Preserve static MCP OAuth client id in agent host - #328347
Draft
jruales wants to merge 1 commit into
Draft
Conversation
`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>
Contributor
There was a problem hiding this comment.
Pull request overview
Preserves static OAuth client IDs when converting MCP server configurations and correctly maps public versus confidential OAuth clients.
Changes:
- Forward
oauth.clientIdto the Copilot SDK. - Prioritize client secrets while defaulting omitted
publicClientto 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
marked this pull request as draft
July 31, 2026 03:59
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Authored by Copilot.
toSdkMcpServerrebuilt HTTP MCP server configs from onlytype,url,toolsandheaders, dropping the configuredoauth.clientId. MCP servers that cannot use dynamic client registration then fail to authenticate.Forwards the client id as
oauthClientIdand lets the runtime apply its documented public-client default. Also fixes the static client mapping inCopilotAgentSessionso aclientSecretwins, an omittedpublicClientstays public, andpublicClient: falsewithout a secret no longer yields a partial client config.Repro
.mcp.json:{ "servers": { "slack": { "type": "http", "url": "https://mcp.slack.com/mcp", "oauth": { "clientId": "<client-id>" } } } }Before: auth fails with
Failed to create MCP auth provider for https://mcp.slack.com/ User did not provide client detailsbecause 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