Skip to content

ModuleNotFoundError: No module named 'mcp'

Spec
2026-07-28
Evidence
E2Reproducedarm64
Python SDK
mcp@2.3.0
Verified

The server’s first import failed:

ModuleNotFoundError: No module named 'mcp'

We got this by running import mcp with the system python3, while the SDK was installed only in the project’s virtual environment. The process exits right away, so the client usually shows Connection closed, and this line is in the server’s log.

If the message names a submodule, such as mcp.server.fastmcp, the SDK is installed but its version does not match your code: see No module named ‘mcp.server.fastmcp’.

"command": "python" means whichever python is first on the client’s PATH. That is rarely your project’s virtual environment. Use one of these instead:

  • uv (recommended): let uv pick the project’s environment.

    { "command": "uv", "args": ["run", "--directory", "/absolute/path/to/project", "python", "server.py"] }
  • The virtual environment’s interpreter, by full path: /absolute/path/to/project/.venv/bin/python on macOS and Linux, C:\path\to\project\.venv\Scripts\python.exe on Windows.

If uv itself cannot be found, the client reports spawn uv ENOENT; use the full path of uv too.

In the project directory:

Terminal window
uv add mcp # or: pip install mcp

Then run the exact command from the client config in a terminal. It should start and wait silently.

MCPDev is community documentation. It is not affiliated with the Model Context Protocol project or with the vendors of the clients it covers.