Skip to content

GitHub MCP OAuth authentication fails with HTTP 422 (Dynamic client registration) #6067

Closed

Description

@mameli

Description

When using the GitHub MCP server via the remote MCP endpoint, OAuth authentication fails with an HTTP 422 error during dynamic client registration.

The same configuration works correctly with other MCP servers, so this appears to be specific to the GitHub MCP integration.

Environment

  • OpenCode version: 1.0.193
  • MCP server: GitHub
  • MCP type: remote
  • OS: macOS (likely platform-independent)

Configuration

{
  "$schema": "https://opencode.ai/config.json",
  "mcp": {
    "github": {
      "type": "remote",
      "url": "https://api.githubcopilot.com/mcp/",
      "enabled": true,
      "oauth": {}
    }
  }
}

Expected Behavior
OAuth authentication completes successfully, similar to other MCP servers using the same flow.

Actual Behavior
Authentication fails with the following error:

Authentication failed
Dynamic client registration failed: HTTP 422

OpenCode version

1.0.193

Steps to reproduce

  1. Configure OpenCode with the GitHub MCP server as shown above
  2. Run MCP authentication (via CLI or UI)
  3. Select github when prompted to authenticate

Screenshot and/or share link

Image

Operating System

macos 26.1

Terminal

ghostty

Activity

  1. github-actions commented on Dec 23, 2025

    @github-actions
    Contributor

    This issue might be a duplicate of existing issues. Please check:

    Feel free to ignore if none of these address your specific case.

  2. christso commented on Dec 28, 2025

    @christso
    Contributor

    This is a GitHub limitation, not an OpenCode issue. GitHub's MCP endpoint does not support Dynamic Client Registration (DCR) - it returns HTTP 422 when DCR is attempted.

    According to GitHub's official documentation, only Copilot-integrated IDEs have OAuth support for the remote GitHub MCP server:

    IDE Remote OAuth Support
    VS Code with Copilot ✅ OAuth + PAT
    JetBrains with Copilot ✅ OAuth + PAT
    Claude Code ❌ PAT only
    Cursor ❌ PAT only
    Windsurf ❌ PAT only

    These Copilot IDEs work because they have pre-registered GitHub OAuth Apps with known client_id values. GitHub doesn't support DCR, so any client without a registered OAuth app must use PAT authentication.

    Good news for OpenCode: PR #5940 (from #5766) adds support for configuring clientId and clientSecret in the MCP OAuth config. Once merged, you can use OAuth by:

    1. Registering a GitHub OAuth App
    2. Configuring OpenCode with your OAuth credentials:
    {
      "mcp": {
        "github": {
          "type": "remote",
          "url": "https://api.githubcopilot.com/mcp/",
          "oauth": {
            "clientId": "your-client-id",
            "clientSecret": "your-client-secret"
          }
        }
      }
    }

    This actually puts OpenCode ahead of Claude Code, Cursor, and other non-Copilot IDEs which only support PAT authentication.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions