mirror of
https://github.com/PrefectHQ/fastmcp.git
synced 2026-08-21 13:04:18 +02:00
custom auth configuration for remote mcp server with mcp config class
This commit is contained in:
parent
3933f4f96c
commit
f2a38d275c
1 changed files with 6 additions and 3 deletions
|
|
@ -4,7 +4,8 @@ import re
|
|||
from typing import TYPE_CHECKING, Annotated, Any, Literal
|
||||
from urllib.parse import urlparse
|
||||
|
||||
from pydantic import AnyUrl, Field
|
||||
import httpx
|
||||
from pydantic import AnyUrl, ConfigDict, Field
|
||||
|
||||
from fastmcp.utilities.types import FastMCPBaseModel
|
||||
|
||||
|
|
@ -59,12 +60,14 @@ class RemoteMCPServer(FastMCPBaseModel):
|
|||
headers: dict[str, str] = Field(default_factory=dict)
|
||||
transport: Literal["streamable-http", "sse"] | None = None
|
||||
auth: Annotated[
|
||||
str | Literal["oauth"] | None,
|
||||
str | Literal["oauth"] | httpx.Auth | None,
|
||||
Field(
|
||||
description='Either a string representing a Bearer token or the literal "oauth" to use OAuth authentication.'
|
||||
description='Either a string representing a Bearer token, the literal "oauth" to use OAuth authentication, or an httpx.Auth instance for custom authentication.',
|
||||
),
|
||||
] = None
|
||||
|
||||
model_config = ConfigDict(arbitrary_types_allowed=True)
|
||||
|
||||
def to_transport(self) -> StreamableHttpTransport | SSETransport:
|
||||
from fastmcp.client.transports import SSETransport, StreamableHttpTransport
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue