servers icon indicating copy to clipboard operation
servers copied to clipboard

No Module Error - Adding MCP server inside Claude Desktop

Open aayushrajj opened this issue 6 months ago • 8 comments
trafficstars

I am trying to add a MCP server in claude desktop. After properly installing required packages, still getting errors. Also, I have added a simple MCP server earlier in the claude desktop that is running properly.

Steps that I did for creating and adding the server to claude destop-

  • uv add "mcp[cli]" - To add mcp cli in the project folder
  • uv pip install -r requirements.txt - to install all the required packages
  • uv run mcp install main.py - to add the server inside claude desktop

I am seeing a successful installation message in the terminal, but when I open claude desktop it shows the server fails to run due to a missing module error in the error logs.

ERROR LOGS - 2025-05-19T13:44:08.019Z [TestServer] [info] Initializing server... 2025-05-19T13:44:08.050Z [TestServer] [info] Server started and connected successfully 2025-05-19T13:44:08.052Z [TestServer] [info] Message from client: {"method":"initialize","params":{"protocolVersion":"2024-11-05","capabilities":{},"clientInfo":{"name":"claude-ai","version":"0.1.0"}},"jsonrpc":"2.0","id":0} Failed to run server: No module named 'fitz' 2025-05-19T13:44:09.663Z [TestServer] [info] Server transport closed 2025-05-19T13:44:09.664Z [TestServer] [info] Client transport closed 2025-05-19T13:44:09.664Z [TestServer] [info] Server transport closed unexpectedly, this is likely due to the process exiting early. If you are developing this MCP server you can add output to stderr (i.e. console.error('...')in JavaScript,print('...', file=sys.stderr) in python) and it will appear in this log. 2025-05-19T13:44:09.664Z [TestServer] [error] Server disconnected. For troubleshooting guidance, please visit our [debugging documentation](https://modelcontextprotocol.io/docs/tools/debugging) {"context":"connection"} 2025-05-19T13:44:09.664Z [TestServer] [info] Client transport closed

Can anyone please help on what I might be doing wrong for this one?

aayushrajj avatar May 19 '25 15:05 aayushrajj

I got same error , anyone resolve this please help me

anwarjupiter avatar May 25 '25 16:05 anwarjupiter

No, still haven't found anything resolves this issue. Any server with no additional packages, are getting added onto Claude Desktop properly and working. But whenever I try to add a server with tools using some packages it gives error while adding it to Claude Desktop.

aayushrajj avatar May 27 '25 10:05 aayushrajj

same issue

nadhir-mb avatar May 27 '25 12:05 nadhir-mb

I have this same problem. I even tried running with uv run --directory /path/to/my/mcp.py fails.

Looks like the integration of Claude Desktop doesn't really work for python mcp servers that need a virtual environment setup with all the required installed packages.

hemna avatar May 30 '25 19:05 hemna

I'm also facing this issue.

dougdaley avatar Jun 01 '25 03:06 dougdaley

As a workaround, instead of

    "my-mcp": {
      "command": "/opt/homebrew/bin/uv",
      "args": [
        "run",
        "--with",
        "mcp[cli]",
        "mcp",
        "run",
        "/path/to/project/server.py"
      ],
    }

I use:

    "my-mcp": {
      "command": "/path/to/project/.venv/bin/mcp",
      "args": [
        "run",
        "/path/to/project/server.py"
      ],
    }

kriomant avatar Jun 01 '25 14:06 kriomant

unfortunately, that doesn't work for python scripts that are wrapped in click.

my python project generates an executable that needs a command and a config option on the commandline, such as

haminfo mcp-server -c /path/to/my/config.conf --loglevel DEBUG

Claude completely fails to do this correctly.

hemna avatar Jun 04 '25 19:06 hemna

I am also facing the same issue, the work around is not working either

nehapradeep avatar Jun 05 '25 05:06 nehapradeep

I ran into the same problem, I was able to address it by adding another "--with", "pyjwt" before the "run" so basically this: "my-mcp": { "command": "/opt/homebrew/bin/uv", "args": [ "run", "--with", "mcp[cli]", "--with", "pyjwt", "mcp", "run", "/path/to/project/server.py" ], }

kevinhorvatin-netwrix avatar Jun 13 '25 20:06 kevinhorvatin-netwrix

I ran into the same problem, I was able to address it by adding another "--with", "pyjwt" before the "run" so basically this: "my-mcp": { "command": "/opt/homebrew/bin/uv", "args": [ "run", "--with", "mcp[cli]", "--with", "pyjwt", "mcp", "run", "/path/to/project/server.py" ], }

This worked, but it defeats the whole purpose of having requirements.xt or pyproject.toml file. I am sure anthropic team will have a better solution to this,

kaustubhgupta avatar Jun 15 '25 16:06 kaustubhgupta

This can be done using the correct working directory as seen on https://modelcontextprotocol.io/quickstart/server

So this should be

"my-mcp": {
    "command": "/opt/homebrew/bin/uv",
    "args": [
        "run",
        "--directory",
        "/path/to/project",
        "run",
        "/path/to/project/server.py"
    ],
}

artoroz avatar Jul 30 '25 09:07 artoroz

This can be done using the correct working directory as seen on https://modelcontextprotocol.io/quickstart/server

So this should be

"my-mcp": {
    "command": "/opt/homebrew/bin/uv",
    "args": [
        "run",
        "--directory",
        "/path/to/project",
        "run",
        "/path/to/project/server.py"
    ],
}

Thank you!, For windows as well, this is working

kaustubhgupta avatar Aug 02 '25 07:08 kaustubhgupta

This can be done using the correct working directory as seen on https://modelcontextprotocol.io/quickstart/server

So this should be

"my-mcp": {
    "command": "/opt/homebrew/bin/uv",
    "args": [
        "run",
        "--directory",
        "/path/to/project",
        "run",
        "/path/to/project/server.py"
    ],
}

Can report this worked!

siphamm avatar Aug 20 '25 13:08 siphamm