Skip to content

Copilot CLI ignores oauth.clientId in mcp-config.json, always uses Dynamic Client Registration (DCR) #2717

@skg-marimuthu

Description

@skg-marimuthu

Describe the bug

Copilot CLI ignores the oauth.clientId configured in ~/.copilot/mcp-config.json for remote HTTP MCP servers. Instead, it always performs Dynamic Client Registration (DCR) and uses a server-assigned client ID, even when a static clientId is explicitly provided.

Affected version

GitHub Copilot CLI 1.0.26

Steps to reproduce the behavior

  1. Configure remote HTTP MCP servers in ~/.copilot/mcp-config.json with an explicit oauth.clientId:
{
  "mcpServers": {
    "WorkIQ-Calendar-MCP-Server": {
      "url": "https://agent365.svc.cloud.microsoft/.../mcp_CalendarTools",
      "type": "http",
      "oauth": {
        "clientId": "ba081686-5d24-4bc6-a0d6-d034ecffed87",
        "callbackPort": 8080
      }
    }
  }
}
  1. Clear any cached OAuth state: Remove-Item ~/.copilot/mcp-oauth-config/* -Force
  2. Start Copilot CLI: copilot
  3. Observe the browser OAuth redirect URL — the client_id parameter is a DCR-assigned ID (aebc6443-996d-45c2-90f0-388ff96faa56), not the configured one (ba081686-...)
  4. Inspect cached OAuth state in ~/.copilot/mcp-oauth-config/ — all entries show "isStatic": false and the DCR-assigned client ID

Expected behavior

When oauth.clientId is explicitly set in the MCP server config, the CLI should use that static client ID for the OAuth flow instead of performing Dynamic Client Registration (DCR).

This is important because:

  • Organizations may have pre-registered OAuth applications with specific client IDs
  • The DCR-assigned client ID may not have the correct permissions or consent grants
  • Admin consent is typically granted to a specific client ID, not a dynamically registered one

Additional context

Browser redirect URL (showing wrong client_id):

https://login.microsoftonline.com/organizations/oauth2/v2.0/authorize?...&client_id=aebc6443-996d-45c2-90f0-388ff96faa56&...

Cached OAuth state (showing DCR was used):

{
  "clientId": "aebc6443-996d-45c2-90f0-388ff96faa56",
  "isStatic": false
}

Related issues:

Proposed fix: When oauth.clientId is present in the server config, skip DCR and use the provided client ID directly with "isStatic": true. The oauth.callbackPort should also be respected to avoid the random port issue described in #1491.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions