Skip to content

Running MCP tools from Docker doesn't properly terminate the container #547

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

Open
dgouvea opened this issue May 26, 2025 · 1 comment
Open
Labels
bug Something isn't working

Comments

@dgouvea
Copy link

dgouvea commented May 26, 2025

Describe the bug
When running MCP tools from Docker, the close doesn't properly terminate the container. It keeps running in the background.
The tools are working correctly. However, because they have to run using -i it keeps running the container.
The main problem is that when the StdioClientTransport .close() is called, it executes this._abortController.abort(), but doesn't terminate the container for some reason. So when my application finishes, it never exits, because the child process is still running.

To Reproduce
Steps to reproduce the behavior:

  1. Create an MCP client and configure a Docker MCP server:
{
  "mcpServers": {
    "time": {
      "command": "docker",
      "args": [
        "run",
        "-i",
        "--rm",
        "mcp/time"
      ]
    }
  }
}
  1. Use a prompt to call the MCP server
  2. Call StdioClientTransport .close()
  3. Your application will hang and never finish

Expected behavior
It should terminate all child processes started by StdioClientTransport. If the process doesn't terminate properly, it should be killed.

Logs
No relevant logs.

Additional context
I am running it on Mac OS Sequoia using the latest version of Docker and the latest version of the library 1.12.0.

@dgouvea dgouvea added the bug Something isn't working label May 26, 2025
dgouvea added a commit to aux4/modelcontextprotocol-sdk that referenced this issue May 26, 2025
@dgouvea
Copy link
Author

dgouvea commented May 26, 2025

I proposed a fix for this problem here, and I am open to any changes you suggest.

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

1 participant