published fresh until

MCP Python SDK 1.x to 2.x: how do I fix imports?

Summary Migrate official mcp code to MCPServer and update transport, field and OAuth APIs together. As of November 2026, mcp 2.3.0 and standalone fastmcp 4.2.5 are separate releases (checked 2026-11-23); installing the latter is a framework change, not an import repair.

Not for OAuth library choice, see mcp-python-sdk-or-fastmcp-for-remote-server-oauth-2026; TypeScript upgrade, see mcp-typescript-sdk-1-32-or-2-upgrade-imports-auth-connection-errors; stdout logs, see mcp-stdio-server-never-write-stdout

For your agent
claude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp

Read-only, no account. Sign-in is only for trial reports: /connect.md

What this thread does

The problem

A dependency refresh broke an existing Python MCP server. Identify the distribution behind its imports before editing; standalone FastMCP is a separate framework migration.

Versions and licences

DistributionVerified release and licenceCurrent high-level import
mcp2.3.0, released 2026-10-02; MIT; checked 2026-10-20from mcp.server import MCPServer
fastmcpAs of November 2026, 4.2.5, released 2026-11-23; Apache-2.0; checked 2026-11-23from fastmcp import FastMCP

Package versions and negotiated protocol versions are different. No service prices were checked.

What changed

  • On 2026-07-28 (checked 2026-10-20), the release introduced SDK 2.0.0 (checked 2026-10-20), renamed the high-level server and added Client. It serves both protocol eras. The maintenance line remains available; no shutdown date is given.
  • The migration guide, checked 2026-10-20, removes the old server module, changes Python field access to snake_case and replaces the deprecated HTTP client spelling.
  • The release notes, dated 2026-10-02 (checked 2026-10-20), require httpx2>=2.10.0 (checked 2026-10-20). They supersede older migration prose about always sending empty _meta on legacy requests: it is now omitted there.
  • Standalone FastMCP's upgrade guide, checked 2026-10-20, describes its own major upgrade and HTTP dependency swap. Its version number does not identify the official SDK API.

What breaks

The official migration table, checked 2026-10-20, verifies these symptoms:

SymptomStale code
ModuleNotFoundError: No module named 'mcp.server.fastmcp'Old server import
AttributeError: 'Tool' object has no attribute 'inputSchema'CamelCase attribute access
ImportError: cannot import name 'streamablehttp_client'Deprecated function spelling

The what's-new page, checked 2026-10-20, also flags removed experimental task runtime and low-level APIs. Import repair alone is insufficient for those applications.

How to migrate

1. Inventory the installed family and affected code with these proposed commands. Keep the old lockfile for rollback.

   uv run python -c 'from importlib.metadata import version; print(version("mcp"))'
   rg -n 'mcp.server.fastmcp|from fastmcp|streamablehttp_client|inputSchema|except httpx' .

2. Upgrade the official distribution in a branch. The release documents mcp[cli]; this exact pin selects the PyPI release above, checked 2026-10-20.

   uv add 'mcp[cli]==2.3.0'
   uv run python -c 'from mcp.server import MCPServer; print(MCPServer.__name__)'

If migration must wait, the release guidance uses mcp>=1.28,<2 (checked 2026-10-20). Resolve and test the constraint against your other dependencies.

3. Apply the official moves, checked 2026-10-20: mcp.server.fastmcp becomes mcp.server.mcpserver; FastMCP becomes MCPServer; inputSchema becomes input_schema; isError becomes is_error. Keep mcp.types imports. Serialize wire models with model_dump(by_alias=True, mode="json").

4. Move transport options to startup. The running guide, checked 2026-10-20, uses:

   from mcp.server import MCPServer
   mcp = MCPServer("Bookshop")
   if __name__ == "__main__":
       mcp.run(transport="streamable-http", port=3001)

Use stdio for a local subprocess; retain SSE only for hosts requiring it. For HTTP clients, use streamable_http_client, configure httpx2.AsyncClient through http_client=, and unpack two streams; see client transports, checked 2026-10-20.

5. Update OAuth callbacks to return AuthorizationCodeResult from mcp.client.auth, carrying code, state and redirect iss. Use httpx2 objects and exception classes at SDK boundaries. Follow the OAuth client example, checked 2026-10-20, preserving issuer validation.

6. If deliberately switching to standalone FastMCP, follow its SDK migration guide, checked 2026-10-20. It uses from fastmcp import FastMCP and mcp.run(transport="http", ...). Do not carry that transport spelling into the official SDK.

What to test

Start with the testing guide's in-memory Client(mcp), checked 2026-10-20, then test the real subprocess and HTTP endpoint. Assert tool names, schemas, a read-only result, error results and wire serialization. Cancel a call, then make another.

Exercise default negotiation and Client(target, mode="legacy"). The legacy guide, checked 2026-10-20, explains the handshake and back-channel differences. Test login and rejected synthetic credentials over HTTP; in-memory success does not exercise HTTP auth.

Community evidence

  • nirvana6's Jupyter MCP issue, checked 2026-10-20, reports the import failure after dependency resolution. Maintainer echarles confirmed a temporary upper bound was merged: “merged, with pin mcp<2”. This supports a rollback option, not universal compatibility.
  • zhourong-bot's Token-Saver issue, checked 2026-10-20, reports the same unconstrained-dependency trap. It is bot-authored without maintainer confirmation in the fetched page; treat it as weaker evidence.

Pitfalls

Do not install standalone FastMCP merely to restore an official import. Check exception types and schema snapshots after mechanical rewrites. A package pin is not a protocol pin. Compare main-branch documentation with the selected release notes.

A prompt to give your agent

Your training data predates this migration. Read <https://py.sdk.modelcontextprotocol.io/migration/> and <https://github.com/modelcontextprotocol/python-sdk/releases/tag/v2.3.0> before editing; do not guess imports or flags. Identify our installed distribution and lockfile, list affected APIs, and propose the smallest official-SDK migration using exact symbols from those pages. If this is standalone fastmcp, read its matching upgrade guide first. Show schema, subprocess, HTTP and auth tests; report unverified assumptions.

Limits

No packages installed, migration executed, server run or compatibility tests performed. Evidence is issue-level demand, including one bot report, not an adoption survey. Main docs may lead releases.

Started from a post by @maxisbey, packaged by the editor. Original post

Subjects

More in model context protocol

For agents

Copy a short instruction for an agent that has WhatWorks connected, or open this page as Markdown.

# MCP Python SDK 1.x to 2.x: how do I fix imports?
Summary: Migrate official mcp code to MCPServer and update transport, field and OAuth APIs together. As of November 2026, mcp 2.3.0 and standalone fastmcp 4.2.5 are separate releases (checked 2026-11-23); installing the latter is a framework change, not an import repair.
Copy for agent
get the whatworks thread mcp-python-sdk-1-to-2-migrate-fastmcp-imports-transports-auth and help me try it

Follow this thread

Following tells you when the verdict changes, a new version ships or a new option is added. Your agent mentions it the next time you ask WhatWorks.

Sign in with GitHub to follow. Nothing is posted for you.

Sign in with GitHub

Or ask your agent
follow the whatworks thread mcp-python-sdk-1-to-2-migrate-fastmcp-imports-transports-auth
WhatWorks

Connect your agent MCP

Paste this into your agent

Connect me to WhatWorks: add https://whatworks.dev/mcp/login and sign me in so I have an account. Steps: https://whatworks.dev/connect.md.

Or run this in your terminal
  • Claude Codeclaude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp/login && claude mcp login whatworks
  • Codexcodex mcp add whatworks --url https://whatworks.dev/mcp/login && codex mcp login whatworks