MCP Setup Guide · GitHub

How to Set Up GitHub MCP with OpenClaw

GitHub MCP is powerful because it touches source code, issues, and pull requests. Make the token boundary explicit before you let OpenClaw use it.

Last reviewed: 2026-04. Verify against the latest OpenClaw and GitHub MCP docs before production use.

Who this is for / not for

Good fit

  • You want OpenClaw to read repos, inspect issues, or prepare PRs.
  • You can create a limited token or use hosted OAuth.
  • You need help with 401, 403, Docker, or OAuth setup errors.

Not a fit

  • Bypassing GitHub OAuth, SSO, or organization policy.
  • Granting broad write access before testing read-only flows.
  • Pasting raw tokens into configs, screenshots, logs, or review requests.

Before you paste this config

Use a fine-grained token where possible. Start read-only, limit it to specific repositories, and store it as an environment variable. Do not put API keys, PATs, OAuth codes, cookies, or private keys in the config.

Minimal local config

This Docker-based setup keeps the secret in GITHUB_TOKEN and passes it to the container as GITHUB_PERSONAL_ACCESS_TOKEN. Replace only the local environment variable value, never the config with a real token.

Minimal GitHub MCP config json
{
  "mcpServers": {
    "github": {
      "command": "docker",
      "args": [
        "run",
        "-i",
        "--rm",
        "-e",
        "GITHUB_PERSONAL_ACCESS_TOKEN",
        "ghcr.io/github/github-mcp-server"
      ],
      "env": {
        "GITHUB_PERSONAL_ACCESS_TOKEN": "${GITHUB_TOKEN}"
      }
    }
  }
}

Hosted OAuth option

If you use a hosted GitHub MCP endpoint, keep OAuth in the provider flow and do not create local PATs just to bypass auth. Hosted access may require GitHub Copilot or organization approval.

Hosted GitHub MCP config json
{
  "mcpServers": {
    "github": {
      "url": "https://api.githubcopilot.com/mcp/"
    }
  }
}

Verify setup

First verify Docker and the image outside OpenClaw, then check whether OpenClaw can see the configured server.

Verify MCP server bash
# macOS/Linux example. Set the token in your shell, not in the config file.
export GITHUB_TOKEN="paste-a-sanitized-test-token-only-in-your-local-shell"
docker run --rm -e GITHUB_PERSONAL_ACCESS_TOKEN ghcr.io/github/github-mcp-server --help
openclaw status

Expected result: Docker can start the GitHub MCP image, and OpenClaw lists the GitHub server. Then test with a read-only prompt like "List my repositories" before attempting writes.

Common errors

401 Unauthorized

Symptom: GitHub responds but rejects every request. Cause: expired, revoked, mistyped, or missing token. Fix: regenerate the token, confirm the env var name matches GITHUB_TOKEN, and never paste the raw token into a review request.

403 Forbidden

Symptom: some repos or org resources are invisible. Cause: token scopes, fine-grained repo access, SSO approval, or org policy. Fix: narrow the repo list intentionally, then grant the minimum read/write scopes needed.

OAuth failed

Symptom: hosted auth opens but does not complete. Cause: wrong account, missing Copilot access, blocked callback, or organization OAuth policy. Fix: verify the hosted GitHub MCP docs and include only the sanitized auth error if asking for review.

Docker not found / server failed to start

Symptom: OpenClaw cannot launch the local GitHub server. Cause: Docker Desktop is not installed, daemon is stopped, or the image cannot be pulled. Fix: run docker ps and pull the image before debugging OpenClaw config.

invalid JSON

Symptom: the GitHub server never starts and OpenClaw reports a parser error. Cause: missing mcpServers wrapper, bad escaping around ${GITHUB_TOKEN}, or trailing commas. Fix: validate the JSON block before changing token scopes.

When to ask for review

Ask for review when the token is removed from the config, Docker works independently, and the remaining failure is unclear: JSON shape, env var injection, GitHub scopes, hosted OAuth, or OpenClaw config location.

Security notes

Related MCPs