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

Closed
opened 2026-02-16 17:41:32 -05:00 by yindo · 2 comments
Owner

Originally created by @mameli on GitHub (Dec 23, 2025).

Originally assigned to: @rekram1-node on GitHub.

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

Originally created by @mameli on GitHub (Dec 23, 2025). Originally assigned to: @rekram1-node on GitHub. ### 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** ```json { "$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 <img width="714" height="206" alt="Image" src="https://github.com/user-attachments/assets/40a8e6f7-c47a-4a11-96f8-122ac1b885e6" /> ### Operating System macos 26.1 ### Terminal ghostty
yindo added the bug label 2026-02-16 17:41:32 -05:00
yindo closed this issue 2026-02-16 17:41:32 -05:00
Author
Owner

@github-actions[bot] commented on GitHub (Dec 23, 2025):

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

  • #5716: Is github mcp serve with oauth supposed to be working? (same HTTP 422 error with GitHub MCP OAuth)
  • #5766: bug: OAuth uses wrong authorization URL and missing redirectUri config (related OAuth issues with MCP)
  • #5444: MCP with oauth doesn't work (related MCP OAuth failures)

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

@github-actions[bot] commented on GitHub (Dec 23, 2025): This issue might be a duplicate of existing issues. Please check: - #5716: Is github mcp serve with oauth supposed to be working? (same HTTP 422 error with GitHub MCP OAuth) - #5766: bug: OAuth uses wrong authorization URL and missing redirectUri config (related OAuth issues with MCP) - #5444: MCP with oauth doesn't work (related MCP OAuth failures) Feel free to ignore if none of these address your specific case.
Author
Owner

@christso commented on GitHub (Dec 27, 2025):

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.

@christso commented on GitHub (Dec 27, 2025): 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](https://github.com/github/github-mcp-server/blob/main/docs/installation-guides/README.md), 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](https://github.com/settings/developers) 2. Configuring OpenCode with your OAuth credentials: ```json { "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 in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#3803