Skip to content

agentHost: fetch MCP OAuth metadata outside renderer - #340537

Merged
Martin Aeschlimann (aeschli) merged 3 commits into
mainfrom
aeschli/mcp-auth-button
Oct 14, 2026
Merged

Martin Aeschlimann (aeschli) merged 3 commits into
mainfrom
aeschli/mcp-auth-button

Conversation

@aeschli

Copy link
Copy Markdown
Contributor

Fixes #340533

Routes MCP authorization-server metadata discovery through the shared process on desktop instead of renderer fetch. This allows OAuth providers whose well-known metadata endpoints do not permit CORS requests to start authentication. Web continues to use the request-service implementation.

Adds regression coverage for an Avalara-style provider where the OAuth metadata endpoint returns 404 and OpenID discovery succeeds.

Validation

  • npm run build-fast -- --client-only — passed
  • ./scripts/test.sh --run src/vs/workbench/contrib/chat/test/browser/agentSessions/agentHostAuth.test.ts — 78 tests passed
  • npm run typecheck-client — passed
  • npm run eslint -- src/vs/platform/agentHost/common/agentHostMcpOAuthMetadataService.ts src/vs/platform/agentHost/electron-browser/agentHostMcpOAuthMetadataService.ts src/vs/workbench/contrib/chat/browser/agentSessions/agentHost/agentHostAuth.ts src/vs/workbench/contrib/chat/test/browser/agentSessions/agentHostAuth.test.ts src/vs/code/electron-utility/sharedProcess/sharedProcessMain.ts src/vs/workbench/workbench.common.main.ts src/vs/workbench/workbench.desktop.main.ts src/vs/sessions/sessions.common.main.ts src/vs/sessions/sessions.desktop.main.ts — passed
  • npm run valid-layers-check — passed
  • Live Code OSS test with Avalara ELR — Authenticate opened the Avalara browser login/authorization flow; no metadata CORS failure remained in renderer logs

Route desktop MCP authorization-server discovery through the shared process so providers without CORS metadata headers can start authentication. Keep the request-service implementation as the web fallback and cover OpenID discovery after an OAuth metadata 404.\n\nFixes #340533\n\nCo-authored-by: Copilot <[email protected]>
Copilot AI balanced review requested due to automatic review settings October 8, 2026 17:27
@vs-code-engineering

Copy link
Copy Markdown
Contributor

📬 CODENOTIFY

The following users are being notified based on files changed in this PR:

Robo (@deepak1556)

Matched files:

  • src/vs/code/electron-utility/sharedProcess/sharedProcessMain.ts

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

OAuth networking now crosses a process and security boundary, warranting final human review despite focused regression coverage.

0 open findings

What changed in this PR

Routes MCP OAuth metadata discovery through the desktop shared process to bypass renderer CORS restrictions while retaining web request-service behavior.

Changes:

  • Adds a request-service-backed metadata discovery service.
  • Registers desktop shared-process proxies for Workbench and Agents Window.
  • Adds Avalara-style fallback regression coverage.
File Description
src/​vs/​platform/​agentHost/​common/​agentHostMcpOAuthMetadataService.ts Implements metadata discovery.
src/​vs/​platform/​agentHost/​electron-browser/​agentHostMcpOAuthMetadataService.ts Registers the shared-process proxy.
src/​vs/​code/​electron-utility/​sharedProcess/​sharedProcessMain.ts Hosts the metadata service channel.
src/​vs/​workbench/​contrib/​chat/​browser/​agentSessions/​agentHost/​agentHostAuth.ts Uses the new service during authentication.
src/​vs/​workbench/​contrib/​chat/​test/​browser/​agentSessions/​agentHostAuth.test.ts Tests OpenID discovery fallback.
src/​vs/​workbench/​workbench.common.main.ts Registers the web-compatible implementation.
src/​vs/​workbench/​workbench.desktop.main.ts Loads the desktop proxy.
src/​vs/​sessions/​sessions.common.main.ts Registers the Agents Window implementation.
src/​vs/​sessions/​sessions.desktop.main.ts Loads the Agents Window desktop proxy.

🧠 Review effort: Balanced


💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@aeschli

Copy link
Copy Markdown
Contributor Author

Copilot resolve the merge conflicts in this pull request

# Conflicts:
#	src/vs/code/electron-utility/sharedProcess/sharedProcessMain.ts

Co-authored-by: aeschli <[email protected]>

Copilot AI commented Oct 9, 2026

Copy link
Copy Markdown
Contributor

Copilot resolve the merge conflicts in this pull request

Resolved in a1e47d6 by merging latest main, preserving the OAuth metadata service and upstream’s AgentFinder removal. ESLint, whitespace, and secret checks passed. Build/test validation was blocked by dependency-refresh networking and Electron sandbox configuration.

@github-actions

github-actions Bot commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

Base: a7bfc0f6 Current: 3aad82fa

No screenshot changes.

@aeschli
Martin Aeschlimann (aeschli) merged commit 24f518d into main Oct 14, 2026
74 of 77 checks passed
@aeschli
Martin Aeschlimann (aeschli) deleted the aeschli/mcp-auth-button branch October 14, 2026 10:02
@vs-code-engineering vs-code-engineering Bot added this to the 1.143.0 milestone Oct 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

MCP: Authenticate button does nothing when OAuth metadata is blocked by CORS

5 participants