Dev Tools·
intermediate
·8 min read·Apr 4, 2026·Updated Oct 10, 2026
By Rad Tome·Lead AI Systems Architect·How we verify this

GitHub MCP Server Setup for Codex & Claude | Complete 2026 Guide

Connect GitHub to OpenAI Codex & Claude Desktop in 5 minutes. Full config.toml, PAT authentication, tool reference (create_issue, create_pr, search_repos), and troubleshooting. Verified working.

MCPGitHubCodexClaudesetupPATtoolsauthentication
Config Target: claude_desktop_config.json
{
  "mcpServers": {
    "github": {
      "command": "npx",
      "args": [
        "-y",
        "@modelcontextprotocol/server-github"
      ],
      "env": {
        "GITHUB_PERSONAL_ACCESS_TOKEN": "ghp_xxxxxxxxxxxxxxxxxxxx"
      }
    }
  }
}
Interactive Tool
1-Click Export

Generate & Test GitHub MCP Server Config

One-click export with environment variables & path locators for Claude Desktop, Cursor, Windsurf, and OpenAI Codex CLI.

Open in Generator

GitHub MCP Server Setup and Configuration Guide

The official GitHub Model Context Protocol (MCP) server enables AI agents—including Claude Desktop, Cursor, Windsurf, and OpenAI Codex CLI—to interact directly with your GitHub repositories. Once configured, your AI assistant can review code, create pull requests, search across codebases, triage issues, and automate complex workflows using standardized tool calls.

This guide walks you through generating a fine-grained Personal Access Token (PAT), configuring your client of choice, and troubleshooting permissions and SAML SSO hurdles.


Prerequisites

  • ▸An active GitHub account.
  • ▸A GitHub Personal Access Token (PAT) with repository permissions.
  • ▸Node.js 18+ installed on your system (verify with node -v).

Step 1: Create a Fine-Grained Personal Access Token

We strongly recommend using Fine-Grained Personal Access Tokens instead of classic tokens to adhere to the principle of least privilege.

  1. ▸Navigate to GitHub Settings → Developer Settings → Personal Access Tokens → Fine-grained tokens (opens in a new tab).
  2. ▸Click Generate new token.
  3. ▸Fill in the token details:
    • ▸Token name: mcp-github-server
    • ▸Expiration: Choose 30, 60, or 90 days (never select "No expiration" in enterprise environments).
    • ▸Repository access: Choose Only select repositories and pick the repositories your agent will work on.
  4. ▸Set Repository Permissions:
    • ▸Contents: Read and write (for reading code, creating commits, and creating branches)
    • ▸Pull requests: Read and write (for drafting and reviewing PRs)
    • ▸Issues: Read and write (for listing and creating issues)
    • ▸Metadata: Read-only (selected automatically)
  5. ▸Click Generate token and copy the token string (github_pat_...) immediately.

Step 2: Configure Your AI Client

Select your host environment below to copy the exact configuration template.

Claude Desktop (claude_desktop_config.json)

File path:

  • ▸macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
  • ▸Windows: %APPDATA%\Claude\claude_desktop_config.json
json
{
  "mcpServers": {
    "github": {
      "command": "npx",
      "args": ["-y", "@modelcontextprotocol/server-github"],
      "env": {
        "GITHUB_PERSONAL_ACCESS_TOKEN": "github_pat_your_token_here"
      }
    }
  }
}

Cursor IDE (~/.cursor/mcp.json)

File path:

  • ▸macOS/Linux: ~/.cursor/mcp.json
  • ▸Windows: %USERPROFILE%\.cursor\mcp.json
json
{
  "mcpServers": {
    "github": {
      "command": "npx",
      "args": ["-y", "@modelcontextprotocol/server-github"],
      "env": {
        "GITHUB_PERSONAL_ACCESS_TOKEN": "github_pat_your_token_here"
      }
    }
  }
}

OpenAI Codex CLI (~/.codex/config.toml)

File path:

  • ▸macOS/Linux: ~/.codex/config.toml
  • ▸Windows: %USERPROFILE%\.codex\config.toml
toml
[mcp_servers.github]
command = "npx"
args = ["-y", "@modelcontextprotocol/server-github"]

  [mcp_servers.github.env]
  GITHUB_PERSONAL_ACCESS_TOKEN = "github_pat_your_token_here"

Or add it in one terminal command:

bash
codex mcp add --name github --command "npx -y @modelcontextprotocol/server-github" --env GITHUB_PERSONAL_ACCESS_TOKEN=github_pat_your_token_here

Windsurf / Cascade (~/.codeium/windsurf/mcp_config.json)

json
{
  "mcpServers": {
    "github": {
      "command": "npx",
      "args": ["-y", "@modelcontextprotocol/server-github"],
      "env": {
        "GITHUB_PERSONAL_ACCESS_TOKEN": "github_pat_your_token_here"
      }
    }
  }
}

Step 3: Verify the Connection

  1. ▸Save your configuration file and restart your AI client (or run codex mcp restart github in Codex CLI).
  2. ▸Open a chat session with your AI agent and prompt:

    "Use the GitHub tool to search for open pull requests in my repository <owner>/<repo>."

  3. ▸The client will trigger the search_repositories or list_pull_requests tool. If prompted, confirm execution.

Available GitHub Tools Reference

The GitHub MCP server provides 20+ specialized tools:

CategoryToolsCapabilities
Repositoriessearch_repositories, get_file_contents, create_or_update_file, push_filesSearch code, read repository trees, push multi-file commits
Branchescreate_branch, list_commitsCreate release branches and inspect git history
Issuescreate_issue, list_issues, update_issue, add_issue_commentAutomate issue triage and bug tracking
Pull Requestscreate_pull_request, list_pull_requests, get_pull_request_diff, merge_pull_requestAutomated PR creation, diff reviews, and merging

Troubleshooting Common Issues

1. 403 Forbidden / SAML SSO Enforcement

  • ▸Symptom: API requests return 403 Resource not accessible by personal access token or SAML error.
  • ▸Fix: If your organization uses Single Sign-On (SAML SSO), you must authorize your token. Go to Personal access tokens in GitHub, find your token, click Configure SSO, and click Authorize next to your organization name.

2. 404 Not Found When Querying Repositories

  • ▸Symptom: Agent reports repository does not exist.
  • ▸Fix: Verify you provided both the repository owner and name in format <owner>/<repo>. Also ensure the fine-grained PAT includes access to that specific repository under "Selected Repositories".

3. Rate Limit Exceeded

  • ▸Symptom: 403 API rate limit exceeded.
  • ▸Fix: Personal Access Tokens are granted 5,000 requests per hour. For high-frequency CI/CD agents, consider authenticating via a GitHub App instead of a PAT.

Interactive Links & Tools

Technical Changelog

Weekly Protocol Diffs & Verified Drops

New server guides, benchmarks, and security audits. No spam. Unsubscribe anytime.

Zero marketing spam. 1-click unsubscribe anytime.

Ready to Deploy?

Build your full agent toolstack in the Visual Generator

Combine GitHub with databases, search APIs, and memory graphs in a single configuration file.

Customize in Generator
Developer Verification & Feedback
0 reports

Did this setup guide work with your AI host?

Help test this configuration across Claude, Cursor, and Codex CLI. Be the first to report:

GitHub MCP Server Setup for Codex & Claude | Complete 2026 Guide FAQ

What is the GitHub MCP Server Setup for Codex & Claude | Complete 2026 Guide?

Connect GitHub to OpenAI Codex & Claude Desktop in 5 minutes. Full config.toml, PAT authentication, tool reference (create_issue, create_pr, search_repos), and troubleshooting. Verified working.

How do I configure GitHub MCP Server Setup for Codex & Claude | Complete 2026 Guide in Claude Desktop or Cursor?

You can copy the configuration JSON from our guide or launch the interactive MCP Codex Config Generator at https://mcp-codex.com/generator to export valid configs in 1 click.

Can I use GitHub MCP Server Setup for Codex & Claude | Complete 2026 Guide with the OpenAI Codex CLI?

Yes, OpenAI Codex CLI supports Model Context Protocol. You can add it directly to ~/.codex/config.toml or pass arguments to codex mcp add.

RT

Written by Rad Tome

Lead AI Systems Architect & Maintainer, MCP Codex

@RadTome

Specializing in Model Context Protocol (MCP) integrations, autonomous AI agent orchestration, and distributed developer toolchains. Researches and benchmarks production MCP client-server architectures across OpenAI Codex, Claude, and Cursor.

Editorial Integrity: Package names are checked against the npm registry and repositories against the GitHub API. Where a package could not be verified, the guide says so instead of giving you a command to run.

Related Guides