Spaces:
Running
Running
Merge pull request #906 from Jason-CKY/feat/custom-auth-mcpconfig
Browse files
src/fastmcp/utilities/mcp_config.py
CHANGED
|
@@ -4,7 +4,8 @@ import re
|
|
| 4 |
from typing import TYPE_CHECKING, Annotated, Any, Literal
|
| 5 |
from urllib.parse import urlparse
|
| 6 |
|
| 7 |
-
|
|
|
|
| 8 |
|
| 9 |
from fastmcp.utilities.types import FastMCPBaseModel
|
| 10 |
|
|
@@ -59,12 +60,14 @@ class RemoteMCPServer(FastMCPBaseModel):
|
|
| 59 |
headers: dict[str, str] = Field(default_factory=dict)
|
| 60 |
transport: Literal["streamable-http", "sse"] | None = None
|
| 61 |
auth: Annotated[
|
| 62 |
-
str | Literal["oauth"] | None,
|
| 63 |
Field(
|
| 64 |
-
description='Either a string representing a Bearer token
|
| 65 |
),
|
| 66 |
] = None
|
| 67 |
|
|
|
|
|
|
|
| 68 |
def to_transport(self) -> StreamableHttpTransport | SSETransport:
|
| 69 |
from fastmcp.client.transports import SSETransport, StreamableHttpTransport
|
| 70 |
|
|
|
|
| 4 |
from typing import TYPE_CHECKING, Annotated, Any, Literal
|
| 5 |
from urllib.parse import urlparse
|
| 6 |
|
| 7 |
+
import httpx
|
| 8 |
+
from pydantic import AnyUrl, ConfigDict, Field
|
| 9 |
|
| 10 |
from fastmcp.utilities.types import FastMCPBaseModel
|
| 11 |
|
|
|
|
| 60 |
headers: dict[str, str] = Field(default_factory=dict)
|
| 61 |
transport: Literal["streamable-http", "sse"] | None = None
|
| 62 |
auth: Annotated[
|
| 63 |
+
str | Literal["oauth"] | httpx.Auth | None,
|
| 64 |
Field(
|
| 65 |
+
description='Either a string representing a Bearer token, the literal "oauth" to use OAuth authentication, or an httpx.Auth instance for custom authentication.',
|
| 66 |
),
|
| 67 |
] = None
|
| 68 |
|
| 69 |
+
model_config = ConfigDict(arbitrary_types_allowed=True)
|
| 70 |
+
|
| 71 |
def to_transport(self) -> StreamableHttpTransport | SSETransport:
|
| 72 |
from fastmcp.client.transports import SSETransport, StreamableHttpTransport
|
| 73 |
|