Repository navigation
Description
Description
The timeout field declared on RemoteMCPServer and StdioMCPServer in fastmcp/mcp_config.py is silently ignored — it never reaches the transport or the session. A config that looks capped is actually unlimited, with no validation error.
Verified on fastmcp 4.0.4, Python 3.14, macOS.
Where the wire is missing
- Field is declared (
fastmcp/mcp_config.py:252):
class RemoteMCPServer(BaseModel):
...
# Timeout configuration
sse_read_timeout: datetime.timedelta | int | float | None = None
timeout: int | None = None # Maximum response time in millisecondsThe same field exists on StdioMCPServer (line 199).
to_transport()drops it (fastmcp/mcp_config.py:265-291):
if transport == "sse":
return SSETransport(
self.url,
headers=self.headers,
auth=self.auth,
sse_read_timeout=self.sse_read_timeout, # ← sse_read_timeout wired
) # ← self.timeout never read
else:
# Both "http" and "streamable-http" map to StreamableHttpTransport
return StreamableHttpTransport(
self.url,
headers=self.headers,
auth=self.auth, # ← self.timeout never read
)StdioMCPServer.to_transport() (line 212) likewise builds StdioTransport(command, args, env, cwd, keep_alive) without timeout.
-
There is nowhere to pass it (
fastmcp/client/transports/http.py:36-41) —StreamableHttpTransport.__init__accepts onlyurl, headers, auth, httpx_client_factory, verify. -
Session-level read timeout comes only from the
Clientconstructor (transports/config.py:130-140): the single-server path delegates with**session_kwargs, whereread_timeout_secondsis set fromClient(timeout=...)(client.py:499), not from the config entry. So for a single-serverMCPConfig, an entrytimeoutleaves the session with NO read limit at all (None= unlimited, no default is substituted).
Because the model uses extra="allow", a user writing timeout in the dict gets no warning whatsoever — the value is accepted by pydantic and dies there.
Reproduction
from fastmcp import Client
# Entry-level timeout (ms) — silently dropped:
c = Client({"mcpServers": {"x": {"url": "http://example.invalid/mcp", "timeout": 30000}}})
print(c._session_kwargs["read_timeout_seconds"]) # → None (no request limit!)
# Client-level timeout — works:
c2 = Client("http://example.invalid/mcp", timeout=30)
print(c2._session_kwargs["read_timeout_seconds"]) # → 30.0Observed: None for the config-entry form, i.e. a hung tool call can wait forever, despite the config looking like it caps response time at 30 s.
Expected behavior
Either:
- wire the entry
timeout(ms) to the session read timeout for that server (at minimum for the single-server path; note the composite path solved the analogous client-level problem in MCPConfigTransport Timeout Not Applied When Multiple Servers Are Configured #2802 viasession_kwargs.get("read_timeout_seconds")), or - remove the field / make it non-accepted so the silent trap can't be configured.
If the field is intentionally accepted-but-unused for compatibility with some external JSON format (e.g. editors' mcp.json), that should at least be documented on the model.
Workaround
Pass the timeout at the client level instead of the entry:
Client("http://…/mcp", timeout=30, auth=...)
# or a pre-built Client into langchain's MCPAdapter:
async with MCPAdapter(Client(url, timeout=30, auth=BearerAuth(token))) as adapter:
tools = await adapter.list_tools()Version info
- fastmcp: 4.0.4 (installed via
langchain[mcp]>=1.4.0) - python: 3.14
- platform: macOS (darwin), but the gap is pure code-path, platform-independent
Found while unifying request-timeout policies of two clients of the same MCP server (a persistent-session client and a langchain.mcp.MCPAdapter consumer) — the config-dict path looked like the obvious way to set the adapter side's timeout and was silently a no-op.
Activity
CloudCorpRecords commentedon Oct 18, 2026
Could I be assigned this issue? My PR #5757 fixes it (entry
timeoutwired to the session read timeout, with zero-as-disabled aligned toClientsemantics), and the contribution gate needs the issue assigned before merge.Honor per-server MCP config timeouts (PrefectHQ#5758)