Title: Restore mcp.server.fastmcp as a deprecated import alias for MCPServer by maxisbey · Pull Request #3189 · modelcontextprotocol/python-sdk · GitHub
Open Graph Title: Restore mcp.server.fastmcp as a deprecated import alias for MCPServer by maxisbey · Pull Request #3189 · modelcontextprotocol/python-sdk
X Title: Restore mcp.server.fastmcp as a deprecated import alias for MCPServer by maxisbey · Pull Request #3189 · modelcontextprotocol/python-sdk
Description: Adds a deprecated mcp.server.fastmcp import path so the single most common line in v1 code, from mcp.server.fastmcp import FastMCP, resolves again on v2 (with an MCPDeprecationWarning) instead of raising ModuleNotFoundError, and makes MCPServer's constructor keyword-only after name. Motivation and Context from mcp.server.fastmcp import FastMCP is the first line of nearly every v1 server, and of most tutorial and LLM-generated code, so it's row 1 of the migration guide's "changes almost every project hits" table. For decorator-built servers the rename is genuinely most of the port: the README-shaped v1 quickstart (FastMCP("Demo") + @mcp.tool() / @mcp.resource() / @mcp.prompt() + mcp.run()) runs unmodified on v2 given only the class alias. This is the one v1 name where the alias alone rescues real programs, which is the line for shimming it — mcp.types and McpError stay hard breaks because an alias there saves nobody. Scope is deliberately narrow: Package init only. FastMCP, Context, Image, Audio, Icon (v1's exact __all__) resolve to the v2 objects; mcp.server.fastmcp.server, .prompts.base, etc. still raise ModuleNotFoundError, since nothing beneath them is behaviour-equivalent. The warning is honest. It says this is not just a rename (default server name, transport params off the constructor, sync handlers on a worker thread) and links the guide. MCPDeprecationWarning subclasses UserWarning, so it shows without -W. Removed in v3. from mcp.server import FastMCP is not restored (v1 exported it there too): that needs a module-level __getattr__ on mcp.server, which loosens static checking of every from mcp.server import ... for all downstream users. No API-reference page — the doc generator skips deprecated shim modules. The keyword-only constructor closes the one hazard the shim would otherwise make silent. v2 inserted title/description ahead of instructions, so a v1 FastMCP("Demo", "You answer questions about the weather.") used to run without complaint and land the instructions in title; with the import erroring, users at least met the guide first. Now that the import warns and continues, that call raises TypeError instead — for shim users and mechanical-rename users alike, matching what the lowlevel Server already does. The migration guide's constructor section is rewritten from "silently misassigns" to "raises". How Has This Been Tested? New tests/server/test_fastmcp.py: the import warns with the replacement named, and the five re-exports are the v2 objects (FastMCP is MCPServer, v1 __all__ preserved). Full suite: ./scripts/test at 100% coverage, strict-no-cover clean; pyright 0 errors. Ran an unmodified v1 README-shaped server end-to-end through the old import against an in-process Client: tool call, resource template, and prompt all round-trip; the warning is attributed to the user's own import line (stacklevel correct) and fires once per process. Probed the edges: from mcp.server.fastmcp.prompts import base → ModuleNotFoundError; positional FastMCP('Demo', 'instructions') → the TypeError quoted in the guide; python -W error::UserWarning -c 'import mcp.server.fastmcp' → raises the warning cleanly by category; from mcp.server import FastMCP → still ImportError. Regenerated docs/api/ before and after: no fastmcp page either way. Breaking Changes MCPServer(...) no longer accepts title, description, instructions, website_url, icons, version, auth_server_provider, or token_verifier positionally — pass them by keyword (the migration guide already recommended this; the signature now enforces it). Documented in docs/migration.md. The new import path is additive (previously it did not exist), gated behind a deprecation warning. Types of changes New feature (non-breaking change which adds functionality) Breaking change (fix or feature that would cause existing functionality to change) Documentation update Checklist I have read the MCP Documentation My code follows the repository's style guidelines New and existing tests pass locally I have added appropriate error handling I have added or updated documentation as needed AI Disclaimer
Open Graph Description: Adds a deprecated mcp.server.fastmcp import path so the single most common line in v1 code, from mcp.server.fastmcp import FastMCP, resolves again on v2 (with an MCPDeprecationWarning) instead of r...
X Description: Adds a deprecated mcp.server.fastmcp import path so the single most common line in v1 code, from mcp.server.fastmcp import FastMCP, resolves again on v2 (with an MCPDeprecationWarning) instead of r...
Opengraph URL: https://github.com/modelcontextprotocol/python-sdk/pull/3189
X: @github
Domain: github.com
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:99e5acac-4dfd-7487-335f-92087f624e8b |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | DDE6:D1C6A:6778FC:8AA6F9:6B00AC59 |
| html-safe-nonce | 3cfc0527e6529d32f805a9b8567b5b7737b2a1fdb7d4be42034bee4028035683 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEREU2OkQxQzZBOjY3NzhGQzo4QUE2Rjk6NkIwMEFDNTkiLCJ2aXNpdG9yX2lkIjoiNDQ3MDgzMzk1MDcyOTc0MzQ0OSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 7535c1042e6f6319448833b876ea4d9c6a4ce63f449477a9f7cfb90f28042057 |
| hovercard-subject-tag | pull_request:4145716728 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/modelcontextprotocol/python-sdk/pull/3189/files |
| twitter:image | https://avatars.githubusercontent.com/u/224885523?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/224885523?s=400&v=4 |
| og:image:alt | Adds a deprecated mcp.server.fastmcp import path so the single most common line in v1 code, from mcp.server.fastmcp import FastMCP, resolves again on v2 (with an MCPDeprecationWarning) instead of r... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | c0dd5f5d6f515a591019ecd66df2c4eab3379c2d3b0777568a90d8c7ae10b79e |
| turbo-cache-control | no-preview |
| diff-view | unified |
| go-import | github.com/modelcontextprotocol/python-sdk git https://github.com/modelcontextprotocol/python-sdk.git |
| octolytics-dimension-user_id | 182288589 |
| octolytics-dimension-user_login | modelcontextprotocol |
| octolytics-dimension-repository_id | 862584018 |
| octolytics-dimension-repository_nwo | modelcontextprotocol/python-sdk |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 862584018 |
| octolytics-dimension-repository_network_root_nwo | modelcontextprotocol/python-sdk |
| turbo-body-classes | logged-out env-production page-responsive full-width |
| disable-turbo | true |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 729d8cda69b3d267995675dfbf89ff27ccf61bf6 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width