MCP: gateway-driven port coordination#6007
Merged
Conversation
Gateway now forwards -mcpPort N to spawned MI (configurable via --mcp-port, default 7887). MI's setupMcp parses the flag, forces the server port and auto-start (overriding the mcp.enableByDefault config), and shows the port read-only in Settings. -mcpDumpFile additionally suppresses server start so the gateway's cache-prime spawn never briefly binds the port. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Fedr
approved these changes
Apr 29, 2026
adalisk-emikhaylov
requested changes
Apr 29, 2026
| [[nodiscard]] MRMCP_API Server& getDefaultServer(); | ||
|
|
||
| /// Overrides parsed from the application's command-line arguments. Sentinel values | ||
| /// (`port <= 0`, empty `dumpFilePath`) mean "no override". |
Contributor
There was a problem hiding this comment.
Let's move this to MRMcpSettings. See my next comment for more details.
| return false; | ||
| #endif | ||
| } | ||
|
|
Contributor
There was a problem hiding this comment.
Put parseCmdLineOverrides in this file, hidden in the .cpp (don't expose to the header).
Make getPort() respect the override, and make setPort() do nothing if the override exists.
Maybe add another function here from the dump file path (not sure if it should be in this file or elsewhere).
|
|
||
| // Push the effective port (CLI override beats config). | ||
| Mcp::Server::Params params = server.getParams(); | ||
| params.port = overrides.port > 0 ? overrides.port : McpSettings::getPort(); |
Contributor
There was a problem hiding this comment.
This logic should be in McpSettings::getPort() IMO.
Pure code motion — colocates CLI-flag parsing with the settings layer (its only consumer). MRMcp public surface stays focused on the Server. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
adalisk-emikhaylov
approved these changes
Apr 29, 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.
Summary
-mcpPort Nto spawned MI (configurable via--mcp-port, default 7887). When--target-urlis omitted, the gateway's probe URL derives from the same port — so--mcp-port 8888is enough to move the whole loop off 7887.MIparses-mcpPortearly insetupMcp(newMcp::parseCmdLineOverrideshelper), forces the server port + auto-start, and shows the port read-only in Settings → MCP with a tooltip explaining why.-mcpDumpFilenow suppresses server start so the gateway's cache-prime spawn never briefly binds the port (would collide with a live backend).Server::processCmdArgs(only called fromsetupMcp).Test plan
MeshInspector.exe -mcpDumpFile out.json -noEventLoop -hidden→ 30 tools written, noMCP server startedlog line.MeshInspector.exe -mcpPort 9999 -noEventLoop -tryHidden→ log showsMCP server started on port 9999.MRMCPGateway --mcp-port 8888 --launch-cmd MeshInspector.exeprimes the cache by spawning MI with-mcpPort 8888 -mcpDumpFile <cache>. Thentools/call launchspawns MI on 8888; Settings → MCP shows port8888read-only with tooltipPort forced by -mcpPort command-line flag.MeshInspector.exe— config-driven path unchanged.🤖 Generated with Claude Code