Skip to content

Move to the MCP Python SDK 2 (1.1.0) - #8

Open
echarles wants to merge 2 commits into
mainfrom
mcp-2
Open

Move to the MCP Python SDK 2 (1.1.0)#8
echarles wants to merge 2 commits into
mainfrom
mcp-2

Conversation

@echarles

Copy link
Copy Markdown
Member

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

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
Copilot AI lite review requested due to automatic review settings August 26, 2026 11:44

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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,<3 and adapt server handlers to lowlevel Server constructor 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_server entry point and MCPServer (instead of FastMCP) 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 thread agent_codemode/server.py
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()
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.

2 participants