Skip to content

Claude Desktop invokes MCP server docker image twice on startup #812

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
tianzhou opened this issue Mar 12, 2025 · 8 comments
Closed

Claude Desktop invokes MCP server docker image twice on startup #812

tianzhou opened this issue Mar 12, 2025 · 8 comments
Labels
bug Something isn't working

Comments

@tianzhou
Copy link
Contributor

tianzhou commented Mar 12, 2025

claude_desktop_config.json

{
  "mcpServers": {
    "dbhub": {
      "command": "docker",
      "args": [
        "run",
        "-i",
        "--rm",
        "bytebase/dbhub",
        "--transport",
        "stdio",
        "--dsn",
        "postgresql://postgres:postgres@host.docker.internal:5432/postgres?sslmode=disable"
      ]
    }
  }
}

When Claude Desktop starts, it starts the docker image twice:

CONTAINER ID   IMAGE            COMMAND                  CREATED              STATUS              PORTS                                       NAMES
460f37945bcc   bytebase/dbhub   "node dist/index.js …"   About a minute ago   Up About a minute   8080/tcp                                    charming_brown
1426b40ffdb6   bytebase/dbhub   "node dist/index.js …"   About a minute ago   Up About a minute   8080/tcp                                    goofy_chaplygin
271a297fe72a   postgres:15      "docker-entrypoint.s…"   26 hours ago         Up 26 hours         0.0.0.0:5432->5432/tcp, :::5432->5432/tcp   Stackbricks-PG-15-Local-Test-7960b0

This means if I specify the --name dbhub in docker run, the 2nd invocation will fail due to image name conflict.

I know it may not be the best place to report this bug as it seems to be a Claude Desktop bug. But it's on the CUJ when building the MCP server. I did file the bug via the Claude Desktop support link. But the format doesn't allow me to provide detailed info. So I submit here as well.

The repo: https://github.com/bytebase/dbhub/

@tianzhou tianzhou added the bug Something isn't working label Mar 12, 2025
@dkozlov
Copy link

dkozlov commented Mar 15, 2025

Workaround:

https://github.com/modelcontextprotocol/servers/tree/main/src/filesystem#build

{
  "mcpServers": {
    "filesystem": {
      "command": "bash",
      "args": [
        "-c",
        "docker attach mcp_filesystem || docker run -i --rm --name mcp_filesystem --mount type=bind,src=/home/user/Downloads,dst=/app/projects mcp/filesystem /app/projects"
        ]
    }
  }
}

@pavelanni
Copy link

I see the same thing with Claude Desktop, which starts my server twice. In my case, the server starts as a binary (written in Go and compiled). I don't know how to tell Claude Desktop to start it only once. The other client (https://github.com/chrishayuk/mcp-cli) starts it once, as it should.

If anybody has figured out how to fix it, please share.

@jmorrell-cloudflare
Copy link

We've run into the same thing working with https://github.com/geelen/mcp-remote/. Claude Desktop initializes the MCP server process twice, causing two different authentication windows to pop up, which is very confusing for the user.

I attempted to use a lockfile so that only one process could perform auth at a time as a workaround, but this resulted in brittle code that we couldn't ship. It would be much better if Claude fixed this issue

@Shchvova
Copy link

Shchvova commented Mar 27, 2025

Just to be clear - this is not specific to docker. This is for every MPC server. If you would try to listen to the socket or something like that - it would fail as well. No idea why claude does it, is that an intent or error, would be nice to have a comment from the devs.

@frijswijk
Copy link

Took me the whole day, running windows claude 0.9.0 and have the same issue with starting twice, can't run my MCP server this way. When will it be fixed anthropic?

@Shchvova
Copy link

You can code around it quite easily to be honest, not a big deal. Probably a good benchmark that you server isn't that bad that it must run in single instance and can't figure it out. What if you launch several Claude instances?

@caasi
Copy link

caasi commented Apr 2, 2025

I also encountered this issue. I guess maybe they want to test if a MCP server can shutdown itself properly.

Anyway my app will open a port but node failed to close it after shutdown. So I have to use kill-port or something similar. It makes my MCP serve a bit more complex.

@olaservo
Copy link
Member

Closing since his bug looks like its specific to the Claude app and not the servers themselves.

For Claude Desktop client issues this is the support link: https://support.anthropic.com/en/articles/9015913-how-to-get-support

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

8 participants