fix(mcp): answer server/discover locally in the stdio proxy (#2084) (#2282)

* fix(mcp): answer server/discover locally in the stdio proxy (#2084)

Clients that probe `server/discover` before the legacy `initialize`
(Antigravity 2.5) wait for its answer. The proxy forwarded it to the shared
daemon, so no reply was written until the daemon connected: a client that
closed stdin first got nothing, and with the daemon unavailable the reply
came ~6s later as -32603 "daemon unavailable". Answer it in the proxy with
-32601 Method not found, which is what sends such a client on to
`initialize`. The direct and daemon sessions already answer unknown methods
with -32601; the new test pins that too.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit 77db6c659c)

* docs(changelog): credit the server/discover fix

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: danusha2345 <ewidusoc498@gmail.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Colby Mchenry
2026-10-02 04:13:42 +00:00
committed by GitHub
co-authored by Claude Opus 5.5 danusha2345
parent 96ba880556
commit 49248e25eb
3 changed files with 143 additions and 0 deletions
+7
View File
@@ -30,6 +30,7 @@ import { CodeGraphPackageVersion } from './version';
import { SERVER_INFO, PROTOCOL_VERSION, initializeInstructions } from './session';
import { SERVER_INSTRUCTIONS } from './server-instructions';
import { getStaticTools } from './tools';
import { ErrorCodes } from './transport';
import { ExploreSessionState } from './explore-session-state';
import { getTelemetry, ClientInfo } from '../telemetry';
import { installMainThreadWatchdog, WatchdogHandle } from './liveness-watchdog';
@@ -332,6 +333,12 @@ export async function runLocalHandshakeProxy(deps: LocalHandshakeDeps): Promise<
writeClient({ jsonrpc: '2.0', id: msg.id, result: { resourceTemplates: [] } });
} else if (msg.method === 'prompts/list') {
writeClient({ jsonrpc: '2.0', id: msg.id, result: { prompts: [] } });
} else if (msg.method === 'server/discover' && msg.id !== undefined) {
// Newer clients (Antigravity 2.5) probe this before `initialize` and wait
// for the answer. We don't implement it; Method-not-found is what sends
// them on to `initialize`. Answer locally — forwarded, it waited on the
// daemon connection and was lost if the client closed stdin first. (#2084)
writeClient({ jsonrpc: '2.0', id: msg.id, error: { code: ErrorCodes.MethodNotFound, message: 'Method not found: server/discover' } });
} else {
routeToDaemon(line);
}