Some links on this page are affiliate links: if you buy through them we may earn a commission, at no extra cost to you.
The most likely fix is to update the import for MCP Python SDK v2: replace from mcp.server.fastmcp import FastMCP with from mcp.server.mcpserver import MCPServer, then construct MCPServer("Demo"). SDK v2 removed the mcp.server.fastmcp module. If that does not resolve the error, verify that the package is installed in the same Python environment your editor or task runner uses.
What the error means
You may see this as an editor diagnostic such as "mcp.server.fastmcp" could not be resolved, or at runtime as ModuleNotFoundError: No module named 'mcp.server.fastmcp'. Those messages can have different immediate causes:
- SDK migration: MCP Python SDK v2 renamed
FastMCPtoMCPServerand moved the module. Code written for v1 therefore points at a module that v2 no longer provides. - Environment mismatch: the SDK may be installed, but not in the interpreter running your script, IDE, test, or task.
- Missing dependency: the package may not be installed in the active environment at all.
The title alone does not identify which environment or SDK version you have. Check the version before changing code or dependencies.
Recommended Free Tools
Fix the import when you are on SDK v2
The official MCP Python SDK migration guide documents this as a breaking change. In v2, use the new class and module:
#1 Best Overall
from mcp.server.mcpserver import MCPServer
mcp = MCPServer("Demo")
Do not change only the class name. Search the project for every import beginning with mcp.server.fastmcp and move those imports to the corresponding mcp.server.mcpserver path. A nested import left behind can produce the same error after the top-level line has been edited.
A minimal v2-shaped server
from mcp.server.mcpserver import MCPServer
mcp = MCPServer("Demo")
@mcp.tool()
def add(left: int, right: int) -> int:
"""Add two integers."""
return left + right
if __name__ == "__main__":
mcp.run()
The exact tool and transport details in your application may require additional migration work. The important part for this import failure is that both the module path and class name match the installed major version.
Choose deliberately between v1 compatibility and a v2 migration
There are two valid repair paths. Pick one based on the project’s constraints rather than mixing examples from different SDK generations.
| Path | Code change | When it fits | Trade-off |
|---|---|---|---|
| Keep existing v1 code | Retain from mcp.server.fastmcp import FastMCP and install a compatible v1 dependency in the environment that runs the application. |
You need an older tutorial or application working with minimal immediate edits. | You remain on the older major line and may later need a migration. |
| Migrate to v2 | Use from mcp.server.mcpserver import MCPServer; update imports below the moved module and address any other migration changes. |
You are starting a project or want to follow the stable v2 line described in the project documentation. | Older examples may require code changes beyond this single import. |
Do not install the newest package and expect old v1 imports to keep working. Conversely, do not downgrade a shared project casually: pin the major version in the project’s dependency configuration and make the choice visible to other developers and deployment systems.
Confirm the SDK version and Python interpreter
Run these checks in the same terminal, virtual environment, container, IDE task, or CI job that launches the failing program.
Rank #2
python -c "import sys, importlib.metadata as md; print(sys.executable); print(md.version('mcp'))"
python -m pip show mcp
The first command prints the interpreter path and installed distribution version. If your system uses a separate launcher, substitute python3. With uv, run the check through the project environment:
uv run python -c "import sys, importlib.metadata as md; print(sys.executable); print(md.version('mcp'))"
Compare the printed path with the interpreter selected by your editor. In VS Code, use Python: Select Interpreter from the Command Palette. In another IDE, select the project’s virtual environment rather than a system Python. An editor can report an unresolved import while a different terminal interpreter can import the package successfully, or the reverse.
The Tool Desk
Outbyte PC Repair FREERepair Windows errors before they cause bigger problemsFix Now →Outbyte Driver Updater FREEScan for outdated or missing drivers - takes under a minuteDriver Scan →Check which package Python is loading
python -c "import mcp, sys; print(sys.executable); print(mcp.__file__)"
This catches a shadowed or unexpected installation. If the command itself fails with No module named mcp, the SDK is absent from that interpreter. If it succeeds but your editor still underlines the import, the editor is almost certainly analyzing a different interpreter or has stale language-server state.
Install the SDK in the active environment
The project’s official installation guidance lists these commands:
uv add "mcp[cli]"
For a pip-managed project:
python -m pip install "mcp[cli]"
Using python -m pip ties pip to the interpreter named by python, which avoids a common pip-versus-python mismatch. The install command only installs the package; it does not translate v1 imports into v2 imports. After installation, repeat the version and path checks, then choose the matching code path.
Resolve editor-only “could not be resolved” warnings
If running the script works but the diagnostic remains, treat it as a language-server configuration problem rather than a package failure.
Free tools Windows power users keep installed
One-click scans. No signup required.
- Print
sys.executablefrom the terminal that works. - Select that exact interpreter in the editor.
- Reload or restart the Python language server.
- Open the project’s configured virtual environment and check that it contains the
mcpdistribution. - Run the editor’s own test or task command, not only an unrelated shell, to verify the same environment.
If the warning points specifically to mcp.server.fastmcp and your installed version is v2, changing the interpreter will not restore a removed module. Use the v2 import or intentionally install a compatible v1 dependency.
Common failures and targeted fixes
“No module named mcp”
Cause: the SDK is not installed in the interpreter executing the program. Fix: activate the project environment and run python -m pip install "mcp[cli]", or add it with uv add "mcp[cli]". Verify with python -m pip show mcp.
“No module named mcp.server.fastmcp” after a successful install
Cause: the installed SDK is v2, where that module was removed. Fix: migrate to from mcp.server.mcpserver import MCPServer and update any imports beneath mcp.server.fastmcp.
The v2 import also fails
Cause: you may actually have an older SDK, a partial or conflicting installation, or a different interpreter in use. Print the distribution version, sys.executable, and mcp.__file__. If the version is v1, either keep the v1 import with a deliberately pinned v1 dependency or upgrade the project and complete the v2 migration.
Only the IDE reports the error
Cause: the IDE’s selected interpreter differs from the one in your terminal or task runner. Fix: select the matching interpreter, reload the language server, and run the check from the IDE’s integrated terminal.
Changing the import reveals new errors
Cause: the import rename is part of a major-version migration, not necessarily the only change. Fix: use the migration guide to review related API and submodule changes, then update the project as a set. Avoid copying isolated lines from a v1 quickstart into a v2 application.
The tutorial and installed package disagree
The repository’s installation and quickstart material still shows a FastMCP-shaped example in places, while the project’s migration and release documentation describe v2’s MCPServer rename. Check the version first, then adapt the example instead of assuming the page and package are from the same API generation. The project’s release context is described in What’s New.
Verify the repair before deploying
- Run the version/path commands from the actual launch environment.
- Search the repository for
mcp.server.fastmcpso no stale nested import remains. - Import the selected class directly with a one-line check, for example
python -c "from mcp.server.mcpserver import MCPServer; print(MCPServer)"for v2. - Start the server using the project’s normal command rather than an unrelated global executable.
- Repeat the check in CI or the deployment image; local virtual-environment success does not prove that the deployed image contains the same major version.
For reproducible builds, keep the dependency declaration and lockfile under version control. A clean environment should install the same major line that your imports expect.
Or skip the browser setup
If your MCP project also needs website screenshots for tools, documentation, or automated checks, ScreenshotNeo provides a screenshot API and MCP server without requiring you to maintain a browser automation stack. One GET request returns a PNG, JPEG, WebP, or PDF.
Best Value
cURL:
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
Python (see the ScreenshotNeo documentation):
import requests
r = requests.get("https://api.screenshotneo.com/v1/shot", params={"access_key": "YOUR_API_KEY", "url": "https://stripe.com"}, timeout=90)
open("shot.webp", "wb").write(r.content)
Node.js:
const q = new URLSearchParams({ access_key: 'YOUR_API_KEY', url: 'https://stripe.com' });
const res = await fetch(`https://api.screenshotneo.com/v1/shot?${q}`);
- Cookie and consent banners, newsletter popups, and chat widgets are accepted or removed before the shot.
- Bot checks or CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed; response headers identify the page verdict and billing status.
- An MCP server exposes
take_screenshot,get_page_info, andcapture_pdfto Claude, Cursor, and other MCP clients. - The Free plan includes 1,000 screenshots each month with no card; paid plans start at $5 for 3,000 screenshots. Every feature is available on every plan.
Create a free ScreenshotNeo account to start with the 1,000-shot monthly allowance.
Frequently asked questions
Is this error caused by Python 3 itself?
Not necessarily. The documented breaking change is in the MCP SDK’s module and class names. Python version compatibility and environment configuration still need checking, but the title alone does not establish either as the cause.
Can v1 and v2 imports be used in one project?
They target different SDK layouts. Mixing them usually leaves unresolved imports or incompatible APIs. Choose one major-version path and update the project consistently.
Should I always downgrade to v1?
No. Keeping v1 can be a temporary compatibility choice for existing code; migrating to v2 follows the SDK’s documented stable-line direction. The right choice depends on your project’s other dependencies and migration effort.
Why does reinstalling not fix the old import?
Reinstalling the current package does not recreate a module that v2 intentionally removed. Reinstallation helps only when the package is missing or installed in the wrong environment; otherwise, change the import or deliberately use a compatible v1 dependency.
Frequently Asked Questions
What command shows which Python is running my MCP server?
Run python -c "import sys; print(sys.executable)" in the same environment that launches the server.
What should I search for after changing to MCPServer?
Search the entire project for mcp.server.fastmcp, including nested imports, configuration files, and examples copied into modules.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
Where are the official migration details?
The MCP Python SDK migration guide is available at github.com/modelcontextprotocol/python-sdk/blob/main/docs/migration.md.
Quick Recap
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

