Skip to content

fix(client): wire MCP config entry timeouts to the session read timeout - #5757

Closed
CloudCorpRecords wants to merge 3 commits into
PrefectHQ:mainfrom
CloudCorpRecords:fix/config-entry-timeout
Closed

CloudCorpRecords wants to merge 3 commits into
PrefectHQ:mainfrom
CloudCorpRecords:fix/config-entry-timeout

Conversation

@CloudCorpRecords

Copy link
Copy Markdown

A config entry's timeout was accepted by the models and then dropped: nothing ever read it, so a config that looked capped left the session with no read timeout at all. The repro in the issue shows read_timeout_seconds coming out as None for the entry form while the client-level form works, which means a hung tool call on such a server waits forever behind a config that says otherwise.

This wires the entry value through in MCPConfigTransport. An entry's timeout (milliseconds, the mcp.json convention) is translated into the session read timeout in seconds: for a single-server config it becomes the session's read_timeout_seconds, and in a multi-server config each backend proxy client gets its own entry's value. The entry is the more specific setting, so it takes precedence over a client-level Client(timeout=...); entries without a timeout keep the client-level value exactly as before.

config = {"mcpServers": {"weather": {"url": "https://example.com/mcp", "timeout": 30000}}}

async with Client(config) as client:  # requests to weather now time out after 30s
    await client.call_tool("get_forecast", {"city": "SF"})

Fixes #5754

Co-authored-by: phnmn 32295782+phnmn@users.noreply.github.com

Prepared with AI assistance.

@github-actions

This comment has been minimized.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ⚠️ Failed 2026-10-15T21:22:19.724181Z 87f819e PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@marvin-context-protocol marvin-context-protocol Bot added bug Something isn't working. Reports of errors, unexpected behavior, or broken functionality. client Related to the FastMCP client SDK or client-side functionality. labels Oct 15, 2026

@BrickerP BrickerP left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks correct for #5754: entry timeout (ms) becomes session read_timeout_seconds, the entry wins over a client-level timeout on the single-server path, and multi-server backends get a per-entry value (or keep the client-level one).

Two notes, neither blocking:

  1. Issue #5754 is still unassigned under FastMCP’s contribution gate — maintainers may want that before merge.
  2. Client(timeout=0) goes through normalize_timeout_to_seconds and means “disabled”; an entry timeout: 0 becomes 0.0 here and would fire immediately. Worth aligning with the client helper if zero-as-disabled is intentional for configs too.

@BrickerP BrickerP left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-review: timeout: 0 must disable, not become 0.0s

I approved this earlier today for correctly wiring entry timeout (ms) into the session. On a closer pass against Client / normalize_timeout_to_seconds, there is one semantic gap:

_entry_timeout_seconds does:

return config.timeout / 1000

So a config entry with timeout: 0 becomes 0.0, and because 0.0 is not None, the single-server path sets read_timeout_seconds=0.0.

That disagrees with client-level semantics. Client documents and implements “0 means disabled → None” via normalize_timeout_to_seconds (fastmcp_slim/fastmcp/client/client.py around the read_timeout_seconds = normalize_timeout_to_seconds(timeout) call, and the util docstring: “Zero values are treated as disabled and return None”).

Please treat a set-but-zero entry the same way: return None for the session timeout while still overriding an unset/default client timeout (so timeout: 0 is distinguishable from an omitted field). #5760’s (is_set, seconds) helper is one clean shape for that; #5758’s / 1000 or None also lands on disabled-zero but is easier to misread.

Also note #5758 and #5760 are concurrent fixes for the same #5754 — once zero-handling is fixed here (or maintainers pick #5760), the other two should close as duplicates.

Happy to re-approve after the zero case is pinned with a test.

CloudCorpRecords added a commit to CloudCorpRecords/fastmcp that referenced this pull request Oct 18, 2026
BrickerP (re-review on PrefectHQ#5757): timeout 0 became read_timeout_seconds 0.0,
which fires immediately, disagreeing with Client semantics where 0 means
disabled via normalize_timeout_to_seconds. _entry_timeout_seconds now
returns (is_set, seconds) so a set-but-zero entry disables (None) while
still overriding an unset/default client timeout. Pinned with single and
multi-server zero tests.
@CloudCorpRecords

Copy link
Copy Markdown
Author

Zero case fixed per the re-review: _entry_timeout_seconds now returns (is_set, seconds), so a set-but-zero entry disables (None) while still overriding an unset/default client timeout — matching Client(timeout=0) via normalize_timeout_to_seconds. Pinned with single-server and multi-server zero tests (both failed with 0.0 before). Suite (54 tests), ruff, format, and ty all green. The check-issue-link failure is the unassigned #5754 — I've asked for assignment there.

CloudCorpRecords and others added 3 commits October 18, 2026 11:37
Co-authored-by: phnmn <32295782+phnmn@users.noreply.github.com>
Signed-off-by: Rene Turcios <95189389+CloudCorpRecords@users.noreply.github.com>
…server configs

Signed-off-by: Rene Turcios <95189389+CloudCorpRecords@users.noreply.github.com>
BrickerP (re-review on PrefectHQ#5757): timeout 0 became read_timeout_seconds 0.0,
which fires immediately, disagreeing with Client semantics where 0 means
disabled via normalize_timeout_to_seconds. _entry_timeout_seconds now
returns (is_set, seconds) so a set-but-zero entry disables (None) while
still overriding an unset/default client timeout. Pinned with single and
multi-server zero tests.

Signed-off-by: Rene Turcios <95189389+CloudCorpRecords@users.noreply.github.com>
@CloudCorpRecords
CloudCorpRecords force-pushed the fix/config-entry-timeout branch from 4aa45e7 to 545305a Compare October 18, 2026 18:37
@CloudCorpRecords

Copy link
Copy Markdown
Author

Closing as superseded by #5760, which covers the same fix (config entry timeout -> session read_timeout_seconds, including per-backend proxy clients) and already has approval. Thanks for the review feedback here regardless — it helped validate the approach.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working. Reports of errors, unexpected behavior, or broken functionality. bypass-issue-check client Related to the FastMCP client SDK or client-side functionality.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

3 participants