Repository navigation
Description
Describe the bug
Resuming an existing session cancels MCP server connections that are still initializing, causing
those servers to be silently unavailable for the entire session.
When a session is resumed, the CLI performs a foreground-session handover. Any MCP server whose
connection is still in flight at that moment is cancelled roughly one second after the handover
begins, and the CLI logs Failed to connect to MCP server "<name>": connection was cancelled.
This disproportionately affects stdio servers launched via npx -y, which need 15-20 seconds to
resolve and start. Fast-starting servers (local executables, HTTP servers) reconnect within that
one-second window and survive, so the same session ends up with a partial, inconsistent set of MCP
servers rather than an outright failure.
The affected servers are demonstrably healthy: they complete initialization and deliver their full
tool lists moments before being cancelled, and fresh tool-snapshot caches are written for them.
They are then discarded anyway, and the tools never become available to the model. There is also no
surfaced error in the interactive UI - the servers simply appear absent, which makes this look like
a configuration or authentication problem rather than a cancelled connection.
The cancellation is deterministic rather than intermittent: every resume of the same session
reproduces it. Because restarting the CLI typically resumes the previous session, the natural
recovery action does not resolve it, and the servers stay unavailable until a genuinely new session
is started.
Affected version
1.0.83
Steps to reproduce the behavior
Prerequisite: a stdio MCP server that takes >2s to start. An npx -y launcher guarantees this
(re-resolves the package on each spawn, 15-20s cold).
-
Configure a slow-starting stdio server alongside a fast one in ~/.copilot/mcp-config.json:
{
"mcpServers": {
"chrome": {
"type": "local",
"command": "npx",
"args": ["-y", "@playwright/mcp", "--user-data-dir", "C:\Users\\.mcp\chrome-profile"],
"tools": [""]
},
"fast-server-1": { "type": "http", "url": "", "tools": [""] }
}
} -
Start a NEW session:
copilot
All servers connect. Log showsService initialized -> Playwright(17s after spawn); tools are
available, cache written under %LOCALAPPDATA%\copilot\mcp-tools, no warnings.
A fresh session tolerates arbitrarily slow starts (38s observed, still fine). Does NOT reproduce here. -
Exit the session.
-
RESUME that same session (the trigger - not a fresh start):
copilot --resume -
Servers connect, then the handover cancels them ~1s later.
~/.copilot/logs/process-.log:08:37:37.342Z Service initialized -> Playwright
08:37:40.148Z Service initialized -> slow-server-a
08:37:40.691Z Service initialized -> local-exe-server
08:37:41.370Z Service initialized -> fast-server-1
08:37:41.634Z Service initialized -> fast-server-2
08:37:41.863Z Unregistering foreground session:
08:37:41.870Z Registering foreground session:
08:37:42.442Z task cancelled (x2)
08:37:42.442Z serve finished {"quit_reason":"Cancelled"} (x2)
08:37:42.459Z Service initialized -> fast-server-1 <- fast servers reconnect in <1s
08:37:42.595Z Service initialized -> local-exe-server
08:37:42.691Z Service initialized -> fast-server-2
08:37:42.911Z [WARNING] Error sending response {"id":"1"} <- server answered initialize after cancel~/.copilot/session-state//events.jsonl:
08:37:42.862Z Failed to connect to MCP server "slow-server-a": ... connection was cancelled
08:37:42.893Z Failed to connect to MCP server "chrome": ... connection was cancelledOnly fast servers reappear; slow ones are gone for the rest of the session.
-
Confirm unavailability - tools from the cancelled servers return nothing and the servers are
absent from the tool manifest. No error surfaces in the interactive UI. -
Restart the CLI. If it resumes the same session, step 5 repeats identically.
Reproduced 3/3 resumes (05:04:07Z, 08:30:06Z, 08:37:42Z); 4/4 fresh sessions connected fine.
Contrast with 1.0.82 - same machine, same config, log from 2026-09-04: four handovers
(07:28:37Z, 19:35:59Z, 19:44:20Z, 20:37:51Z) each waited 13-16s for the same npx servers to
reconnect after "Registering foreground session", all succeeded. Zero warnings before the upgrade.
Note: the race is about timing, not specific servers. A normally-fast local .exe server was also
cancelled once, at 06:31:48.232Z, when it happened to start slowly.
Expected behavior
Resuming a session should preserve all configured MCP servers, regardless of how long they take to
start. The session-resume handover should either wait for in-flight MCP connections to complete, or
allow them to finish and register afterwards - as 1.0.82 did, waiting 13-16 seconds without issue.
Specifically:
-
A resumed session should end up with the same set of available MCP servers as a fresh session
using the same configuration. Startup latency should not silently determine which servers survive. -
Connections that have already completed initialization and returned their tool list should not be
discarded. In the observed logs the servers deliver their tools and a tool cache is written, and
the result is thrown away regardless. -
If a server genuinely cannot be connected, that should be surfaced in the interactive UI, not only
buried in the process log and events.jsonl. As it stands the servers just appear absent, which
points users toward debugging their configuration, credentials, or the servers themselves - none
of which are at fault. -
Restarting the CLI after such a failure should recover. Because a restart normally resumes the
previous session, the obvious remedy reproduces the same failure instead of resolving it.
If a timeout on MCP connection setup is intentional, it should be configurable, and its value should
be generous enough to accommodate npx-launched servers, which routinely need 15-20 seconds on a
cold start.
Additional context
Environment: Windows, Node v25.9.0, npm 11.9.0. Five MCP servers configured - two npx-launched
stdio, plus faster local and HTTP ones for contrast.
Ruled out - config is not the variable:
- mcp-config.json parses cleanly and was unchanged across both the working (1.0.82) and broken
(1.0.83) periods. - No enabled/disabled/trust/timeout fields. The affected servers use the same "tools": ["*"] as a
server that connects fine. - Credentials valid - the affected servers complete
initializeand return their full tool lists
on every launch, so auth demonstrably succeeds. - No enterprise MCP policy in force (log:
effective policy resolved: source=none). - Both npx packages resolve and run fine when invoked manually.
Strongest evidence the servers are healthy: on the failing run, fresh tool-snapshot caches were
written for all five servers moments before two were cancelled. The tool lists were retrieved, then
discarded.
The [WARNING] Error sending response {"id":"1"} immediately after cancellation looks like a server
responding to an initialize whose transport was already torn down - may help locate the trigger.
Possibly related in the same release: 1.0.83 rejects the old cache format with
Unsupported MCP tool cache schema version: 1, suggesting the MCP subsystem was reworked.
Workarounds:
- Start a genuinely new session instead of resuming - fresh sessions connect reliably.
- Pre-installing the npx packages globally cuts ~15s of resolution, but isn't a guaranteed fix
against a ~1s window.
Impact: the failure is silent and misleading - servers just appear absent with no UI error, and
since restarting resumes the same session, it persists across restarts. Significant time was lost
investigating config and credentials before the logs revealed the cancellation.
Activity
Svudec commentedon Sep 7, 2026
Environment
ado-> stdio,npx -y @azure-devops/mcp <org> --authentication azcliAdditional repro: also happens on genuinely new sessions, not only resume
In addition to
/restart(session resume), this also reproduces when starting a brand-newsession with
/new. Not just a resume-specific handover issue.Log excerpt (redacted), showing ado's MCP handshake completing successfully,
then being cancelled ~10s later, before its tools are ever listed:
Note: in this case the cancellation happened ~10s after the handshake completed, not ~1s
as described in the issue title, so the window may vary depending on server/timing.
Workaround that reliably fixes it every time:
/mcp reload adoafter the session is fully up.veriton-dev commentedon Sep 7, 2026
Host-ops notes: treat resume handover as a second MCP lifecycle, not a restart
The regression shape here is familiar from other agent hosts that tightened cancel budgets around session handoff: the old session's MCP graph is torn down with a short cancel window, and the new session only re-attaches whoever wins that race. Fast HTTP/local exe survive; cold
npx -ystdio lose. Fresh sessions work because they never enter that dual-lifetime path.Three clocks that should not share one budget
initialize+ tools/list. Cold npx routinely needs 10–20s; HTTP can be <1s.If (1) cancels (2) with a ~1s budget, you get exactly the partial set described: healthy servers complete initialize, write a tool cache, then get
quit_reason: Cancelledand never reappear. That is not a server fault.Failure matrix worth separating in logs + UI
Today cancel-after-init and hard fail both present as "server not connected," which burns time on config/credentials.
Concrete host policy (what 1.0.82 effectively did)
MCP "chrome" cancelled during session resume (connect budget exceeded)rather than vanishing the server./mcp reloadfor cancelled names.Acceptance checks that would have caught 1.0.83
npx -ystdio that sleeps ~10s before ready.--resume(and/restartif that path differs): both still in manifest within connect budget; zeroconnection was cancelledfor servers that completed initialize./mcp reload <name>restores without full process restart (workaround already reported — good candidate for automatic recovery).Why the tool-cache detail matters
Writing a fresh tool snapshot and then discarding the live connection is the worst of both worlds: disk says the server is healthy, runtime says it is gone, model sees neither tools nor error. Prefer: cache is advisory; live registration is authoritative; cancel after successful tools/list is a host bug, not a cache miss.
No product pitch — just the lifecycle split that keeps slow stdio MCP servers alive across resume the way 1.0.82 did.
SQLBImhugh commentedon Sep 8, 2026
Still reproduces on 1.0.84-2, and the threshold is lower than
npx -yTwo additions to this report: it is not fixed in the current prerelease, and it affects
fast local executables, not only cold
npx -yservers.Environment
Starting Copilot CLI: 1.0.84-2, dist...\copilot\pkg\win32-x64\1.0.84-2type: localstdio andtype: http)1.0.84-2 does not fix it
v1.0.84-2 lists under Fixed: "MCP reload summary shows servers still starting after
timeout". That wording suggested this path, so I updated and retested. A session started
15 seconds after the binary was replaced still ends degraded:
The new "still starting" wording does not appear anywhere in the log (0 occurrences), so
whatever that change covers, it is not this path. The reload-race marker is still present:
The threshold is much lower than 15-20s - plain local executables are hit
The report and the first comment both frame this around
npx -yneeding 15-20s. On thismachine the cancelled servers are not npx-based; they are direct local executables and a
venv Python module. Measured cold-start (spawn ->
initialize->tools/listcomplete):pocportal<venv>\python.exe -m pocportal_mcp.server(62 tools)pmb.execodebase-memory-mcp.exeEvery
type: httpserver survives every time. Across sessions the cancelled set is drawnconsistently from the same stdio pool -
pocportal,pmb,EngHub,msx,workiq,playwright,codebase-memory-mcp- whileazure,ms-learn,webiq,powerbi-designandpowerbi-modeling-mcp(all HTTP) are never affected.So the cutoff sits somewhere between 1.6 s and 3.2 s, not at 15-20 s. Any fix that only
widens the budget enough for cold
npxmay still leave ordinary local servers on the wrongside of it if the budget is not tied to the actual initialize lifecycle.
It is not deterministic here, which makes it easy to mis-triage
Same machine, same config, consecutive sessions:
EngHub,msx,pocportal)connected=14, failed_retry_count=3connected=16, failed_retry_count=0- fully recoveredconnected=15, failed_retry_count=2So a later retry sometimes rescues a cancelled server and sometimes does not. Sessions that end
with
failed_retry_count > 0are genuinely missing those servers for their whole lifetime.Counting caveat for anyone else gathering evidence
If you have
logLevel: allset and use the agent itself to grep its own logs, the agent's tooloutput is echoed back into the log, so
grep 'connection was cancelled'over-counts wildly - Imeasured 299 hits in a session that had none. Count only real emitter lines:
jasonko commentedon Sep 11, 2026
Root cause of the second reload: the built-in
github-mcp-serveris injected lateAdding a root-cause detail I don't think is in the thread yet. Reproduced on 1.0.83, macOS 15 (arm64), via
/clear(same foreground-session handover path as/new).The cancellation isn't only a short teardown budget — there's a specific, identifiable config change that triggers the reconcile, and it comes from a built-in server rather than from user config.
On handover the CLI logs
MCP host reload requested (trigger=session_change), takes thefull replace_hostpath, and starts every configured server. Roughly 300 ms later a second reload lands, becausegithub-mcp-serverhas only just become available — it needs the CAPI token, so it is absent from the first signature. Diffing the two signatures logged bydiscover_and_start_root, the sole delta is that entry:Since the signature changed, the host switches from
replace_hosttoincremental reconcile, and that is what cancels the in-flight connects. This is likely why the bug is so widespread: the triggering config change is the CLI's own built-in server, so it happens on every handover regardless of what the user has configured.The reconcile cancels servers it has already identified as unchanged
This is the narrow part. In the same reconcile, the only server logged as restarting is the one whose config actually changed:
google-workspaceis never(re)starting— its config is unchanged — yet its pending connect is cancelled and recorded as a failure anyway:So the cancellation set is "everything still pending", not "everything whose config changed", even though the two are distinguished one line earlier.
A benign variant worth separating for triage
In my case the retry always succeeds:
google-workspacereconnects about a second later and its full tool list is available for the whole session. The user still getson essentially every
/clear. #4811 looks like the same thing. That suggests two separable fixes:pendingrather thanfailed, which fixes the spurious warning on its own.unchanged_config: trueservers alone, which removes the restart churn and thefailed_retry_count > 0cases where a server is genuinely lost.The window is ~300 ms, not 1.6–3.2 s
Consistent with the cutoff measured earlier in this thread, but tighter than it may appear: the gap between the two reloads here is about 300 ms.
google-workspace(workspace-mcplaunched viauvx) needs ~960 ms to answerinitialize, so it loses every time.I confirmed the mechanism by making the handshake complete in ~40 ms — a wrapper process that replays the server's own cached
initializeresult while the real child starts behind it. At that speed the server is alreadyconnectedwhen the reconcile fires, so it is left alone and the warning disappears entirely, with no other change. That isolates the bug to the pending-vs-connected distinction rather than anything about the server itself, and it means a fix that merely widens the cancel budget would need to cover sub-second servers to help here.Side note: killing a Python stdio child mid-handshake makes
mcp2.x dump anExceptionGrouptraceback to stderr, which is whatgetServerStderr()would surface as the failure detail if a retry ever did fail.indeherb commentedon Sep 26, 2026
@IrynaKulakova this issue was closed on 2026-09-17 with no explanation I can find:
commit_id/commit_urlasnull).changelog.json) across every 1.0.84 -> 1.0.88 release - no entry references this issue number or matches the specific mechanism described in the last comment above (github-mcp-serverbecoming available ~300ms after resume triggering a reconcile pass that cancels unrelated in-flight stdio connections).Given multiple people reproduced this as recently as the last comment before closure, could you confirm what actually resolved it, and which release/PR contains the fix? Happy to retest on 1.0.88 against specific repro steps if that helps confirm either way.