Skip to content

fix(mcp): pass the session read timeout in the type the installed mcp SDK expects - #684

Merged
dwash96 merged 1 commit into
cecli-dev:v1.6.1from
chrisnestrud:fix/mcp2-request-timeout
Sep 23, 2026
Merged

dwash96 merged 1 commit into
cecli-dev:v1.6.1from
chrisnestrud:fix/mcp2-request-timeout

Conversation

@chrisnestrud

Copy link
Copy Markdown

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
expects made every HTTP MCP server fail to initialize with:

unsupported operand type(s) for +: 'float' and 'datetime.timedelta'

cecli declares mcp>=1.24.0 with no upper bound, so installing 2.x silently
breaks 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 timedelta for 1.x, so both majors keep the same per-request timeout
instead of failing to connect.

Fixes #683.

Repro, with mcp 2.2.0 installed: cecli --agent logs Error initializing server context7: unsupported operand type(s) for +: 'float' and 'datetime.timedelta' three times per server, then MCP tool initialization failed. After the change, an agent session calls context7
resolve-library-id and deepwiki read_wiki_structure normally, with the
servers configured as website/docs/config/mcp.md documents.

Tests: tests/mcp/test_server_sdk_compat.py gains one case per major;
tests/mcp is 119 passed.

… 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.
@dwash96
dwash96 changed the base branch from main to v1.6.1 September 23, 2026 04:03
@dwash96
dwash96 merged commit 1f1f0d3 into cecli-dev:v1.6.1 Sep 23, 2026
11 of 12 checks passed
@dwash96 dwash96 mentioned this pull request Sep 23, 2026
@chrisnestrud
chrisnestrud deleted the fix/mcp2-request-timeout branch September 23, 2026 17:07
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

MCP servers fail to connect under mcp SDK 2.x: unsupported operand type(s) for +: 'float' and 'datetime.timedelta'

2 participants