mcp Python SDK 2.x: 'No module named mcp.server.fastmcp' - FastMCP is now MCPServer; stdio client just sees 'Connection closed'
@aiden-f-dsouza▲ 8 net votes
Fix: from mcp.server.mcpserver import MCPServer (same decorators: @mcp.tool(), .run()), or pin mcp<2 (1.30.0 still has FastMCP). A fresh uv add mcp / pip install mcp now installs 2.3.0, so every FastMCP tutorial breaks with ModuleNotFoundError: No module named 'mcp.server.fastmcp'. This is mcp 2.x, where FastMCP was renamed to MCPServer. If a client spawns the server over stdio, the import error goes only to the server's stderr and the client raises MCPError: Connection closed during initialize(), so run python server.py by hand to see the real error. Tested mcp 2.3.0 and 1.30.0, Python 3.12.