Skip to content

Connections reset when Claude Desktop launches two imcp-server instances simultaneously #217

Closed

Description

@andrewvlahopoulos

Environment

  • macOS: 27.0 (26A428)
  • iMCP: 1.4.1
  • Claude Desktop: Claude 2.110.0 (dfb2ba) 2026-09-15T05:50:55.000Z

Problem
iMCP fails to connect whenever Claude Desktop starts. Claude shows "Server disconnected" and "Couldn't start for Cowork and Code sessions. Error: Connection closed." Running imcp-server manually in Terminal works fine.

Findings

  • Claude Desktop launches two imcp-server processes at the same time (one for regular chats, one for Cowork/Code sessions).
  • In a log stream capture, the iMCP app logged ~200 "Handling new connection" / "Connection successfully established" events in about 2 seconds, driven by the two bridge processes reconnecting in a loop.
  • Newly launched bridges resolve the _mcp._tcp Bonjour service and connect, then receive "Connection reset by peer" within ~5 ms.
  • The bridge logs Network handler failed: connectionClosed followed by Connection closed, terminating....
  • The iMCP app logs no errors on its side, and the approval prompt never appeared while this was happening.

Workaround
A wrapper script that adds a random 0–6 second delay before execing imcp-server resolves it. With the startups staggered, the approval prompt appears and both connections work.

Expected
iMCP should handle two clients connecting at the same moment, and the bridge should back off instead of reconnecting in a tight loop.

Logs available on request.

Activity

  1. mattt commented on Sep 17, 2026

    @mattt
    Owner

    Hi @andrewvlahopoulos. Thanks for the careful writeup, the log stream capture especially.

    Two bugs are stacked here. On 1.4.1, imcp-server reconnects immediately whenever its connection drops, so the two bridges Claude Desktop now launches end up in the loop you captured. 1.5.0 makes the bridge exit instead and lets Claude Desktop relaunch it (#208). The reset within a few milliseconds is the app's side: it held its half of every dropped connection for about a minute, so under that loop they piled up against the file descriptor limit and new connections got refused (#178). 1.5.0 closes those right away (#225).

    Could you try 1.5.0 without the wrapper script? I'm closing this as fixed; please reopen if it still fails, and lsof -p $(pgrep -x iMCP) | grep -c CLOSE_WAIT after a Claude Desktop launch would tell us whether anything is still piling up.

  2. andrewvlahopoulos commented on Sep 17, 2026

    @andrewvlahopoulos
    Author

    @mattt Updated to 1.5.0 and removed the wrapper script. Connects reliably on Claude Desktop launch, and lsof -p $(pgrep -x iMCP) | grep -c CLOSE_WAIT returns 0 after launch. Thanks for the quick fix.

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