MCP Python SDK v2: FastMCP Is Now MCPServer
Eric Greene November 30, 2026Version 2 of the official MCP Python SDK is now the stable line, and pip install mcp installs it. According to the SDK's what's new page, two things changed at once: the SDK was rebuilt, and it now speaks the 2026-07-28 revision of the Model Context Protocol, which removes sessions and the initialize handshake. The change most teams hit first is a rename. The high-level FastMCP class is now MCPServer, and the old import path was removed, not deprecated. A Python MCP server that imports FastMCP from the SDK and installs mcp without an upper bound stops importing on its next build.
The rename and what moved with it
The decorators didn't change. @mcp.tool(), @mcp.resource() and @mcp.prompt() work as before, so most of a server's code stays put. What changes is the import, the class name, and where transport settings live. Here is a small v1 server:
from mcp.server.fastmcp import FastMCP
mcp = FastMCP("Demo", port=9000)
@mcp.tool()
def add(a: int, b: int) -> int:
return a + b
mcp.run(transport="streamable-http")And the same server on v2:
from mcp.server import MCPServer
mcp = MCPServer("Demo")
@mcp.tool()
def add(a: int, b: int) -> int:
return a + b
mcp.run(transport="streamable-http", host="127.0.0.1", port=9000)The migration guide lists the rest of the renames. The mcp.server.fastmcp modules moved to mcp.server.mcpserver, ctx.fastmcp became ctx.mcp_server, FastMCPError became MCPServerError, and McpError became MCPError. get_context() is gone: a tool that needs the request context declares a ctx: Context parameter instead.
A few changes don't raise an import error, so they are easy to miss in review:
- Transport options such as
host,port,stateless_httpandjson_responsemoved from the constructor torun()and the app builders.MCPServer("x", port=9000)raisesTypeError, andmount_pathis gone, so a server mounted inside a Starlette or FastAPI app mounts the ASGI app instead. - The server no longer reads
MCP_*environment variables or.envfiles. Read them in your own code, then pass transport values such ashostandporttorun()or the app builder, and the other settings to the constructor. A server mounted as an ASGI app takes its port from the outer server that runs it. - The default server name is now
mcp-server. Pass a name if a client config refers to it. - Raising
MCPErrorin a tool now returns a JSON-RPC protocol error rather than a tool result withisErrorset. RaiseToolErrorfor failures the model should see and recover from. - Synchronous
defhandlers run on a worker thread, so code inside them that callsasyncio.get_running_loop()fails. - The HTTP client is
httpx2instead ofhttpx, and TLS verification uses the operating system's trust store. Servers behind a TLS-inspecting proxy may needSSL_CERT_FILEorSSL_CERT_DIR.
The standalone FastMCP project is a separate package (fastmcp on PyPI) with its own releases. The rename applies to the class that shipped inside the official mcp package.
A stateless protocol underneath
The 2026-07-28 changelog removes protocol-level sessions and the Mcp-Session-Id header from the Streamable HTTP transport, and drops the initialize handshake. Each request now carries its protocol version and client capabilities in _meta. Servers must implement a new server/discover request that advertises their versions, capabilities and identity, and clients can call it first or use it to probe an older server.
This matters most for teams that run MCP servers behind a load balancer. With no session ID, nothing ties a request to one replica, so the balancer can send each 2026-era request to any of them. The SDK's what's new page adds one condition: the default key that protects request state is per process, so a server with several replicas passes RequestStateSecurity(keys=[...]) with a shared key. Servers that need state across calls get it from handles the server mints and passes back as ordinary tool arguments.
The changelog also replaces the standalone GET stream and resources/subscribe with subscriptions/listen, removes ping and logging/setLevel, and moves the experimental tasks feature out of the core protocol into an extension. The Python SDK removed its experimental Tasks API in v2, along with the WebSocket transport and the old streamablehttp_client function (the replacement is streamable_http_client).
An upgraded server keeps working with older clients. One streamable_http_app() or stdio server answers both 2025-era and 2026-era clients without extra configuration, and the v2 Client falls back to initialize when a server doesn't answer server/discover. A team can upgrade servers and clients one at a time.
Server-initiated requests are gone
Under the 2026-07-28 revision a server can no longer send its own requests to the client in the middle of a tool call: no elicitation/create, no sampling/createMessage, no roots/list. Multi round-trip requests replace them. The tool returns an InputRequiredResult that lists what it needs, the client gathers the answers, and the client retries the original call with them.
In the Python SDK this shows up as NoBackChannelError. On a 2026 connection, ctx.elicit() and ctx.session.create_message() raise it; on a legacy connection they still work. The SDK's preferred replacement is Resolve: you annotate a tool parameter with Resolve(fn), and your function fills that parameter instead of the model. The function can return Elicit(...) to ask the user, and the SDK runs the extra round trip for you. A handler that needs full control can return an InputRequiredResult and handle the rounds itself. In our Building AI Agents with Python and MCP course, students build servers on the v2 SDK's MCPServer, add multi round-trip requests, and debug them with the MCP Inspector.
The spec also deprecates the Roots, Sampling and Logging features. They still work during the deprecation window, which the new feature lifecycle policy sets at a minimum of twelve months, but new servers shouldn't adopt them. The changelog suggests the replacements: pass directories or files as tool parameters or server configuration instead of Roots, call the model provider's API directly instead of Sampling, and log to stderr or OpenTelemetry instead of MCP logging. In v2 the SDK emits MCPDeprecationWarning when a server uses one of them.
Upgrading a team's servers
Start by pinning. The what's new page says v1.x is in maintenance, with critical fixes and security patches, and libraries that aren't ready should pin below 2. A requirements line that keeps a server on v1 while the team migrates:
mcp>=1.28,<2Then upgrade one server at a time with mcp>=2,<3. The migration guide also raises several dependency floors, Pydantic 2.12 among them, and adds opentelemetry-api as a required dependency, so check for conflicts with the rest of the service before changing code.
Run the test suite before you trust the upgrade, and expect some failures that aren't import errors. The SDK's in-memory Client(mcp) replaces v1's create_connected_server_and_client_session() helper, and it negotiates the 2026-07-28 revision by default. A test that exercises a tool calling ctx.elicit() can fail on v2 even though it passed on v1. Move the tool to Resolve, or set mode="legacy" for the tests that still need the old behavior. The low-level Server API changed the most: decorators such as @server.list_tools() became constructor arguments such as on_list_tools, handlers take (ctx, params) and return full result types, and input schemas are advertised but no longer enforced before the handler runs. A server built on the low-level API deserves a line-by-line review.
Client configuration in Claude Code, Cursor or a team's own agents needs no change for a server that only renamed its class. It does need a check if the server's name came from the old default, or if the server took its port from an MCP_ environment variable that v2 no longer reads. For agents that call these servers, the AI engineering training page lists the courses on LangGraph, the vendor agent SDKs and Amazon Bedrock AgentCore.