Skip to content

Unable to stop mcpproxy server when local command-based upstream servers are running #51

Closed

Description

@Alex0007

When using local command-based upstream servers (like mongodb-mcp-server executed via npx), the mcpproxy server cannot be properly stopped/terminated. This appears to be different behavior compared to remote server connections, which can be stopped normally.

Expected behavior: mcpproxy server should stop gracefully regardless of upstream server type (local command vs remote server)

Actual behavior: mcpproxy server hangs or fails to terminate when local command-based upstream servers are active

Steps to Reproduce

  1. Configure a local command-based upstream server in mcp_config.json:
    {
      "command": "npx",
      "args": ["-y", "mongodb-mcp-server"]
    }
  2. Start mcpproxy server
  3. Verify the upstream server is running and connected
  4. Attempt to stop mcpproxy server
  5. Observe that mcpproxy server does stuck in "stopping" state

Environment Details

  • Operating System: macOS 15.5

Logs

Expand
2025-09-03T06:22:40.295+04:00 | INFO | managed/client.go:85 | Starting connection attempt | {"server": "MongoDB ", "transport": "stdio", "url": "", "command": "npx", "protocol": ""}
2025-09-03T06:22:43.620+04:00 | INFO | core/connection.go:105 | MCP initialization completed successfully | {"server": "MongoDB ", "server_name": "MongoDB MCP Server", "server_version": "0.3.0", "protocol_version": "2025-06-18"}
2025-09-03T06:22:43.620+04:00 | INFO | managed/client.go:85 | Successfully connected and initialized | {"server": "MongoDB ", "transport": "stdio", "server_name": "MongoDB MCP Server", "server_version": "0.3.0", "protocol_version": "2025-06-18"}
2025-09-03T06:22:49.766+04:00 | INFO | core/connection.go:1076 | Disconnecting from server | {"server": "MongoDB "}
2025-09-03T06:22:51.768+04:00 | WARN | core/monitoring.go:27 | stderr read error | {"server": "MongoDB ", "error": "read |0: file already closed"}

Additional Details

While it logs the file already closed error, the MongoDB MCP process remains running.

Activity

  1. Alex0007 commented on Sep 22, 2025

    @Alex0007
    Author

    With recent commits it seems like closing mcpproxy now kills MCP servers processes, which is expected behavior

  2. Alex0007 commented on Oct 16, 2025

    @Alex0007
    Author

    Version 0.9.* not closing child MCP processes again

  3. Melodeiro commented on Oct 27, 2025

    @Melodeiro

    Probably some timeout is needed because some mcp's are nasty, and mcpproxy isn't stopping without forced kill, thats true. I mean force kill of the underlying mcp proxies after a timeout

  4. Melodeiro commented on Oct 28, 2025

    @Melodeiro

    Also relevant to #105

  5. added 2 commits that reference this issue on Dec 21, 2025
    dd614cd
    1de875d
  6. added a commit that references this issue on Dec 21, 2025
    f94cf5c
  7. Dumbris commented on Dec 21, 2025

    @Dumbris
    Member

    Hey! The subprocess cleanup was fixed a few versions ago. In #214 we tuned the timeouts and documented everything properly.

    Current behavior:

    When mcpproxy stops, subprocesses get cleaned up in two phases:

    1. Graceful close (10s) - closes stdin/stdout, waits for process to exit nicely
    2. Force kill (9s) - SIGTERM → poll every 100ms → SIGKILL if still running

    Process groups ensure child processes (spawned by npm/npx) get killed together.

    Timeouts:

    What Time
    Graceful close 10s
    SIGTERM → SIGKILL 9s
    Docker containers 30s

    Docs:

    Closing this one out!

  8. added a commit that references this issue on Jan 21, 2026
    42fa59a
  9. added a commit that references this issue on Jan 23, 2026
    9fee199
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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