Repository navigation
Description
- Copilot Chat Extension Version: Not established in this RCA.
- VS Code Version: Affected build version not established. Logs captured on October 16, 2026. Source analysis below uses checkout revision
3895f178cc2a9cc5fa55071052f522bf159cae04, not a verified affected-build revision. - OS Version: macOS. Exact version not established.
- Feature (e.g. agent/edit/ask mode): Agents window / Agent Host / HTTP MCP OAuth authentication.
- Selected model (e.g. GPT 4.1, Claude 3.7 Sonnet): Not relevant to the observed authentication handoff.
- Logs: Sanitized timeline below from an Agent Host debug-log export. Raw logs are not attached because they contain sensitive session content. Exported bearer tokens are redacted, so token-byte equality cannot be established from this bundle.
Steps to Reproduce:
- Configure two named HTTP MCP servers, such as
slack-aandslack-b, both usinghttps://mcp.slack.com/mcp, with differentoauthClientIdvalues and authorization intended for different Slack workspaces. - Start or resume an Agent Host session so both servers request authentication at approximately the same time.
- Allow the client to supply their authentication credentials.
- Search through each named server and inspect the workspace of returned results.
Actual behavior
A search explicitly routed through the server intended for workspace A returned links from workspace B. Reading a known channel from workspace A then returned channel_not_found.
The configuration uses different OAuth client IDs. The AHP authentication-required states preserve the correct client ID for each named server. The distinction disappears in the resource-level authentication reply.
Expected behavior
Each server receives only the credential selected for its authentication request and OAuth client/account. Sharing an endpoint or protected-resource identifier must not collapse distinct server authorizations.
Observed timeline
These events occur within the same session. All times are UTC on October 16, 2026.
| Time | Event |
|---|---|
| 17:12:47.973 | First Slack server enters authRequired with its configured OAuth client ID. |
| 17:12:47.976 | Second Slack server enters authRequired with its different configured OAuth client ID. |
| 17:12:48.398 | Client sends authenticate for resource https://mcp.slack.com, with scopes and a redacted token, but no MCP-server or auth-request identifier. |
| 17:12:48.428 | First server transitions to starting. |
| 17:12:48.431 | Second server transitions to starting, before the second authentication reply arrives. |
| 17:12:48.450 | Client sends the second resource-level authentication request. |
| 17:12:49.359 / 17:12:49.673 | Both servers reach ready. |
| 18:14:55 | Search through the server intended for workspace A returns workspace B links. |
| 18:20:39 / 18:21:12 | Reads of a workspace A channel fail with channel_not_found. |
Root cause analysis
The current implementation explains the ordering above:
forwardAuthenticationTokensends resource, scopes, and token without identifying the originating MCP server or authentication request.CopilotAgent.handleAuthenticationTokenforwards the reply to every live session.CopilotAgentSession.resolveMcpAuthenticationloops over pending requests and matches only protected resource and sufficient scopes. It does not match server name, OAuth client ID, or request ID. It responds to every match withparams.token.
Thus the first credential handoff can complete both servers' pending SDK auth callbacks. Different static OAuth client IDs do not protect against this host-side fan-out. The logs do not establish which original OAuth grant won, but they show both servers starting after the first handoff and before the second.
There is also a related identity concern in getDynamicAuthenticationProviderId, which derives provider identity from authorization-server URL plus resource, without client ID. That needs consideration alongside the pending-request routing fix, rather than assuming credential-cache partitioning alone solves this incident.
Suggested fix and regression coverage
Preserve the originating MCP authentication request/server identity through the client reply and resolve only the intended pending callback. Keep distinct OAuth client/account identities isolated through provider selection and credential storage.
Add a regression test with two simultaneously pending MCP auth requests that share resource/scopes but have different server names and OAuth client IDs. Delivering the first credential must resolve only its intended request; the other must remain pending until its own credential arrives.
Related issues
- MCP: Cannot authenticate to multiple Atlassian sites simultaneously - OAuth credentials shared across MCP server configurations #293533 reports multiple Atlassian sites sharing credentials in the workbench MCP flow. This report isolates an Agent Host callback fan-out with distinct OAuth client IDs.
- Incorrect value of resource parameter is sent during authentication when two MCP servers have the same host #258410 concerns the wrong OAuth resource parameter for servers sharing a host.
- Agent Host duplicate MCP auto-auth reports failure after success #327824 concerned duplicate Agent Host handoffs reporting failure after success. This report concerns different servers accepting one handoff.
No code changes or fresh reproduction were performed for this report. Evidence comes from the captured incident and source inspection.
🤖 Posted by GitHub Copilot on Harald's behalf.
Activity
vs-code-engineering commentedon Oct 16, 2026
Thanks for creating this issue! It looks like you may be using an old version of VS Code; the latest stable release is 1.142.0. Please try upgrading to the latest version and checking whether this issue remains.
Happy Coding!
agentHost: keep targeted MCP credentials separate for reconnect replay
agentHost: send each MCP OAuth token only to its target server (#343026)