fix(mcp): pass the session read timeout in the type the installed mcp SDK expects - #684
Merged
Merged
Conversation
… SDK expects mcp SDK 2.x types ClientSession.read_timeout_seconds as a float number of seconds and adds it to other floats internally, so the timedelta that 1.x wanted made every HTTP MCP server fail to initialize with "unsupported operand type(s) for +: float and datetime.timedelta". Return whichever type the installed major wants so both stay connected. Adds unit coverage for the 1.x and 2.x branches in tests/mcp/test_server_sdk_compat.py.
Merged
JessicaMulein
pushed a commit
to Digital-Defiance/cecli
that referenced
this pull request
Sep 23, 2026
…imeout fix(mcp): pass the session read timeout in the type the installed mcp SDK expects
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
mcp SDK 2.x types
ClientSession.read_timeout_secondsas a float number ofseconds and adds it to other floats internally, so the
timedeltathat 1.xexpects made every HTTP MCP server fail to initialize with:
cecli declares
mcp>=1.24.0with no upper bound, so installing 2.x silentlybreaks the transport, while the other 2.x shims in the same module
(
_get_http_client_module,_unpack_transport, the OAuth callback handler)kept working.
This routes the value through a helper that returns float seconds for mcp 2.x
and a
timedeltafor 1.x, so both majors keep the same per-request timeoutinstead of failing to connect.
Fixes #683.
Repro, with mcp 2.2.0 installed:
cecli --agentlogsError initializing server context7: unsupported operand type(s) for +: 'float' and 'datetime.timedelta'three times per server, thenMCP tool initialization failed. After the change, an agent session calls context7resolve-library-idand deepwikiread_wiki_structurenormally, with theservers configured as
website/docs/config/mcp.mddocuments.Tests:
tests/mcp/test_server_sdk_compat.pygains one case per major;tests/mcpis 119 passed.