Skip to content

v1.0.83: session resume cancels in-flight stdio MCP server connections (~1s timeout, was ~16s in v1.0.82) #4753

Closed

Description

@indeherb

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).

  1. 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": ["
    "] }
    }
    }

  2. Start a NEW session: copilot
    All servers connect. Log shows Service 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.

  3. Exit the session.

  4. RESUME that same session (the trigger - not a fresh start): copilot --resume

  5. 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 cancelled

    Only fast servers reappear; slow ones are gone for the rest of the session.

  6. 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.

  7. 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 initialize and 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

  1. added theissue type on Sep 7, 2026
  2. Svudec commented on Sep 7, 2026

    @Svudec

    Environment

    • Copilot CLI version: 1.0.83 (upgraded from 1.0.81 immediately before this started)
    • OS: macOS 15 (Darwin 25.6.0, arm64)
    • Node.js: v22.22.2 (also reproduced under v24.20.0)
    • MCP server: ado -> stdio, npx -y @azure-devops/mcp <org> --authentication azcli

    Additional repro: also happens on genuinely new sessions, not only resume

    In addition to /restart (session resume), this also reproduces when starting a brand-new
    session 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:

    2026-09-07T09:16:19.588Z [INFO] Starting Copilot CLI: 1.0.83
    2026-09-07T09:16:20.915Z [INFO] [rust:rmcp::service] Service initialized as client
      {"peer_info": ... "server_info": {"name": "Azure DevOps MCP Server", "version": "2.9.0", ...}}
    2026-09-07T09:16:31.174Z [INFO] [rust:rmcp::service] task cancelled
    2026-09-07T09:16:31.174Z [INFO] [rust:rmcp::service] serve finished {"quit_reason":"Cancelled"}
    ...
    2026-09-07T09:16:52.737Z [WARNING] PluginsScreenDetail listMcpTools(ado) failed:
      Error: MCP server "ado" is not connected
    

    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 ado after the session is fully up.

  3. veriton-dev commented on Sep 7, 2026

    @veriton-dev

    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 -y stdio lose. Fresh sessions work because they never enter that dual-lifetime path.

    Three clocks that should not share one budget

    1. Handover / foreground-session swap — unregister A, register B. This is a host control-plane event, not an MCP error.
    2. Transport reconnect / initialize — stdio spawn + initialize + tools/list. Cold npx routinely needs 10–20s; HTTP can be <1s.
    3. Tool-ready registration — only after (2) settles should the model-visible tool manifest change.

    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: Cancelled and never reappear. That is not a server fault.

    Failure matrix worth separating in logs + UI

    Mode What happened User-visible Correct recovery
    cancel-during-init handshake in flight when handover fires server absent wait/rebind, do not mark permanently failed
    cancel-after-init tools/list already succeeded, cache written, then cancel silent missing tools re-register from cache or retry once without new spawn storm
    hard connect fail spawn/auth/protocol error explicit error surface name + reason in UI
    slow-but-alive initialize > budget but still progressing looks like fail progress heartbeat / configurable budget

    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)

    • Do not cancel in-flight MCP connects on resume unless the operator is quitting the process. Handover should re-parent or wait, not abort.
    • If a timeout is required, make it per-server connect budget (default ≥15–20s for stdio, lower for HTTP), not a global ~1s handover timer.
    • Preserve completed init: if tools/list already returned, keep the registration (or the cache snapshot) across the session id swap; only drop on hard error.
    • Surface cancel distinctly: UI should say MCP "chrome" cancelled during session resume (connect budget exceeded) rather than vanishing the server.
    • Restart must not re-enter the same trap: if default restart = resume, and resume always cancels slow servers, the obvious recovery is broken. Either force a true cold session after N cancel failures, or auto /mcp reload for cancelled names.

    Acceptance checks that would have caught 1.0.83

    1. Config: one HTTP MCP + one npx -y stdio that sleeps ~10s before ready.
    2. Fresh session: both in tool manifest.
    3. Exit → --resume (and /restart if that path differs): both still in manifest within connect budget; zero connection was cancelled for servers that completed initialize.
    4. Intentionally kill only the slow server mid-init: UI shows named failure; fast server remains.
    5. After a cancel-during-resume, /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.

  4. added
    area:mcp
    area:sessions
    and removed on Sep 8, 2026
  5. SQLBImhugh commented on Sep 8, 2026

    @SQLBImhugh

    Still reproduces on 1.0.84-2, and the threshold is lower than npx -y

    Two additions to this report: it is not fixed in the current prerelease, and it affects
    fast local executables, not only cold npx -y servers.

    Environment

    • Copilot CLI 1.0.84-2 (prerelease channel), Windows 11
    • Confirmed in-log: Starting Copilot CLI: 1.0.84-2, dist ...\copilot\pkg\win32-x64\1.0.84-2
    • 16 MCP servers configured (mix of type: local stdio and type: 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:

    22 x "Recorded failure for server <name>: MCP server "<name>" connection was cancelled"
    final: {"connected_count":15,"pending_count":0,"failed_retry_count":2}
    

    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:

    discarding stale MCP host projection after newer reload admission
      {"captured_revision":3,"current_revision":4}
    

    The threshold is much lower than 15-20s - plain local executables are hit

    The report and the first comment both frame this around npx -y needing 15-20s. On this
    machine the cancelled servers are not npx-based; they are direct local executables and a
    venv Python module. Measured cold-start (spawn -> initialize -> tools/list complete):

    server launcher cold start outcome
    pocportal <venv>\python.exe -m pocportal_mcp.server (62 tools) 4.0 s repeatedly cancelled
    pmb local .exe 3.2 s repeatedly cancelled
    codebase-memory-mcp local .exe 1.6 s never cancelled

    Every type: http server survives every time. Across sessions the cancelled set is drawn
    consistently from the same stdio pool - pocportal, pmb, EngHub, msx, workiq,
    playwright, codebase-memory-mcp - while azure, ms-learn, webiq, powerbi-design and
    powerbi-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 npx may still leave ordinary local servers on the wrong
    side 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:

    session cancellations final state
    A 3 (EngHub, msx, pocportal) connected=14, failed_retry_count=3
    B 8 (8 distinct servers) connected=16, failed_retry_count=0 - fully recovered
    C 22 (11 distinct servers) connected=15, failed_retry_count=2

    So a later retry sometimes rescues a cancelled server and sometimes does not. Sessions that end
    with failed_retry_count > 0 are genuinely missing those servers for their whole lifetime.

    Counting caveat for anyone else gathering evidence

    If you have logLevel: all set and use the agent itself to grep its own logs, the agent's tool
    output is echoed back into the log, so grep 'connection was cancelled' over-counts wildly - I
    measured 299 hits in a session that had none. Count only real emitter lines:

    rt_mcp::native_host] Recorded failure for server <name>: MCP server
    
  6. jasonko commented on Sep 11, 2026

    @jasonko

    Root cause of the second reload: the built-in github-mcp-server is injected late

    Adding 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 the full replace_host path, and starts every configured server. Roughly 300 ms later a second reload lands, because github-mcp-server has only just become available — it needs the CAPI token, so it is absent from the first signature. Diffing the two signatures logged by discover_and_start_root, the sole delta is that entry:

    prev: {"servers":[["google-workspace",...]],"disabled":[],"managedPolicyStartPending":false}
    new : {"servers":[["github-mcp-server",...],["google-workspace",...]],"disabled":[],"managedPolicyStartPending":false}
    

    Since the signature changed, the host switches from replace_host to incremental 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:

    mcp incremental reconcile: (re)starting server {"server":"github-mcp-server","unchanged_config":false,"had_previous_config":true}
    

    google-workspace is never (re)starting — its config is unchanged — yet its pending connect is cancelled and recorded as a failure anyway:

    06:06:48.965  MCP host reload requested (trigger=session_change)
    06:06:48.983  mcp discover_and_start_root {"signature_matches":false,...}
    06:06:48.983  mcp discover_and_start_root: full replace_host path              <- google-workspace starts
    06:06:49.282  rmcp::service Service initialized as client (github-mcp-server, 2026-07-28)
    06:06:49.283  mcp discover_and_start_root {"signature_matches":false,...}
    06:06:49.283  mcp discover_and_start_root: incremental reconcile path
    06:06:49.283  mcp incremental reconcile: (re)starting server {"server":"github-mcp-server","unchanged_config":false,...}
    06:06:49.283  rmcp::service task cancelled
    06:06:49.283  rmcp::service serve finished {"quit_reason":"Cancelled"}
    06:06:49.622  rt_mcp::native_host] Recorded failure for server google-workspace: MCP server "google-workspace" connection was cancelled
    06:06:49.623  mcp discover_and_start_root {"signature_matches":true,...}       <- restarted, connects fine
    

    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-workspace reconnects about a second later and its full tool list is available for the whole session. The user still gets

    Failed to connect to MCP server "google-workspace": MCP server "google-workspace" connection was cancelled. Execute '/mcp show google-workspace' to inspect or check the logs.
    

    on essentially every /clear. #4811 looks like the same thing. That suggests two separable fixes:

    1. A connect cancelled by the CLI's own reload is not a connect failure — it should return to pending rather than failed, which fixes the spurious warning on its own.
    2. The reconcile should leave connections for unchanged_config: true servers alone, which removes the restart churn and the failed_retry_count > 0 cases 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-mcp launched via uvx) needs ~960 ms to answer initialize, 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 initialize result while the real child starts behind it. At that speed the server is already connected when 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 mcp 2.x dump an ExceptionGroup traceback to stderr, which is what getServerStderr() would surface as the failure detail if a retry ever did fail.

  7. indeherb commented on Sep 26, 2026

    @indeherb
    Author

    @IrynaKulakova this issue was closed on 2026-09-17 with no explanation I can find:

    • No closing comment was left.
    • No linked commit or PR (the close event shows commit_id/commit_url as null).
    • I checked the CLI changelog (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-server becoming 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:mcparea:sessions

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions