No module named 'mcp.server.fastmcp'
- Spec
2026-07-28- Evidence
- E2Reproducedarm64
- Python SDK
mcp@2.3.0- Verified
What it means
Section titled “What it means”The Python SDK 2.x renamed FastMCP to MCPServer. With mcp 2.3.0 installed, the import from almost every 1.x tutorial fails:
ModuleNotFoundError: No module named 'mcp.server.fastmcp'. This is mcp 2.x, where FastMCP was renamed to MCPServer (from mcp.server.mcpserver import MCPServer) and other APIs changed; see the migration guide at https://py.sdk.modelcontextprotocol.io/v2/migration/#fastmcp-renamed-to-mcpserver or pin 'mcp<2' to keep running v1 code.Importing the old name from its new package fails differently:
ImportError: cannot import name 'FastMCP' from 'mcp.server'The server stops at import, so a client usually shows Connection closed and the text above is in the server’s log.
SDK 2.x is installed and the code is for 1.x
Section titled “SDK 2.x is installed and the code is for 1.x”Update the code. The migration guide gives the new import:
# SDK 1.xfrom mcp.server.fastmcp import FastMCPmcp = FastMCP("Demo")
# SDK 2.xfrom mcp.server.mcpserver import MCPServermcp = MCPServer("Demo")Our example server uses from mcp.server import MCPServer, which also works in 2.3.0. The rename is not the only change: the guide also lists ctx.fastmcp becoming ctx.mcp_server and FastMCPError becoming MCPServerError. See Upgrade a Python server to SDK 2.x.
The dependency is not pinned
Section titled “The dependency is not pinned”If the code worked yesterday and nobody changed it, a fresh install picked up 2.x. Until you migrate, pin the old line, as the error message suggests:
uv add "mcp<2" # or in requirements.txt: mcp<2Related
Section titled “Related”- ModuleNotFoundError: No module named ‘mcp’: the SDK is not installed at all.
Sources
MCPDev is community documentation. It is not affiliated with the Model Context Protocol project or with the vendors of the clients it covers.