Skip to content

Migrate MCP servers that use OAuth - #341352

Merged
Vritant Bhardwaj (vritant24) merged 3 commits into
microsoft:mainfrom
vritant24:agents/migrate-oauth-servers-in-mcp-customization
Oct 13, 2026
Merged

Vritant Bhardwaj (vritant24) merged 3 commits into
microsoft:mainfrom
vritant24:agents/migrate-oauth-servers-in-mcp-customization

Conversation

@vritant24

Copy link
Copy Markdown
Member

Part of #340161 (case C10).

The MCP customization migrator now migrates remote servers that use oauth instead of excluding them.

Changes

  • Eligibility: a server with oauth is migratable, except:
    • oauth.enterpriseManaged: true. Enterprise-managed sign-in relies on a VS Code setting that Copilot doesn't have. New exclusion reason EnterpriseManagedOAuth.
    • Servers whose OAuth client has a client secret stored in VS Code (set with Set Client Secret). The Copilot runtime can't read VS Code's secret storage, and the Copilot config has no secret field. New exclusion reason OAuthClientSecret. The secret is checked at planning time and again before writing, using the same key as the code lens.
  • Written config: oauth.clientId is written as oauthClientId. oauth and enterpriseManaged: false are dropped. The planner's comparison against the agent-host projection ignores oauth, since the projection drops it.
  • VS Code's own chat: claudeConfigToServerDefinition (used for workspace .mcp.json and the Copilot user mcp-config.json) reads oauthClientId and a nested oauth.clientId into launch.oauth.clientId, so migrated servers keep using their configured client. The client ID is part of the trust nonce, so Copilot user-config servers that already had one are trusted again once.
  • Migrations view warnings:
    • OAuth servers: "You may need to sign in again after migration."
    • User-scope servers: "VS Code will ask you to trust this server again after migration." Copilot user-config servers are trusted per configuration, and a migrated server is a new definition. .mcp.json collections are always trusted, so workspace migrations don't prompt.
  • Updated the OAuthClientConfigurationIgnored compatibility detail, which said to remove the OAuth configuration in order to migrate.

Sign-in tokens aren't migrated. VS Code's chat and Copilot sessions in VS Code share VS Code's authentication providers. Standalone Copilot CLI users sign in once on first use.

How to test

  1. In .vscode/mcp.json or the user mcp.json, add a remote server with "oauth": { "clientId": "<id>" }.
  2. Open the Chat Customizations editor's Migrations view with the Copilot harness. The server is listed with the sign-in warning, plus the trust warning for user servers.
  3. Migrate it. The destination (.mcp.json or ~/.copilot/mcp-config.json) contains "oauthClientId": "<id>", and the source entry is removed.
  4. Use Set Client Secret on another server's clientId, or set "enterpriseManaged": true. That server is excluded, and its details explain why.

Validation

All commands were run on this branch after rebasing onto main (68343b4619b):

  • npm run typecheck-client: passed
  • npm run build-fast -- --client-only: passed
  • ./scripts/test.sh --reporter dot with --run for every src/vs/workbench/contrib/chat/test/browser/aiCustomization/*.test.ts, plus nativeMcpDiscoveryAdapters.test.ts, workspaceDotMcpDiscovery.test.ts and agentHostAuth.test.ts: passed (828 passing)
  • npm run eslint -- <12 changed files>: passed
  • npm run valid-layers-check: passed

Not verified against a real OAuth server: sign-in with a migrated client ID in the standalone Copilot CLI and in a Copilot session in VS Code.

The MCP customization migrator now migrates remote servers with `oauth`
instead of excluding them, writing `oauth.clientId` as `oauthClientId`.

- Exclude servers with enterprise-managed sign-in, which relies on a VS Code
  setting, and servers whose OAuth client has a client secret stored in VS
  Code, which the destination cannot use. The secret is checked again
  before writing.
- Read `oauthClientId` and `oauth.clientId` from `.mcp.json` and the Copilot
  user configuration. The client ID is part of the trust nonce, so servers
  that already had one are trusted again once.
- Warn that migrated OAuth servers may need to sign in again, and that
  migrated user servers will be trusted again before they start.

Co-authored-by: Copilot <[email protected]>
Copilot AI balanced review requested due to automatic review settings October 13, 2026 18:06

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.

🟡 Changes recommended

Secret detection uses resolved URLs, so OAuth servers with variables can migrate despite having stored client secrets.

1 open finding
What changed in this PR

Enables migration of OAuth-configured MCP servers while preserving client IDs and excluding unsupported secret or enterprise-managed configurations.

Changes:

  • Migrates OAuth client IDs into Copilot configuration.
  • Adds secret-storage and enterprise OAuth eligibility checks.
  • Adds migration warnings, discovery support, and tests.
File Description
aiCustomizationManagementEditor.fixture.ts Adds secret-storage fixture support.
workspaceDotMcpDiscovery.test.ts Tests OAuth discovery.
nativeMcpDiscoveryAdapters.test.ts Tests client-ID parsing.
nativeMcpDiscoveryAdapters.ts Reads flat and nested client IDs.
mcpServerCustomizationMigration.test.ts Tests OAuth migration exclusions.
customizationMigrationServiceImpl.test.ts Supplies test secret storage.
customizationMigration.test.ts Tests migration warnings.
customizationMigrationService.ts Adds OAuth candidate metadata and failures.
mcpServerCustomizationMigration.ts Implements OAuth migration and validation.
customizationMigrationCategories.ts Adds sign-in and trust warnings.
agentHostMcpServerSupportScope.ts Updates OAuth compatibility guidance.
agentHostMcpServerMigrationProvider.ts Injects secret storage and explains exclusions.

🧠 Review effort: Balanced


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

The Set Client Secret code lens keys the secret by the URL as written in the
source, before its variables are resolved. Read the key from the source
entry, at planning time and again before writing, instead of from the
projection, so a server with a variable in its URL is still excluded.

Co-authored-by: Copilot <[email protected]>
…servers-in-mcp-customization

# Conflicts:
#	src/vs/workbench/contrib/chat/browser/agentSessions/agentHost/agentHostMcpServerMigrationProvider.ts
#	src/vs/workbench/contrib/chat/browser/aiCustomization/customizationMigrationCategories.ts
#	src/vs/workbench/contrib/chat/browser/aiCustomization/mcpServerCustomizationMigration.ts
#	src/vs/workbench/contrib/chat/test/browser/aiCustomization/customizationMigration.test.ts
#	src/vs/workbench/contrib/chat/test/browser/aiCustomization/mcpServerCustomizationMigration.test.ts
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.

4 participants