Skip to content

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

Open
@dgouvea

Description

@dgouvea

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions