Repository navigation
Description
Summary
When a stdio MCP server takes longer than ~10 s to start, Copilot CLI gives up waiting for its server/discover probe and sends a legacy initialize on the same stdio connection. A server built on the MCP Python SDK 2.3.0 then processes the queued server/discover first, locks the connection to the 2026-07-28 protocol, and rejects the initialize with -32022. Copilot CLI reports the server as failed and does not retry, even though both sides support 2026-07-28.
In the same situation, Claude Code (2.1.308) and the MCP Python SDK client re-probe with server/discover and connect successfully.
Environment
- Copilot CLI 1.0.103 (linux-x64)
- MCP server: any stdio server on
mcp(Python SDK) 2.3.0 with a slow cold start. Observed withanalytics-mcp0.8.0 (Google Analytics MCP server) andserena-agent2.1.0.
Steps to reproduce
-
Save this as
slow_server.py:# /// script # dependencies = ["mcp==2.3.0"] # /// import time time.sleep(12) # simulate a slow cold start from mcp.server.mcpserver import MCPServer server = MCPServer("slow-start-repro") @server.tool() def ping() -> str: return "pong" server.run("stdio")
-
Run
uv run --script slow_server.py < /dev/nullonce so the dependencies are cached. -
Start Copilot CLI with the server:
copilot -p "List the tools of the slowrepro MCP server. Do not call them." \ --additional-mcp-config '{"mcpServers":{"slowrepro":{"type":"local","command":"uv","args":["run","-q","--script","/path/to/slow_server.py"],"tools":["*"]}}}'
Actual behavior
The server is not connected. The log shows:
[WARNING] [rust:rt_mcp_connection] MCP server connection failed {"server_name":"...","raw_error":"failed to initialize MCP client: JSON-RPC error: -32022: connection is serving the 2026-07-28 protocol; the initialize handshake is not accepted({\"supported\":[\"2026-07-28\"],\"requested\":\"2025-11-25\"})"}
Frames captured between Copilot CLI and the server (seconds since spawn):
0.007 C->S {"id":0,"method":"server/discover","params":{"_meta":{"io.modelcontextprotocol/protocolVersion":"2026-07-28",...}}}
9.797 C->S {"id":1,"method":"initialize","params":{"protocolVersion":"2025-11-25",...}}
13.813 S->C {"id":0,"result":{"supportedVersions":["2026-07-28"],...}}
13.814 S->C {"id":1,"error":{"code":-32022,"message":"connection is serving the 2026-07-28 protocol; the initialize handshake is not accepted","data":{"supported":["2026-07-28"],"requested":"2025-11-25"}}}
Servers that normally start within 5 s also hit this right after the machine boots (cold disk cache, many processes starting at once). In that case, /mcp reload or restarting Copilot CLI connects them.
Expected behavior
The connection succeeds over 2026-07-28, as it does when the server starts within the timeout. Any of these would work:
- When the fallback
initializegets-32022anddata.supportedcontains a version the client supports, re-probe withserver/discoverat that version. The MCP Python SDK client does this (mcp/client/_probe.py: "The fallback handshake itself can be answered with -32022 … That code is itself positive modern evidence … so it triggers one re-probe at a mutual version instead of failing the connect."), and so does Claude Code. - Accept a late
server/discoverresponse that arrives after the fallback was sent. - For stdio, restart the server process before falling back, so the fallback does not share a connection with the unanswered probe.
Workaround
Make the server start faster than the probe timeout. In our case the venv is read-only at runtime, so .pyc files were never written. Installing the server with uv tool install --compile-bytecode brought startup down to ~3.5 s, and Copilot CLI then connected over 2026-07-28. This still fails occasionally right after the machine boots, as described above.
Activity
hstaudacher commentedon Nov 18, 2026
Thanks for the precise wire capture. Confirmed: when
server/discovertimes out, the legacyinitializefallback is sent on the same connection, so slow-starting stdio servers can fail to connect. This is separate from the cache-hint fix for #4888, and we've moved it to the backlog.