Dev ToolsΒ·
intermediate
Β·13 min readΒ·Apr 4, 2026

How to Set Up the GitHub MCP Server for Repository Management

Connect your AI agent to GitHub repositories. Create issues, manage pull requests, search code, and automate repository workflows through MCP.

GitHubgitrepositoriesautomationdeveloper tools
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

Set Up the GitHub MCP Server

The GitHub MCP server provides comprehensive access to GitHub's REST API. It transforms your AI agent into an automated project manager and code reviewer capable of managing repositories, triaging issues, and drafting pull requests.

Prerequisites

  • β–ΈA GitHub account.
  • β–ΈA GitHub Personal Access Token (PAT).
  • β–ΈNode.js 18+ installed locally.

Creating a Fine-Grained Personal Access Token

It is strongly recommended to use Fine-Grained Tokens rather than Classic Tokens for security.

  1. β–ΈGo to GitHub Settings β†’ Developer Settings β†’ Personal Access Tokens β†’ Fine-grained tokens.
  2. β–ΈClick Generate new token.
  3. β–ΈSet the Repository access to "Only select repositories".
  4. β–ΈAssign the following Permissions:
    • β–ΈContents (Read/Write)
    • β–ΈIssues (Read/Write)
    • β–ΈPull Requests (Read/Write)
  5. β–ΈGenerate the token and copy it immediately.

Configuration Setup

Add the following to your MCP client config:

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

Available Tools

The GitHub server exposes a massive suite of tools to the agent:

Repository Operations

  • β–Έcreate_repository / search_repositories / get_file_contents / push_files / create_branch

Issue Management

  • β–Έcreate_issue / list_issues / update_issue / add_issue_comment

Pull Request Operations

  • β–Έcreate_pull_request / list_pull_requests / merge_pull_request / get_pull_request_diff

Example Workflows

  • β–ΈCode Review Assistant: "Review the latest pull request on my-org/my-repo, look for security vulnerabilities, and add a comment on the issue with your findings."
  • β–ΈIssue Triage: "List all open issues labeled 'bug' in my-repo and categorize them by severity based on the user descriptions."
  • β–ΈRepository Analysis: "Analyze the codebase structure of my-org/my-repo and create a README.md outline."

Troubleshooting

  • β–Έ403 Forbidden / SAML SSO: If your organization enforces SAML Single Sign-On, your PAT will be rejected by the API unless you explicitly authorize the token for use with that specific organization in the GitHub UI.
  • β–Έ404 Not Found: This almost always means your token lacks the correct permissions to view the repository, or the repository name is misspelled. Remember that repos must be prefixed with their owner (owner-name/repo-name).
  • β–ΈToken Expiry: Fine-grained tokens have a maximum lifespan of 1 year. If your agent suddenly loses access, verify your PAT hasn't expired.

Using with OpenAI Codex

You can use this MCP server with the OpenAI Codex CLI by adding it to your configuration:

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

For a full list of recommended servers, see Best MCP Servers for OpenAI Codex.

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

Related Guides