chore(deps): update mcp requirement from <2,>=1.28.1 to >=2.2.0,<3 - #2334
Conversation
Updates the requirements on [mcp](https://github.com/modelcontextprotocol/python-sdk) to permit the latest version. - [Release notes](https://github.com/modelcontextprotocol/python-sdk/releases) - [Changelog](https://github.com/modelcontextprotocol/python-sdk/blob/main/RELEASE.md) - [Commits](modelcontextprotocol/python-sdk@v1.28.1...v2.2.0) --- updated-dependencies: - dependency-name: mcp dependency-version: 2.2.0 dependency-type: direct:production ... Signed-off-by: dependabot[bot] <support@github.com>
ReviewThis is an automated Dependabot bump of
Findings
RecommendationClose or hold this PR until |
python-sdk 2.0 removed decorator-based handler registration on mcp.server.Server in favour of on_*= constructor kwargs whose handlers take (ctx, params) and return typed result models. opencontractserver/mcp/server.py still used the 1.x decorators, so the dependabot bump alone would have broken both MCP entrypoints at import time (see the review on #2334). - server.py: build the global and corpus-scoped servers through shared adapters (_build_on_call_tool, _build_on_list_tools, _build_on_list_resource_templates, _on_read_resource). Argument validation against inputSchema and isError wrapping of dispatcher exceptions -- which the 1.x call_tool decorator did implicitly -- are now explicit. Tool and template catalogues move to get_tool_definitions() / get_resource_template_definitions(). SDK types use their 2.x snake_case fields; resource URIs are plain str. - resources/read payloads are stamped application/json (MCP_RESOURCE_MIME_TYPE) to match the advertised templates; caller-side read failures return JSON-RPC INVALID_PARAMS with the message. - tests: replace the removed server.request_handlers seam with mcp.client.Client in-memory sessions and add MCPSdkClientRoundTripTest, which drives both servers through the SDK runtime (list/call/read, validation errors, permission propagation) plus a real stateless Streamable HTTP JSON-RPC request through StreamableHTTPSessionManager. - requirements/base.txt + .pre-commit-config.yaml: mcp>=2.2.0,<3 with the stale "fastmcp-slim caps mcp<2" note replaced (fastmcp-slim resolves against 2.x; pip check is clean). - docs/mcp/README.md: SDK integration section; changelog fragment added.
|
Pushed the companion migration the review asked for (3fc6fde), so this bump no longer lands as a bare pin change. Addressing the three findings:
Two intentional wire-level changes, noted in the changelog fragment: Generated by Claude Code |
Review: mcp python-sdk 2.x migrationThis is well beyond a routine dependabot bump — A few things worth a look before merge: 1. Schema-validation short-circuit skips per-tool rate limiting and telemetry (moderate)In ```python But Net effect after this PR: a caller can send a known tool name with a deliberately wrong-typed argument (e.g.
2.
|
Follow-up to the python-sdk 2.x migration, addressing the automated review on #2334: - A call rejected by inputSchema validation never reached the dispatcher, so it consumed no per-tool rate-limit budget and left no telemetry row. _reject_malformed_arguments now runs _check_per_tool_rate_limit and records an InputValidationError event before returning the isError result; scoped servers pass their URL-bound corpus_slug for attribution. (1.x's call_tool decorator had the same pre-validation gap; this closes it rather than merely restoring parity.) - The adapter's catch-all now also covers a jsonschema.SchemaError from a malformed tool definition, and MCPToolSchemaValidityTest checks every advertised inputSchema against the JSON Schema meta-schema so such a typo fails in CI instead of at runtime. - jsonschema is imported directly by server.py, so it gets an explicit pin in requirements/base.txt instead of riding on mcp's dependency tree.
|
Addressed all three findings in e9da3dc. 1. Schema-rejected calls bypass per-tool rate limiting / telemetry — fixed. One correction to the premise: this was not new in this PR. The 1.x 2. 3. Explicit Verified locally against mcp 2.2.0: full Generated by Claude Code |
|
Review This is a substantial, well-executed migration of the MCP server to python-sdk 2.x, well beyond a typical dependabot bump. The on_*= adapter approach (_build_on_call_tool, _build_on_list_tools, _build_on_list_resource_templates, _on_read_resource) is a clean way to centralize argument validation, error wrapping, and resource serialization for both the global and scoped servers. The new MCPSdkClientRoundTripTest suite driving real mcp.client.Client sessions and a live StreamableHTTPSessionManager request is a big upgrade over the old server.request_handlers[...] seam - it actually exercises the SDK wiring that changed. The docstrings/comments (e.g. the "do not double-record telemetry" note on the scoped call_tool, the _format_tool_error_text identity-check comment) read like real lessons learned, not boilerplate. The .pre-commit-config.yaml mcp pin is correctly kept in lockstep with requirements/base.txt, and the changelog fragment follows the changelog.d/ convention. A couple of minor things worth a look, nothing blocking:
Other things checked that look correct:
Test coverage looks strong - schema-validity pinning (MCPToolSchemaValidityTest), rate-limit/telemetry edge cases, resource-read error mapping, and the full SDK round trip are all covered. |
…nyUrl test comment Follow-up nits from the automated review on #2334: the constant added for resources/read payloads now also backs every Resource/ResourceTemplate mime_type so the advertised and served types cannot drift, and the scoped resource test no longer claims Resource.uri is an AnyUrl (mcp 2.x types it as str).
|
Both nits taken in 29f5f5f: every On the error-exposure note: agreed that Generated by Claude Code |
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
|
Status on 29f5f5f: every code check is green (linter, pytest, backend-ci-gate, redis-integration, CodeQL, codecov patch). The one red check, The Codecov note (one uncovered line in Generated by Claude Code |
|
Re-running Generated by Claude Code |
Review: mcp 2.x migrationThis is a substantial hand-authored migration riding on top of the dependabot version bump (not a mechanical dependency update), so I reviewed Strengths
Minor notes (non-blocking)
Verified
Nice work — this is a clean, well-tested migration of a non-trivial breaking SDK upgrade. |
…failures Follow-up notes from the automated review on #2334: ServerRequestContext is part of mcp.server's public __all__, so import it from there instead of the lowlevel submodule (one less internal seam to drift). The adapter's catch-all now also emits a server-side warning so a failure that surfaces to the client as an isError result is visible in logs too. The list() copy on the result content stays: list is invariant and mypy needs the copy to widen list[TextContent] to the SDK's content-block union (comment added).
|
Thanks for the re-review. The three minor notes, in a7a1b81:
Round-trip and adapter tests, mypy and lint pass locally. Generated by Claude Code |
|
Review: MCP python-sdk 2.x migration This started as a routine Dependabot bump (mcp<2 to mcp>=2.2.0,<3) but correctly grew into a full migration of Correctness
Minor / non-blocking observations
Test coverage Security Overall this is a careful, well-tested migration with good documentation (README section + changelog fragment) tying the change together. I'd merge once CI is green (couldn't verify checks status directly from this session). |
|
Thanks. On the two non-blocking notes:
Nothing else outstanding from my side; the PR is ready to merge once CI on a7a1b81 finishes. Generated by Claude Code |
Updates the requirements on mcp to permit the latest version.
Release notes
Sourced from mcp's releases.
... (truncated)
Commits
9972c21Replace RootModel wrappers with type aliases and TypeAdapter validation (#3470)fd66270docs: refresh translations, and translate pages in parallel (#3458)08a3bc8docs: ask for AI disclosure on comments too (#3459)7bb486adocs: stop presenting the in-memory client as the way to connect (#3443)0c91368Add AuthSettings.validate_token_resource to check a bearer token's resource (...9771e6bKeep following a relative redirect when the endpoint URL carries userinfo (#3...a925e55Bump the locked versions of eight dev and test dependencies (#3449)e8b9486Bump pymdown-extensions from 11.0 to 11.0.1 (#3285)c6762e8Follow redirects only within the MCP endpoint's origin (#3397)5fd3abcSkip automatic docs previews for fork PRs and drop the setup-uv retry steps (...Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting
@dependabot rebase.Dependabot commands and options
You can trigger Dependabot actions by commenting on this PR:
@dependabot rebasewill rebase this PR@dependabot recreatewill recreate this PR, overwriting any edits that have been made to it@dependabot show <dependency name> ignore conditionswill show all of the ignore conditions of the specified dependency@dependabot ignore this major versionwill close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)@dependabot ignore this minor versionwill close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)@dependabot ignore this dependencywill close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)