Repository navigation
fix(client): wire MCP config entry timeouts to the session read timeout - #5757
CloudCorpRecords wants to merge 3 commits into
Conversation
This comment has been minimized.
This comment has been minimized.
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
BrickerP
left a comment
There was a problem hiding this comment.
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:
- Issue #5754 is still unassigned under FastMCP’s contribution gate — maintainers may want that before merge.
Client(timeout=0)goes throughnormalize_timeout_to_secondsand means “disabled”; an entrytimeout: 0becomes0.0here and would fire immediately. Worth aligning with the client helper if zero-as-disabled is intentional for configs too.
BrickerP
left a comment
There was a problem hiding this comment.
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 / 1000So 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.
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.
|
Zero case fixed per the re-review: |
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>
4aa45e7 to
545305a
Compare
|
Closing as superseded by #5760, which covers the same fix (config entry |
A config entry's
timeoutwas 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 showsread_timeout_secondscoming out asNonefor 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'stimeout(milliseconds, the mcp.json convention) is translated into the session read timeout in seconds: for a single-server config it becomes the session'sread_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-levelClient(timeout=...); entries without a timeout keep the client-level value exactly as before.Fixes #5754
Co-authored-by: phnmn 32295782+phnmn@users.noreply.github.com
Prepared with AI assistance.