Skip to content

Config entry 'timeout' field is silently ignored (RemoteMCPServer/StdioMCPServer) — no request limit applied #5754

Closed

Description

@phnmn

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

  1. 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 milliseconds

The same field exists on StdioMCPServer (line 199).

  1. 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.

  1. There is nowhere to pass it (fastmcp/client/transports/http.py:36-41) — StreamableHttpTransport.__init__ accepts only url, headers, auth, httpx_client_factory, verify.

  2. Session-level read timeout comes only from the Client constructor (transports/config.py:130-140): the single-server path delegates with **session_kwargs, where read_timeout_seconds is set from Client(timeout=...) (client.py:499), not from the config entry. So for a single-server MCPConfig, an entry timeout leaves 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.0

Observed: 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:

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

  1. added
    bug
    client
    on Oct 15, 2026
  2. CloudCorpRecords commented on Oct 18, 2026

    @CloudCorpRecords

    Could I be assigned this issue? My PR #5757 fixes it (entry timeout wired to the session read timeout, with zero-as-disabled aligned to Client semantics), and the contribution gate needs the issue assigned before merge.

  3. added a commit that references this issue on Oct 20, 2026
    8f0d481
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugclient

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions