Repository navigation
Fix reconnect loop that drops Claude Desktop connections - #208
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
A pending network receive can prevent the task group from exiting after stdin EOF, so the helper may still fail to terminate.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
Fixes helper shutdown behavior after stdin EOF and closes a startup race in connection approval.
Changes:
- Adds centralized reconnect/termination decisions with regression tests.
- Treats stdin EOF and clean proxy returns as terminal.
- Registers approval handling before Bonjour advertisement.
File summaries
| File | Description |
|---|---|
iMCP.xcodeproj/project.pbxproj |
Adds loop logic and tests to the test target. |
CLITests/MCPServiceLoopTests.swift |
Tests reconnect decisions. |
CLI/MCPServiceLoop.swift |
Defines proxy errors and retry policy. |
CLI/main.swift |
Updates proxy cleanup and EOF handling. |
App/Controllers/ServerController.swift |
Reorders approval registration and startup. |
Review details
- Files reviewed: 5/5 changed files
- Comments generated: 1
- Review effort level: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
This was referenced Sep 17, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Smoke testing latest version on main branch with Claude Desktop wasn't working for me.
When the MCP client closes stdin, the stdin handler returned without an error.
MCPServicetreated that as a reason to browse Bonjour again immediately. stdin stayed at EOF, so each new TCP session died at once and the helper spun until it was force-quit or crashed. Claude Desktop still owned the process, so it could not spawn a fresh helper.stdin EOF now fails the proxy session, and a clean return is treated as a disconnect. The helper exits so the client can relaunch it. The menubar app also registers the connection approval handler before it advertises the Bonjour service, so the first connection after launch is not rejected because the handler is still nil.