Conversation
Requires mcp>=2,<3. The lowlevel Server takes its handlers as constructor arguments and returns full result types; a failing tool is still answered as an is_error result rather than the JSON-RPC error mcp 2 would send. Streamable HTTP is served through the SDK's own app factory, the proxy client uses streamable_http_client (two streams, no session-id callback), Tool fields are snake_case, and result parsing accepts is_error beside isError. The examples build an MCPServer instead of FastMCP. The documented one-liner to serve the codemode server never worked with the lowlevel Server (its run() needs streams): run_server is exported and the README and docs use it. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HczQyfKTwmuaGJdVkg4f6m
There was a problem hiding this comment.
Pull request overview
This PR upgrades Agent Codemode’s MCP integration to MCP Python SDK v2, updating the server implementation, proxy client, and documentation/examples to match the new SDK APIs and response/result shapes.
Changes:
- Bump dependency to
mcp[cli]>=2,<3and adapt server handlers to lowlevelServerconstructor callbacks plus snake_case tool fields. - Update streamable HTTP serving/client transport usage for MCP SDK v2.
- Refresh docs and examples to use the exported
run_serverentry point andMCPServer(instead ofFastMCP) where applicable.
Reviewed changes
Copilot reviewed 15 out of 15 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/conftest.py | Removes FastMCP Settings rebuild workaround that’s no longer needed with the MCP v2 migration. |
| README.md | Updates programmatic server start example to use run_server. |
| pyproject.toml | Bumps MCP dependency to v2 and documents migration link. |
| examples/skills/example_mcp_server.py | Switches example server from FastMCP to MCPServer. |
| examples/simple/example_mcp_server.py | Switches example server from FastMCP to MCPServer. |
| examples/patterns/codemode_example.py | Updates embedded example text to describe lowlevel server usage. |
| docs/docs/skills/index.mdx | Updates docs snippets to use run_server. |
| docs/docs/integrations/index.mdx | Updates integration docs snippets to use run_server. |
| docs/docs/index.mdx | Updates top-level docs snippet to use run_server. |
| agent_codemode/server.py | Migrates to MCP v2 Server callbacks, uses snake_case tool fields, updates streamable HTTP serving. |
| agent_codemode/proxy/mcp_client.py | Updates streamable HTTP client import/name and adapts to the new transport return shape. |
| agent_codemode/discovery/codegen.py | Accepts is_error (snake_case) as well as legacy isError when parsing tool results. |
| agent_codemode/composition/executor.py | Accepts is_error (snake_case) as well as legacy isError when parsing tool results. |
| agent_codemode/version.py | Bumps package version to 1.1.0. |
| agent_codemode/init.py | Exports run_server from the package API surface. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+623
to
+627
| content=[types.TextContent(type="text", text=str(e))], | ||
| is_error=True, | ||
| ) | ||
| json_str = json.dumps(result, indent=2) | ||
| return [types.TextContent(type="text", text=json_str)] | ||
| return types.CallToolResult(content=[types.TextContent(type="text", text=json_str)]) |
Comment on lines
+161
to
+163
| # Serve it over stdio (the MCP SDK's lowlevel Server under the hood) | ||
| from agent_codemode.server import run | ||
| run() |
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.
Requires mcp>=2,<3. The lowlevel Server takes its handlers as constructor arguments and returns full result types; a failing tool is still answered as an is_error result rather than the JSON-RPC error mcp 2 would send. Streamable HTTP is served through the SDK's own app factory, the proxy client uses streamable_http_client (two streams, no session-id callback), Tool fields are snake_case, and result parsing accepts is_error beside isError. The examples build an MCPServer instead of FastMCP.
The documented one-liner to serve the codemode server never worked with the lowlevel Server (its run() needs streams): run_server is exported and the README and docs use it.
Claude-Session: https://claude.ai/code/session_01HczQyfKTwmuaGJdVkg4f6m