Spaces:
Running
Running
Merge pull request #1031 from cegersdoerfer/mcpconfig-timeout
Browse files
src/fastmcp/utilities/mcp_config.py
CHANGED
|
@@ -1,5 +1,6 @@
|
|
| 1 |
from __future__ import annotations
|
| 2 |
|
|
|
|
| 3 |
import re
|
| 4 |
from typing import TYPE_CHECKING, Annotated, Any, Literal
|
| 5 |
from urllib.parse import urlparse
|
|
@@ -65,6 +66,7 @@ class RemoteMCPServer(FastMCPBaseModel):
|
|
| 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 |
|
|
@@ -77,11 +79,19 @@ class RemoteMCPServer(FastMCPBaseModel):
|
|
| 77 |
transport = self.transport
|
| 78 |
|
| 79 |
if transport == "sse":
|
| 80 |
-
return SSETransport(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 81 |
else:
|
| 82 |
# Both "http" and "streamable-http" map to StreamableHttpTransport
|
| 83 |
return StreamableHttpTransport(
|
| 84 |
-
self.url,
|
|
|
|
|
|
|
|
|
|
| 85 |
)
|
| 86 |
|
| 87 |
|
|
|
|
| 1 |
from __future__ import annotations
|
| 2 |
|
| 3 |
+
import datetime
|
| 4 |
import re
|
| 5 |
from typing import TYPE_CHECKING, Annotated, Any, Literal
|
| 6 |
from urllib.parse import urlparse
|
|
|
|
| 66 |
description='Either a string representing a Bearer token, the literal "oauth" to use OAuth authentication, or an httpx.Auth instance for custom authentication.',
|
| 67 |
),
|
| 68 |
] = None
|
| 69 |
+
sse_read_timeout: datetime.timedelta | int | float | None = None
|
| 70 |
|
| 71 |
model_config = ConfigDict(arbitrary_types_allowed=True)
|
| 72 |
|
|
|
|
| 79 |
transport = self.transport
|
| 80 |
|
| 81 |
if transport == "sse":
|
| 82 |
+
return SSETransport(
|
| 83 |
+
self.url,
|
| 84 |
+
headers=self.headers,
|
| 85 |
+
auth=self.auth,
|
| 86 |
+
sse_read_timeout=self.sse_read_timeout,
|
| 87 |
+
)
|
| 88 |
else:
|
| 89 |
# Both "http" and "streamable-http" map to StreamableHttpTransport
|
| 90 |
return StreamableHttpTransport(
|
| 91 |
+
self.url,
|
| 92 |
+
headers=self.headers,
|
| 93 |
+
auth=self.auth,
|
| 94 |
+
sse_read_timeout=self.sse_read_timeout,
|
| 95 |
)
|
| 96 |
|
| 97 |
|