published fresh until

OpenCode can't connect to GitHub's MCP server: how do I set up OAuth?

Summary As of November 2026, a token header or pre-registered OAuth app are options for the GitHub MCP registration error. OpenCode V2 nests servers under mcp.servers; its OAuth credential fields are client_id and client_secret

Not for GitHub Copilot Enterprise model-provider login; see opencode-github-enterprise-login

For your agent
claude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp

Read-only, no account. Sign-in is only for trial reports: /connect.md

What this thread does

As of November 2026, use a token header or a pre-registered OAuth app. Do first: use the V2 configuration names: mcp.servers, client_id and client_secret; the issue’s camelCase example is from V1.

The problem

OpenCode listed the remote GitHub MCP server but the agent had no GitHub tools. The GitHub issue (opened 2025-11-12 by ThomasCode92) was closed on 2026-02-14.

Cause 1: a typo in the environment reference

The reporter wrote Bearer ${env:GITHUB_MCP_PATH} in the Authorization header. A commenter noticed OpenCode's syntax is {env:NAME} with no dollar sign, and that it worked after correcting the reference. OpenCode's MCP docs use the {env:...} form. Also make sure the variable is actually set in the shell that starts OpenCode, and that the braces hold the variable's name and not the token itself: another commenter's header failed as "badly formatted" because they had written the token inside {env:...}, and was told to put the variable name there and define the variable in their profile. Commenters also noted that opencode mcp debug can still print the dynamic registration error while the TUI connection succeeds.

Cause 2: OAuth without dynamic client registration

Commenters who tried OpenCode's OAuth flow got "Incompatible auth server: does not support dynamic client registration". A GitHub maintainer (2026-02-13) said GitHub does not plan to support dynamic client registration and is only looking at client ID metadata documents with no guarantee. Per the maintainer, the spec says clients should then fall back to a client id and secret, so you create your own GitHub OAuth app and give it to the client.

Two ways to connect

A. Token in a header. Several commenters confirmed a remote server entry with "headers": {"Authorization": "Bearer {env:YOUR_TOKEN_VAR}"}, with your personal access token held in an environment variable, not typed into the file. OpenCode's remote-server docs show "oauth": false for header authentication; in V2 put the named server under mcp.servers.

B. Pre-registered OAuth. The maintainer’s V1 example used clientId and clientSecret. The current V2 docs use oauth.client_id and oauth.client_secret, with the same {env:NAME} substitution and optional scope. Run opencode mcp auth <server-name> or select the server in /mcps. Create the OAuth app yourself in GitHub and keep the secret out of the repo.

Questions the maintainer answered

  • The maintainer suggested an app identity per user or shared within an internal team; an organization or enterprise may require app installation for repository access.
  • Why prefer OAuth to a token: the token is protected during exchange and held by the client, not exposed in the environment. This is the maintainer's reasoning.

Caveats

The maintainer closed it saying only documentation work remained, and nobody in the thread confirmed route B end to end after the maintainer's reply. The separate "GitHub MCP server v2" thread covers the server's features, not this login step.

Sources

  • GitHub issue 1396: environment-reference correction and the February 2026 maintainer OAuth explanation.
  • OpenCode MCP docs: V2 server nesting, snake_case OAuth fields, header authentication and sign-in commands.
  • GitHub host integration guide: no dynamic client registration; OAuth app or GitHub App registration and organization restrictions.

Started from a post by @ThomasCode92, packaged by the editor. Original post

Subjects

More in agent workflows

For agents

Copy a short instruction for an agent that has WhatWorks connected, or open this page as Markdown.

# OpenCode can't connect to GitHub's MCP server: how do I set up OAuth?
Summary: As of November 2026, a token header or pre-registered OAuth app are options for the GitHub MCP registration error. OpenCode V2 nests servers under `mcp.servers`; its OAuth credential fields are `client_id` and `client_secret`
Copy for agent
get the whatworks thread github-mcp-server-opencode-oauth-connect and help me try it

Follow this thread

Following tells you when the verdict changes, a new version ships or a new option is added. Your agent mentions it the next time you ask WhatWorks.

Sign in with GitHub to follow. Nothing is posted for you.

Sign in with GitHub

Or ask your agent
follow the whatworks thread github-mcp-server-opencode-oauth-connect
WhatWorks

Connect your agent MCP

Paste this into your agent

Connect me to WhatWorks: add https://whatworks.dev/mcp/login and sign me in so I have an account. Steps: https://whatworks.dev/connect.md.

Or run this in your terminal
  • Claude Codeclaude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp/login && claude mcp login whatworks
  • Codexcodex mcp add whatworks --url https://whatworks.dev/mcp/login && codex mcp login whatworks