Repository navigation
Python: Move the TypeSafe MCP sample to mcp 2.x - #9756
Draft
Naveen Chatlapalli (1aifanatic) wants to merge 1 commit into
Draft
Naveen Chatlapalli (1aifanatic) wants to merge 1 commit into
Naveen Chatlapalli (1aifanatic) wants to merge 1 commit into
Conversation
The MCP sample pinned mcp<2, but Agent Framework's MCP client imports mcp.Client from mcp 2.x, so the documented command failed to open the MCP session. With mcp 2.x installed instead, the weather server failed to start because FastMCP was renamed to MCPServer. Port the server to MCPServer, keep its tool returning plain text, and pin both scripts and the README command to mcp>=2.2.0,<3 like the rest of the repository. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Naveen Chatlapalli (1aifanatic)
temporarily deployed
to
github-app-auth
October 27, 2026 12:48 — with
GitHub Actions
Inactive
Naveen Chatlapalli (1aifanatic)
temporarily deployed
to
github-app-auth
October 27, 2026 12:48 — with
GitHub Actions
Inactive
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
The narrow sample-only migration aligns with existing repository usage and dependency requirements, with no unresolved findings.
No open issues 🎉
What changed in this PR
Updates the TypeSafe MCP sample to MCP 2.x, aligning it with the Agent Framework MCP client’s dependency requirements.
Changes:
- Updates both script dependency headers and the README command to
mcp>=2.2.0,<3. - Replaces
FastMCPwithMCPServer. - Disables structured output to preserve the documented plain-text weather response.
| File | Description |
|---|---|
python/packages/typesafe/samples/README.md |
Updates the run command to require MCP 2.x. |
python/packages/typesafe/samples/mcp_weather_server.py |
Migrates the server API and dependency while preserving plain-text output. |
python/packages/typesafe/samples/mcp_function_calling.py |
Aligns the client script’s dependency with MCP 2.x. |
Review effort: Balanced
This branch was previously deployed
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.
Motivation & Context
The TypeSafe MCP sample (
packages/typesafe/samples/mcp_function_calling.pywithmcp_weather_server.py) can't connect to its server under either supportedmcpmajor version:mcpinstalled>=1.27.0,<2, as the README command and both PEP 723 headers pinToolException: Failed to create MCP session ... cannot import name 'Client' from 'mcp'. Since the MCP SDK 2.x migration, core's MCP tools need mcp 2.x; core'sallextra pinsmcp>=2.2.0,<3.No module named 'mcp.server.fastmcp'(FastMCP becameMCPServerin 2.x). The client then reportsConnection closed.Description & Review Guide
mcp_weather_server.pynow usesmcp.server.mcpserver.MCPServer, the same API assamples/04-hosting/mcp/mcpserver_app.py. The tool passesstructured_output=Falseso it still returns plain text (Seattle is sunny and 22 C.), matching the sample's documented output. Without it, mcp 2.x returns{"result": "..."}as the text content.mcp>=2.2.0,<3.Verification: with the README's command (
uv run --with "mcp>=2.2.0,<3" --package agent-framework-typesafe ...),MCPStdioToollaunched the server, discoveredget_weather, and returnedSeattle is sunny and 22 C.for{"city": "Seattle", "detailed": false}. Onmain, both rows above fail.uv run --script mcp_weather_server.pyalso resolves and starts the server. I couldn't run the full sample because it needs aTYPESAFE_API_KEY. I found this by type-checking the example code shipped inside packages: pyright reported"FastMCP" is unknown import symbol.Related Issue
N/A - trivial change: the sample is updated to the MCP SDK major version that Agent Framework's MCP client already requires.
AI Assistance
AI assistance details: Claude Code helped find this by type-checking the package samples, reproduce both failure modes, port the server, and draft this description.
Contribution Checklist
breaking changelabel (or add "[BREAKING]" to the title prefix, before or after any language prefix) — a workflow keeps the label and title prefix in sync automatically.🤖 Generated with Claude Code