The import fails because the interpreter that launches your server has mcp 2.x, released on PyPI on July 28, 2026, where FastMCP became MCPServer under mcp.server.mcpserver; on mcp older than 1.2.0 the same message means FastMCP had not shipped yet. Releases 2.0.0 and 2.1.0 give the bare Python message, while 2.0.1, 2.1.1, 2.2.0 and 2.3.0 ship a stub module that names the rename and suggests pinning mcp<2. To keep v1 code, pin mcp>=1.30,<2, not >=1.2 or ==1.29.0: five advisories published between September 28 and October 5 are fixed only in 1.30.0 on the 1.x line, and a sixth arrived in 1.29.1. To port, change the import, pass the name and every other constructor argument by keyword, and move host, port, json_response and stateless_http to run(). For a third-party server launched with uvx, constrain mcp in the environment uvx builds instead of editing its code. Installing the standalone fastmcp package never restores mcp.server.fastmcp, and fastmcp 4.x requires mcp 2. Start by printing importlib.metadata.version('mcp') from the exact interpreter your MCP host runs.
ModuleNotFoundError: No module named 'mcp.server.fastmcp' means the Python interpreter that starts your MCP server has a release of the mcp package with no FastMCP at that import path. On a fresh install without an upper bound, that release is mcp 2.x: 2.0.0 reached PyPI on July 28, 2026, and it renamed FastMCP to MCPServer and moved it to mcp.server.mcpserver. Change the import to from mcp.server.mcpserver import MCPServer and work through the other v2 changes, or pin mcp>=1.30,<2 to keep v1 code running unchanged. On mcp older than 1.2.0 the same message means FastMCP had not shipped yet, and the fix is to upgrade.
The break arrived without a code change on the reader's side. Any requirement written as mcp>=1.x with no upper bound resolved to 2.x on every fresh install from that day. An issue on the AWS Labs MCP servers repository, opened the same day, listed 19 servers whose mcp[cli] requirement (for example mcp[cli]>=1.23.0) had no ceiling, and hundreds of issues carrying this exact error string have since been opened across third-party server repositories.
What follows is read from the MCP Python SDK source at tags v2.3.0 and v1.30.0 (2.3.0, uploaded October 2, 2026, is the latest release on PyPI; 1.30.0 is the latest 1.x), the SDK's v2 migration guide at v2.3.0, PyPI metadata, the repository's security advisories, and uv at 0.13.10.
No module named 'mcp.server.fastmcp': check the interpreter the host launches
Before touching code, find out which mcp the failing process imports. Not your shell's python, not the venv your editor selected: the exact interpreter in the MCP host's server config, or the environment uvx builds for it.
# the venv your MCP host launches (use its absolute path, not your shell's python)
/opt/mcp/records/.venv/bin/python -c "import importlib.metadata as m; print(m.version('mcp'))"
# a server the host launches with uvx
uvx --from <server-package> python -c "import importlib.metadata as m; print(m.version('mcp'))"importlib.metadata.version is in the standard library, and the SDK requires Python 3.10 or newer on both majors, so the check works in any environment that can run the server. The version it prints tells you which cause you have and what message to expect:
The stub is src/mcp/server/fastmcp.py, a module with no API that defines the message and then runs raise ModuleNotFoundError(_MESSAGE, name=__name__). It was added to main in PR #3388, merged August 25, 2026 and first released in 2.1.1, then backported to the 2.0.x branch in PR #3393 and released in 2.0.1. The 2.0.1 release notes say the backport exists because many people hit this error and opened issues on other repositories about it. On those four releases the traceback ends with this:
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.
Any import below the old path fails the same way, because Python imports the parent first: from mcp.server.fastmcp.prompts import base raises the identical message. No environment variable, setting or timeout changes this. If you see No module named 'mcp.server'; 'mcp' is not a package instead, that is a different problem: a local file named mcp.py next to your server is shadowing the installed package.
| mcp version found | Cause | What the import raises |
|---|---|---|
| Below 1.2.0 | FastMCP first shipped in 1.2.0 (January 3, 2025); absent at v1.1.3 | The bare Python message |
| 1.2.0 to 1.30.0 | Not this cause: the module exists on 1.x | Nothing; you are checking the wrong interpreter |
| 2.0.0, 2.1.0 | Renamed to MCPServer, no stub module | The bare Python message |
| 2.0.1, 2.1.1, 2.2.0, 2.3.0 | Renamed, stub module present | A long message naming MCPServer and suggesting mcp<2 |
Fix A: pin mcp>=1.30,<2 to keep v1 code running
If the server is yours and porting has to wait, bound the dependency. The SDK's own migration guide opens with this advice: the v1.x maintenance line "keeps receiving critical bug fixes and security patches", and a package that depends on mcp should keep a <2 upper bound until it has migrated.
# requirements.in, or an entry in the dependencies list of pyproject.toml mcp>=1.30,<2
The floor is the part that gets skipped. A bare mcp<2 is satisfied by whatever old version an existing lock or cache already holds, and one workaround posted on public issue threads, the AWS Labs one included, was mcp==1.29.0. That release predates six advisories in the SDK's repository:
All six were published between September 28 and October 5, 2026, and on the 1.x line five of them are fixed only in 1.30.0. That is why the pin is >=1.30, not >=1.2 or >=1.10.1.
1.30.0 also changes behaviour you will notice on Streamable HTTP servers. Idle stateful sessions now expire after 30 minutes, a server holds at most 10,000 sessions and returns 503 beyond that, the HTTP client follows redirects only within the same origin, and the OAuth client checks the authorization server's issuer. If a long-lived internal client depends on sessions surviving overnight, pass session_idle_timeout=None or max_sessions=None to the FastMCP constructor (both are constructor keywords at v1.30.0), knowing that turning them off reopens the first advisory in the table.
One v1 path bypasses your pin. mcp dev and mcp install on 1.x run the server through a fresh uv run --with ... environment whose mcp requirement was unpinned, so it resolves to the newest stable release: a 1.30.0 install can spawn a 2.x environment and fail with this error. v2 pins that spawned environment to the installed version. On 1.x, start the server with your venv's interpreter directly.
| Advisory | Severity | Problem | Fixed in (1.x / 2.x) |
|---|---|---|---|
| GHSA-84m7-p3x7-pcfv (CVE-2026-59951) | High | Streamable HTTP sessions never reclaimed by default | 1.30.0 / 2.2.0 |
| GHSA-qx49-fqc8-xw99 (CVE-2026-115563) | High | OAuth client could send credentials to an authorization server chosen by the MCP server | 1.30.0 / 2.2.0 |
| GHSA-fmmv-w9g8-j3gc (CVE-2026-109527) | High | HTTP transports and OAuth endpoints read request bodies with no size limit | 1.29.1 / 2.1.0 |
| GHSA-rwrf-2pqf-9j8j (CVE-2026-116686) | Medium | Client fetched server-chosen $ref URLs while validating tool output | 1.30.0 / 2.2.0 |
| GHSA-5h93-6whr-6q8j (CVE-2026-116685) | Medium | HTTP client followed cross-origin redirects with custom headers and bodies | 1.30.0 / 2.2.0 |
| GHSA-w4fh-qvv9-3v23 (CVE-2026-116684) | Medium | Server accepted bearer tokens issued for a different resource server | 1.30.0 / 2.2.0 |
Fix B: from mcp.server.fastmcp import FastMCP becomes MCPServer
Porting is mostly mechanical for a decorator-based server, and three changes are silent. For the server-building basics themselves, the walkthrough in our MCP developer guide for building Python servers still uses the v1 import; on 2.x apply the mapping below to it.
# v1 (mcp<2)
from mcp.server.fastmcp import FastMCP, Context
mcp = FastMCP("records", json_response=True, stateless_http=True)
mcp.run(transport="streamable-http")
# v2 (mcp>=2.2)
from mcp.server.mcpserver import MCPServer, Context
mcp = MCPServer("records", instructions="Look up case records by id.")
mcp.run(transport="streamable-http", host="127.0.0.1", port=8000,
json_response=True, stateless_http=True)On v1, host, port, json_response and stateless_http were constructor keywords and run() accepted only transport and mount_path. On v2, the streamable-http overload of run() takes them as keyword-only arguments, and the constructor rejects them with TypeError: MCPServer.__init__() got an unexpected keyword argument 'port'. Assigning mcp.settings.port instead raises a ValueError saying the Settings object has no field "port".
What carries over unchanged: @mcp.tool(), @mcp.resource(), @mcp.prompt() and @mcp.completion() take the same arguments and handler signatures, tool return values are wrapped by the same rules, and TransportSecuritySettings still lives in mcp.server.transport_security. Image and Audio import from mcp.server.mcpserver, and ToolError and ResourceError from its exceptions module.
try:
from mcp.server.mcpserver import MCPServer as Server, Context
except ModuleNotFoundError:
from mcp.server.fastmcp import FastMCP as Server, Context
mcp = Server("records")
@mcp.tool()
def get_record(record_id: str) -> dict:
return {"id": record_id}
if __name__ == "__main__":
mcp.run() # stdio: no transport keywords, so both signatures agreeThe three changes that do not raise
The default name. A server constructed without a name now reports mcp-server instead of FastMCP as serverInfo.name (line 213 of mcpserver/server.py at v2.3.0 reads name=name or "mcp-server"). Any allowlist, dashboard or audit rule keyed on the reported name changes with it. Pass the name explicitly. The positional order. v1's constructor was name, instructions, website_url, icons, .... v2's is name, title, description, instructions, website_url, icons, version. A v1 call written as FastMCP("records", "Look up case records by id."), with only the class name changed, puts the instructions in title and stops sending instructions at all. Pass everything after the name by keyword. The version. A server that never set one used to report the mcp package version; v2 reports an empty string. Set version= if anything downstream reads it.
Settings that never worked, and a dependency that left
v1's Settings class read FASTMCP_-prefixed environment variables and a .env file (its docstring example is FASTMCP_DEBUG=true), but the v1 constructor passed every field explicitly, so those values never took effect. v2 reads no environment variables for settings at all. If a deployment manifest sets FASTMCP_PORT or FASTMCP_HOST, it was already being ignored: move the values into run(). Settings is now a plain Pydantic model, and pydantic-settings is no longer an SDK dependency, so application code that imported it transitively must declare it. Binding changes too. DNS rebinding protection switches on automatically when the host is 127.0.0.1, localhost or ::1 and no transport_security is passed, and in v2 that check moved from the constructor into sse_app() and streamable_http_app(), which default to host="127.0.0.1", so a mounted app has protection on until you configure it. To serve it under a real hostname, for example behind a reverse proxy, pass transport_security=TransportSecuritySettings(allowed_hosts=[...], allowed_origins=[...]), or requests whose Host header is not on the allowlist come back 421 Invalid Host header.
Running on both majors during a staged rollout
If one codebase has to deploy against hosts still pinned to 1.x and hosts already on 2.x, the guide's note that importing the old path raises ModuleNotFoundError makes a fallback import safe. This only holds for name-only construction and a stdio run(), because the transport keywords live in different places on the two majors, and ctx.fastmcp versus ctx.mcp_server differs too.
| v1 (mcp 1.30.0) | v2 (mcp 2.3.0) |
|---|---|
from mcp.server.fastmcp import FastMCP | from mcp.server.mcpserver import MCPServer |
mcp.server.fastmcp.* submodules | mcp.server.mcpserver.*, same structure |
ctx.fastmcp | ctx.mcp_server |
FastMCPError | MCPServerError in mcp.server.mcpserver.exceptions |
from mcp import McpError | MCPError, constructed as MCPError(code, message, data) |
FastMCP[MyState] with lifespan= | MCPServer[MyState], same lifespan= |
host, port, json_response, stateless_http, path and session keywords on the constructor | Keywords on run(), sse_app() or streamable_http_app() |
mount_path | Removed |
MCP Python SDK v2: the errors you hit after the import works
The migration guide's "Changes almost every project hits" table lists the first symptom of each change. Once the FastMCP import is fixed, these are the next tracebacks a FastMCP-based server is likely to hit, a subset of that table in the guide's order:
Two removals give their own bare "No module named" errors with no stub to explain them: mcp.shared.session and the WebSocket transport (mcp.client.websocket, mcp.server.websocket, and the mcp[ws] extra). mcp.types survives as a permanent alias of the new mcp-types distribution.
The dependency set changed underneath all of this. mcp 2.3.0 drops httpx, httpx-sse and pydantic-settings, and adds httpx2>=2.10.0, mcp-types==2.3.0 and opentelemetry-api>=1.28.0, with pydantic>=2.12.0. mcp 1.30.0 still requires httpx<1.0.0,>=0.27.1, httpx-sse>=0.4 and pydantic-settings>=2.5.2. Anything in your environment that leaned on those transitively breaks at import on 2.x, even when the SDK calls themselves are fine.
| First symptom | Change | Fix |
|---|---|---|
AttributeError: 'Tool' object has no attribute 'inputSchema' | Fields renamed from camelCase to snake_case | input_schema, and so on for every field |
ImportError: cannot import name 'Content' from 'mcp.types' | Type aliases removed from mcp.types | Use the concrete content types the guide lists |
ImportError: cannot import name 'McpError' from 'mcp' | Renamed | MCPError(code, message, data) |
AttributeError: 'str' object has no attribute 'host' | Resource URIs are str, not AnyUrl | Parse the string where you need parts |
ImportError: cannot import name 'streamablehttp_client' | Client helper removed | Follow the guide's client transport section |
ModuleNotFoundError: No module named 'httpx' or TypeError: Invalid "auth" argument | httpx and httpx-sse replaced by httpx2 | Import httpx2; declare httpx yourself if your code uses it |
TypeError: MCPServer.__init__() got an unexpected keyword argument 'port' | Transport parameters moved | Pass them to run() |
RuntimeError from asyncio.get_running_loop() in a def handler | Sync handlers run on a worker thread | Make the handler async def |
Fix C: constrain mcp<2 for a uvx MCP server you cannot edit
This is the situation the stub was added for. Your MCP host config runs a published server with uvx, the server declares mcp>=1.something without an upper bound, and uvx resolves a fresh environment that now contains mcp 2.x. Nothing in your repository changed. In an MCP host the import crash may never reach you as a traceback: one public report notes that when the server dies this way, before the initialize handshake, Claude Code shows error -32000. If that is what your host shows, the triage steps in what MCP error -32000 Connection closed means will lead you back to the server's stderr, and this traceback.
You fix it in the environment, not the code. Public reports on affected servers used --with to add a bounded mcp requirement to the tool's environment; uv's --constraints flag (alias --constraint, equivalent to pip's --constraint) says the same thing explicitly and can be shared:
# one-off, as the public reports did uvx --with "mcp>=1.30,<2" <server-command> # explicit constraint file, reusable across servers printf 'mcp>=1.30,<2\n' > /etc/mcp/constraints.txt uvx --constraints /etc/mcp/constraints.txt <server-command>
uv 0.13.10 also reads the constraints path from the UV_CONSTRAINT environment variable, which you can set once in the host's server entries instead of editing every command. --with installs the bounded requirement into the tool's environment; a constraints file is the form to standardise on because one reviewed file covers every server, and a package listed in it is never installed unless something already requires it. --overrides is a different instrument: it replaces the tool's own requirements outright, and it is the wrong default when you want the resolver to tell you about a conflict.
A constraint fails loudly when the server moves on. If a later release of that server ports to v2 and requires mcp>=2, resolution under mcp<2 fails at launch, which is the signal to bump the server and drop the constraint in the same change. The other route is to move to a server release that bounds or ports mcp itself; check its declared requirement on PyPI before relying on it.
If you publish a server or library, add the <2 bound now, even before you plan a port. The SDK guide's advice is aimed at you: every consumer of an unbounded mcp requirement inherits the break the next time anything resolves fresh.
mcp.server.fastmcp vs fastmcp: the standalone package is not the fix
Installing the standalone fastmcp package looks like a fix from the name alone. It is not one. The standalone fastmcp project is a different distribution, imported as from fastmcp import FastMCP, and installing it never creates mcp.server.fastmcp. Worse, its current major pulls in the very version that caused the error:
From 3.3.0 on, the bound sits in fastmcp-slim, which the fastmcp wheel pins to its own version. The consequence for a requirements file: an unbounded fastmcp next to mcp>=1.30,<2 resolves to fastmcp 3.4.11 or older, and anything that also requires fastmcp>=4 makes the set unsolvable. Porting an application from fastmcp to the official SDK, or the reverse, is a separate decision; here the only point is that the package does not restore the v1 import path.
| fastmcp release | PyPI date | Requirement on mcp |
|---|---|---|
| 2.14.0 | December 11, 2025 | mcp>=1.23.1, no upper bound |
| 3.0.0 to 3.4.11 (last 3.x) | February 18 to October 20, 2026 | mcp>=1.24.0,<2.0 |
| 4.0.0 | August 31, 2026 | mcp>=2.0.0,<3.0.0 |
| 4.2.5, 4.2.6 | November 23 and 25, 2026 | mcp>=2.3.0,<3.0.0 |
On-prem: pin mcp with hashes from a private PyPI mirror
Inside a regulated perimeter, Python MCP servers install from a mirrored PyPI rather than the public index, and the ones launched with uvx resolve whatever requirements each server declares. That arrangement turns a single upstream release into a coordinated outage: the day the mirror syncs mcp 2.x, every server with an unbounded requirement crashes at import on its next fresh resolve, and the host shows a connection error with no traceback in sight. The same mechanics reach every MCP server your local coding agents launch on developer workstations and to tooling you pre-stage for air-gapped installs from a mirror.
The fix is to make version changes a change you approve, not one the mirror makes for you.
Your own servers get a hash-pinned lock. Compile the bounded requirement into exact versions with hashes, and install with hash checking enforced, so a mirror sync cannot cross a major version and a tampered artifact cannot install:
uv pip compile requirements.in --generate-hashes -o requirements.txt pip install --require-hashes -r requirements.txt
Here requirements.in holds mcp>=1.30,<2 until the port lands, then mcp>=2.2,<3. Both bounds sit above the advisory fixes in the table earlier.
Third-party servers share one constraints file. Keep a single constraints.txt under change control, pass it to every uvx-launched server with --constraints or UV_CONSTRAINT, and bump it in one reviewed change when you move the estate to 2.x. Which servers and versions agents may reach at all is a governance question an MCP gateway in front of agent tool access can enforce centrally.
Check TLS before you port anything that calls out. In 2.x the SDK's HTTP client moved from httpx to httpx2, and the trust model moved with it: httpx validated against certifi's bundled CA list, httpx2 validates against the operating system trust store via truststore. Behind an internal CA that works without configuration when the CA is installed in the container image's system store. Where it is not, set SSL_CERT_FILE or SSL_CERT_DIR, which httpx2 honours first, or build an ssl.SSLContext; passing a CA bundle path as verify="ca.pem" is deprecated in httpx2. A minimal image with no usable system store fails here even after every import is fixed.
Planning the 2.x port for a fleet of internal servers, with serverInfo names, transport bindings and TLS checked per server, is the kind of work our on-premise AI development team takes on inside client infrastructure.
This week, run the version check from the first code block against every server each MCP host in your estate launches, and write down which ones print 2.x and which resolve unbounded. Then add mcp>=1.30,<2 to one shared constraints file and point every uvx entry at it. That stops the next mirror sync from breaking anything while you schedule the ports one server at a time. More on running developer tooling inside your own perimeter is in the AI development tools hub.
FAQ
Quick answers to the questions this post tends to raise.



