๐Ÿ’ป

How to Set Up GitHub MCP

Connect openclaw to your GitHub repos: read code, search issues, and even open PRsโ€”all via natural language.

Category: Developer Tools
Difficulty: Medium

Overview

The GitHub MCP lets openclaw:

  • Read repository contents and file trees
  • Search issues and pull requests
  • Create issues and PRs (with write scopes)
  • List commits and branches

Prerequisites

  • openclaw installed and running
  • GitHub account
  • Personal Access Token (PAT) with correct scopes
  • Docker (for CLI method) or internet access (for SSE method)

Step 1 โ€” Create a Personal Access Token

  1. Go to GitHub Settings โ†’ Developer settings โ†’ Personal access tokens
  2. Click "Generate new token (classic)"
  3. Select scopes:
    • repo โ€” full repository access
    • read:org โ€” read org membership (if using org repos)
  4. Copy the token immediately (you won't see it again)

Step 2 โ€” Choose Your Config Method

Option A: CLI Server (Docker)

Best for local development. Runs in a container, auto-stops when openclaw exits.

GitHub CLI Config json
{
  "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}"
    }
  }
}
Important: Store GITHUB_TOKEN as an environment variable, not plaintext.

Option B: SSE Server (URL)

Simpler setup, uses GitHub Copilot's hosted MCP endpoint.

GitHub SSE Config json
{
  "GitHub": {
    "url": "https://api.githubcopilot.com/mcp/"
  }
}

This method requires GitHub Copilot subscription for full functionality.

Step 3 โ€” Verify

  1. Run openclaw status โ€” GitHub MCP should show as "running"
  2. Test: "List my recent repositories"
  3. Test: "Search issues in owner/repo with label bug"

Common Errors

ErrorCauseFix
401 Unauthorized Invalid or expired PAT Regenerate token, check expiration
403 Forbidden Missing scopes Add repo and read:org scopes
Docker not found Docker not installed or not running Install Docker Desktop, start daemon
Rate limit exceeded Too many API calls Wait 1 hour or use authenticated requests

Security Notes

  • Use fine-grained PATs when possible (limit to specific repos)
  • Never commit tokens to version control
  • Rotate tokens regularly (every 90 days recommended)
  • For org repos, consider a dedicated bot account

Example Prompts

  • "Show the README of owner/repo"
  • "List open issues in owner/repo labeled 'enhancement'"
  • "Create an issue titled 'Fix login bug' in owner/repo"
  • "Show recent commits on main branch of owner/repo"

Related MCPs