Repository navigation
feat(deps): support mcp 2 alongside mcp 1 - #274
Merged
Merged
Conversation
fetch_mcp_tools and call_mcp_tool each opened the transport, built a ClientSession, initialized it under the same deadline and mapped failures through _raise_mcp_failure. That now lives in one _run_mcp_session helper, import guard included; each function keeps only its own exchange. The retry-once-with-the-looked-up-end-user logic was written three times (per-account listing, search/execute listing, tool execution). It is now retry_for_end_user, with the same rules: only a 400 naming an account that was sent without an end user, and only if the lookup finds one. No behaviour change. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: Guillaume Lebedel <10488548+glebedel@users.noreply.github.com>
The retry condition is documented once, on retry_for_end_user, as the toolset callers already rely on; the copy above the tool's call site restated it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: Guillaume Lebedel <10488548+glebedel@users.noreply.github.com>
retry_for_end_user already checks is_end_user_refusal before it calls the look-up, and every caller goes through it, so the look-up's own check was a second copy that could drift. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: Guillaume Lebedel <10488548+glebedel@users.noreply.github.com>
Main changed the two MCP session bodies this branch folds into _run_mcp_session. The shared helper stays, with main's edits carried over: tools/list pages with list_tools(params=PaginatedRequestParams(...)), the mcp imports drop their ty ignores, and the shared SSL context merged on its own. The types import in fetch_mcp_tools sits inside _list, so it runs after the helper's guarded import and a broken install still raises ToolsetConfigError. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: Guillaume Lebedel <10488548+glebedel@users.noreply.github.com>
The pagination test only counted calls, so a regression to the old positional cursor argument would still pass. Assert the first call sends params=None and the second carries the next cursor. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: Guillaume Lebedel <10488548+glebedel@users.noreply.github.com>
Widen the mcp range to >=1.30.0,<3.0.0 and lock mcp 2.3.0, so installs next to packages that need mcp 2 (fastmcp 4, newer agent frameworks) no longer conflict, while projects pinned to mcp 1 (langchain-mcp-adapters caps mcp<2) keep resolving. mcp 2 changed four things the SDK relied on: - its transport takes an httpx2 client, not an httpx one, and yields two streams instead of three; - model attributes are snake_case only (is_error, structured_content, input_schema, next_cursor), so getattr(result, "isError", False) silently read every failed tool call as a success; - a failed POST becomes a JSON-RPC error with no HTTP status or body, which lost the 400/412/429 status that end-user recovery, rate limiting and error messages read; - ClientRequest is a typing union, so the request is passed directly. The MCP client now uses whichever HTTP library the installed mcp takes, reads fields under either name, and raises a non-404 POST error status itself, as mcp 1 does. GET /accounts keeps using httpx. CI also runs the suite against mcp 1.30.0. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: Guillaume Lebedel <10488548+glebedel@users.noreply.github.com>
mcp 2.0.x and 2.1.x carry four published advisories that 2.2.0 fixes (GHSA-w4fh-qvv9-3v23, GHSA-5h93-6whr-6q8j, GHSA-rwrf-2pqf-9j8j, GHSA-84m7-p3x7-pcfv), so the range excludes them as it already excludes mcp 1 below 1.30.0. The pagination test now builds the installed mcp's own ListToolsResult and Tool models, so it reads the field names that major really uses. The async client tests assert that a failed POST raises with its body readable, and that a 404 POST, a GET and a DELETE are handed back to mcp unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: Guillaume Lebedel <10488548+glebedel@users.noreply.github.com>
This was referenced Nov 11, 2026
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.
What
The SDK now runs on mcp 2 as well as mcp 1.
pyproject.tomlallowsmcp>=1.30.0,!=2.0.*,!=2.1.*,<3.0.0and the lockfile pins mcp 2.3.0. This replaces the Dependabot bump in #208, which cannot merge as is: on mcp 2.3.0, everyfetch_tools()and tool call onmainfails.stackone_ai/tools.py:_mcp_httpis httpx2 when mcp 2 is installed and httpx otherwise, and the MCP transport client, timeouts and error types come from it.GET /accountsstays on httpx._mcp_fieldreads model fields by their snake_case name (mcp 2) or wire name (mcp 1):inputSchema,nextCursor,structuredContent,isError.HTTPStatusErrorwith its status and body, as mcp 1 does. mcp 2 would turn it into a JSON-RPC error with neither. A 404 is still handed to mcp, which reports a lost session.call_mcp_toolpassesCallToolRequesttosend_requestdirectly, which both majors accept.Why, with evidence
mainon mcp 2.3.0:ToolsetLoadError: ... ValueError: not enough values to unpack (expected 3, got 2)on every list and call, becausestreamable_http_clientchanged its yield.How verified
ruff check,ruff format --check,ty check stackone_ai examples: clean.pytest: 879 passed on mcp 2.3.0 (locked), on 2.2.0 and on 1.30.0 (uv run --with).scripts/validate.sh: PASS 6/6 (examples, conformance--strict-schema, SDK smoke, Pydantic AI 1.x and 2.x, Google ADK plugin).tests/mocks/serve.ts): list two accounts (one valid, one the mock refuses with 400), then call a listed tool and an unknown one.acc1main, mcp 1.30.0StackOneAPIError400 with server bodyStackOneAPIError"Unknown tool"main, mcp 2.3.0ToolsetLoadError(unpack)ToolsetLoadError(unpack)ToolsetLoadErrorToolsetLoadErrorStackOneAPIError400 with server bodyStackOneAPIError"Unknown tool"StackOneAPIError400 with server bodyStackOneAPIError"Unknown tool"Good citizen
Retry counts, backoff,
Retry-Afterhandling, timeouts and concurrency are unchanged. TLS still uses the same verified SSL context. No new network calls and no new dependencies: httpx2 is imported only when mcp 2, which requires it, is installed.Gates (head 5429c2b)
uv lock --checkok; no OSV/GHSA entries for the new versions_buffer_error_body, unchanged frommain)Tool.inputSchemais a required dict on both majors, thetoolset.pyitems belong to #261Merge order
This branch is built on #261 and includes its commits, so merge #261 first. This PR then supersedes #208, which can be closed.
Post-merge validation
feat(minor) release PR; after it publishes, install the release with mcp 2.3.0 and with mcp 1.30.0 and run the quickstart example against a real key.Requested by guillaume@stackone.com in Slack (repo audit thread).
🤖 Generated with Claude Code
Summary by cubic
The SDK now runs on mcp 2 as well as mcp 1, so installs next to packages that require mcp 2 no longer conflict while projects pinned to mcp 1 keep resolving. On main, mcp 2 made every
fetch_tools()call and tool invocation fail with aToolsetLoadError.mcp>=1.30.0,!=2.0.*,!=2.1.*,<3.0.0and the lockfile pins mcp 2.3.0; 2.0.x and 2.1.x are excluded because they carry four published advisories.GET /accountsstays on httpx.inputSchema,nextCursor,structuredContent,isError); on mcp 2 the wire names silently read every failed call as a success.HTTPStatusErrorwith their status and body, as mcp 1 does; mcp 2 would otherwise turn them into a JSON-RPC error carrying neither. A 404 is still left to mcp as a lost session.Written for commit 5429c2b. Summary will update on new commits.