Skip to content

Claude throwing an error "Server disconnected" #402

@ANewProfile

Description

@ANewProfile

Describe the bug
So I was interested in learning to make MCPs, and I started with a simple python file called "FastMCP-Intro.py":

from fastmcp import FastMCP

mcp = FastMCP("LearningDemo")


@mcp.tool()
def add(a: int, b: int):
    """Add two numbers"""
    return a + b

After running fastmcp install FastMCP-Intro.py in the correct working directory, my terminal says: Added server 'LearningDemo' to Claude config and Successfully installed LearningDemo in Claude app, indicating that the installation was successful. Looking at Claude's config file, it does contain:

"LearningDemo": {
      "command": "uv",
      "args": [
        "run",
        "--with",
        "fastmcp",
        "fastmcp",
        "run",
        "/Users/path/to/correct/directory/FastMCP-Intro.py"
      ]
}

However, after launching the Claude desktop app, the Settings say that there was an Error, with the message "Server disconnected". I also tried with the config:

"RealDemo": {
      "command": "npx",
      "args": [
        "-y",
        "@modelcontextprotocol/server-filesystem",
        "/Users/path/to/correct/directory/FastMCP-Intro.py"
      ]
}

but this returned the same error.

However, public MCPs that I was previously using still worked, connecting like normal.

When I ran fastmcp dev FastMCP-Intro.py and accessed the MCP Inspector from my browser, the MCP worked fine. I was able to use the "add" tool to add two numbers, with no troubles. On the sidebar, there were three errors:
[03/29/25 13:47:39] INFO Processing request of type server.py:534 ListResourcesRequest,
[03/29/25 13:47:48] INFO Processing request of type server.py:534 ListToolsRequest, and
[03/29/25 13:48:02] INFO Processing request of type server.py:534 CallToolRequest, but the MCP tool still worked perfectly fine in the Inspector.

Realizing that the jlowin/fastmcp directory was no longer maintained, I turned to here with the code

from mcp.server.fastmcp import FastMCP

mcp = FastMCP("LearningDemo")


@mcp.tool()
def add(a: int, b: int):
    """Add two numbers"""
    return a + b

with the implementation

"LearningDemo": {
      "command": "uv",
      "args": [
        "run",
        "--with",
        "mcp[cli]",
        "mcp",
        "run",
        "/Users/path/to/correct/directory/FastMCP-Intro.py"
      ]
}

, but that returns the same error. I tried running uv run --with mcp[cli] mcp run /Users/path/to/correct/directory/FastMCP-Intro.py in my terminal, but it returned with an error and said: zsh: no matches found: mcp[cli].

Running uv run --with mcp mcp run /Users/path/to/correct/directory/FastMCP-Intro.py or uv run --with fastmcp fastmcp run /Users/path/to/correct/directory/FastMCP-Intro.py both don't return with an error, but nothing showed in the terminal and I ended up CTRL+C'ing out of it.

Expected behavior
Claude can recognize the demo MCP tool and use it to add numbers

Screenshots
Image

Desktop:

  • OS: MacOS Sequoia 15.3.2
  • Browser: Claude Desktop
  • MCP: latest

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions