Repository navigation
Connect only to the iMCP service on this Mac - #259
Merged
Merged
Conversation
With iMCP running on two Macs on the same network, imcp-server could select the other Mac's service, because both names contain "iMCP". It then connected to its own loopback address on the other Mac's port, which nothing listens on. Ignore browse results that aren't reported on the loopback interface, which is how Bonjour reports a service registered on this Mac. Fixes #257
A connection to a port that nothing listens on stays in the waiting state and retries indefinitely, so imcp-server hung without output and never answered the client. Treat waiting before the connection is ready as a failure, so that imcp-server logs the error and tries discovery again. Set the state handler before starting the connection, so the first state update isn't missed.
imcp-server has its own Local Network entry in System Settings, and while it is turned off, the only output was a discovery timeout. Name the setting in that error, and describe it in the README.
Contributor
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Connection refusals still enter the indefinite reconnect loop instead of exiting non-zero.
Review effort: Balanced
Findings: 1
What changed in this PR
Restricts Bonjour discovery to local iMCP services and improves connection diagnostics.
Changes:
- Filters Bonjour results to loopback services.
- Reports connection waiting errors and Local Network permission guidance.
- Adds regression tests and README troubleshooting guidance.
| File | Description |
|---|---|
README.md |
Documents Local Network permission. |
CLITests/BonjourDiscoveryTests.swift |
Tests local-service selection. |
CLI/StdioProxy.swift |
Handles initial connection waiting states. |
CLI/MCPService.swift |
Improves discovery messaging. |
CLI/BonjourDiscovery.swift |
Filters remote Bonjour results. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| if let continuation = continuation, | ||
| await shouldResume(connectionState: connectionState) | ||
| { | ||
| continuation.resume(throwing: error) |
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.

Resolves #257
With iMCP on two Macs on the same network,
imcp-servercould pick the other Mac's "iMCP" service, connect to its port on127.0.0.1, and hang while the refused connection retried. This PR connects only to a service that Bonjour reports on the loopback interface, fails instead of waiting when the connection is refused, and names the Local Network setting in the discovery timeout error and the README.