Skip to content

Preserve static MCP OAuth client id in agent host - #328347

Draft
jruales wants to merge 1 commit into
mainfrom
jruales/mcp-oauth-client-id
Draft

Preserve static MCP OAuth client id in agent host#328347
jruales wants to merge 1 commit into
mainfrom
jruales/mcp-oauth-client-id

Conversation

@jruales

@jruales jruales commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

Authored by Copilot.

toSdkMcpServer rebuilt HTTP MCP server configs from only type, url, tools and headers, dropping the configured oauth.clientId. MCP servers that cannot use dynamic client registration then fail to authenticate.

Forwards the client id as oauthClientId and lets the runtime apply its documented public-client default. Also fixes the static client mapping in CopilotAgentSession so a clientSecret wins, an omitted publicClient stays public, and publicClient: false without a secret no longer yields a partial client config.

Repro

  1. Configure a remote MCP server that requires a pre-registered OAuth client and does not support dynamic client registration, e.g. in a plugin .mcp.json:
    { "servers": { "slack": { "type": "http", "url": "https://mcp.slack.com/mcp", "oauth": { "clientId": "<client-id>" } } } }
  2. Start an agent session so the agent host launches the server.
  3. Trigger authentication for that server.

Before: auth fails with Failed to create MCP auth provider for https://mcp.slack.com/ User did not provide client details because the client id never reaches the SDK.
After: the configured client id is forwarded and the auth provider is created.

Validation

  • ./scripts/test.sh --run src/vs/platform/agentHost/test/node/copilotPluginConverters.test.ts (38 passing, incl. new OAuth conversion test)
  • ./scripts/test.sh --run src/vs/platform/agentHost/test/node/copilotAgentSession.test.ts --grep 'impersonating the GitHub MCP name'
  • npm run compile, hygiene, diagnostics clean

`toSdkMcpServer` rebuilt HTTP MCP server configurations from only `type`,
`url`, `tools` and `headers`, silently dropping the configured
`oauth.clientId`. Servers that cannot use dynamic client registration
(e.g. Slack) then failed to authenticate with "User did not provide
client details".

Forward the configured client id as `oauthClientId` and let the runtime
apply its documented public-client default, so an explicitly configured
confidential client is not misclassified as public.

Also fix the static client mapping in `CopilotAgentSession` so a provided
`clientSecret` takes priority, an omitted `publicClient` keeps the
documented public default, and `publicClient: false` without a secret no
longer produces a partial client configuration.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings July 31, 2026 03:54

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.

Pull request overview

Preserves static OAuth client IDs when converting MCP server configurations and correctly maps public versus confidential OAuth clients.

Changes:

  • Forward oauth.clientId to the Copilot SDK.
  • Prioritize client secrets while defaulting omitted publicClient to public.
  • Update OAuth conversion and authentication tests.
Show a summary per file
File Description
copilotPluginConverters.ts Forwards OAuth client IDs.
copilotAgentSession.ts Corrects static OAuth client mapping.
copilotPluginConverters.test.ts Tests OAuth configuration conversion.
copilotAgentSession.test.ts Tests the default public-client behavior.

Review details

  • Files reviewed: 4/4 changed files
  • Comments generated: 1
  • Review effort level: Balanced

Comment on lines +1765 to +1767
const oauthClient: McpAuthRequirement['oauthClient'] = request.staticClientConfig?.clientSecret
? { clientId: request.staticClientConfig.clientId, clientSecret: request.staticClientConfig.clientSecret }
: request.staticClientConfig && request.staticClientConfig.publicClient !== false
@jruales
jruales marked this pull request as draft July 31, 2026 03:59
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.

2 participants