mirror of
https://github.com/PrefectHQ/fastmcp.git
synced 2026-08-22 05:24:18 +02:00
accept timeouts in MCPConfig
This commit is contained in:
parent
3784c1363b
commit
3a304b46af
1 changed files with 12 additions and 2 deletions
|
|
@ -3,6 +3,7 @@ from __future__ import annotations
|
|||
import re
|
||||
from typing import TYPE_CHECKING, Annotated, Any, Literal
|
||||
from urllib.parse import urlparse
|
||||
import datetime
|
||||
|
||||
import httpx
|
||||
from pydantic import AnyUrl, ConfigDict, Field
|
||||
|
|
@ -65,6 +66,7 @@ class RemoteMCPServer(FastMCPBaseModel):
|
|||
description='Either a string representing a Bearer token, the literal "oauth" to use OAuth authentication, or an httpx.Auth instance for custom authentication.',
|
||||
),
|
||||
] = None
|
||||
sse_read_timeout: datetime.timedelta | int | float | None = None
|
||||
|
||||
model_config = ConfigDict(arbitrary_types_allowed=True)
|
||||
|
||||
|
|
@ -77,11 +79,19 @@ class RemoteMCPServer(FastMCPBaseModel):
|
|||
transport = self.transport
|
||||
|
||||
if transport == "sse":
|
||||
return SSETransport(self.url, headers=self.headers, auth=self.auth)
|
||||
return SSETransport(
|
||||
self.url,
|
||||
headers=self.headers,
|
||||
auth=self.auth,
|
||||
sse_read_timeout=self.sse_read_timeout,
|
||||
)
|
||||
else:
|
||||
# Both "http" and "streamable-http" map to StreamableHttpTransport
|
||||
return StreamableHttpTransport(
|
||||
self.url, headers=self.headers, auth=self.auth
|
||||
self.url,
|
||||
headers=self.headers,
|
||||
auth=self.auth,
|
||||
sse_read_timeout=self.sse_read_timeout,
|
||||
)
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue