Sitar118 Claude Sonnet 4.6 commited on
Commit
19d5f13
·
1 Parent(s): d9f9b4b

fix: first instance always binds port 16620, fallback to auto-port

Browse files

Ensures Claude Code MCP registration (fixed at 16620) always works.
Second+ instances get OS-assigned ports, discoverable via list_instances().

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

Files changed (1) hide show
  1. Source/Plugin/McpServer.cpp +6 -1
Source/Plugin/McpServer.cpp CHANGED
@@ -69,7 +69,12 @@ void McpServer::start()
69
  if (running.load()) return;
70
  serverThread = std::thread([this]() {
71
  running.store(true);
72
- port = server->bind_to_any_port("127.0.0.1");
 
 
 
 
 
73
  server->listen_after_bind();
74
  running.store(false);
75
  });
 
69
  if (running.load()) return;
70
  serverThread = std::thread([this]() {
71
  running.store(true);
72
+ // Try port 16620 first (Claude Code MCP registration). If taken by
73
+ // another instance, fall back to OS-assigned port.
74
+ if (server->bind_to_port("127.0.0.1", 16620))
75
+ port = 16620;
76
+ else
77
+ port = server->bind_to_any_port("127.0.0.1");
78
  server->listen_after_bind();
79
  running.store(false);
80
  });