GitHub MCP server

Integrates with GitHub APIs to enable repository searching, issue management, pull request creation, and settings control directly within Claude Desktop conversations, eliminating the need to switch to the GitHub web interface.
Back to servers
Setup instructions
Provider
Nick Martinez
Release date
Mar 22, 2025
Language
Python
Stats
1 star

This MCP server provides tools for interacting with GitHub APIs through Claude Desktop, allowing you to manage repositories, issues, pull requests, and more without leaving your Claude environment.

Installation

Prerequisites

You'll need a GitHub account and a personal access token before setting up the MCP server.

Setup Steps

  1. Clone the repository:

    git clone https://github.com/yourusername/github-mcp.git
    cd github-mcp
    
  2. Create and activate a virtual environment:

    # On macOS/Linux
    python -m venv venv
    source venv/bin/activate
    
    # On Windows
    python -m venv venv
    .\venv\Scripts\activate
    
  3. Install dependencies:

    pip install -r requirements.txt
    
  4. Create a .env file in the project root:

    touch .env
    
  5. Add your GitHub credentials to the .env file:

    GITHUB_TOKEN=your_personal_access_token_here
    GITHUB_USERNAME=your_github_username
    
  6. Start the MCP server:

    python run.py
    

Setting Up GitHub Personal Access Token

To use this MCP server, you'll need a fine-grained personal access token:

  1. Log in to your GitHub account
  2. Go to Settings > Developer settings > Personal access tokens > Fine-grained tokens
  3. Click "Generate new token"
  4. Configure the token:
    • Token name: "Claude Desktop Integration"
    • Description: "Token for Claude Desktop GitHub integration"
    • Expiration: Choose an appropriate expiration date
    • Repository access: Select "All repositories" or specific repositories
    • Permissions:
      • Repository permissions:
        • Actions: Read and write
        • Contents: Read and write
        • Issues: Read and write
        • Pull requests: Read and write
        • Repository hooks: Read and write
        • Repository settings: Read and write
      • Organization permissions (if working with organization repositories):
        • Members: Read-only
        • Teams: Read-only
  5. Save the generated token securely and add it to your .env file

Available Tools

Search Repositories

Search for GitHub repositories using various criteria.

Parameters:

  • query: Search query string
  • sort: Sort field (stars, forks, updated, etc.)
  • order: Sort order (asc or desc)
  • max_results: Maximum number of results to return (default: 10)

Create Issue

Create a new GitHub issue in a specified repository.

Parameters:

  • owner: Repository owner
  • repo: Repository name
  • title: Issue title
  • body: Issue description
  • labels: List of labels to apply
  • assignees: List of assignee usernames

Create Pull Request

Create a new pull request.

Parameters:

  • owner: Repository owner
  • repo: Repository name
  • title: PR title
  • body: PR description
  • head: Source branch
  • base: Target branch
  • draft: Whether to create as draft PR

Manage Repository Settings

Update repository settings and configurations.

Parameters:

  • owner: Repository owner
  • repo: Repository name
  • settings: Dictionary of settings to update

Search Issues

Search for issues across repositories.

Parameters:

  • query: Search query string
  • state: Issue state (open, closed, all)
  • sort: Sort field
  • order: Sort order
  • max_results: Maximum number of results

Manage Workflows

Manage GitHub Actions workflows.

Parameters:

  • owner: Repository owner
  • repo: Repository name
  • workflow_file: Workflow file path
  • action: Action to perform (enable, disable, trigger)

Manage Collaborators

Manage repository collaborators.

Parameters:

  • owner: Repository owner
  • repo: Repository name
  • username: Collaborator username
  • permission: Permission level (pull, push, admin, maintain, triage)

Usage Examples

Here are examples of how to use the MCP tools in your code:

# Search for repositories
search_repos(query="python web framework", sort="stars", max_results=5)

# Create a new issue
create_issue(
    owner="username",
    repo="repository",
    title="Bug: Login not working",
    body="Users cannot log in using the login button",
    labels=["bug", "high-priority"]
)

# Create a pull request
create_pull_request(
    owner="username",
    repo="repository",
    title="Feature: Add user authentication",
    body="Implements JWT-based authentication",
    head="feature/auth",
    base="main"
)

# Search for issues
search_issues(query="is:open is:issue author:username", max_results=10)

# Manage repository settings
manage_repo_settings(
    owner="username",
    repo="repository",
    settings={
        "has_issues": True,
        "has_projects": True,
        "has_wiki": True
    }
)

How to install this MCP server

For Claude Code

To add this MCP server to Claude Code, run this command in your terminal:

claude mcp add-json "github" '{"command":"python","args":["run.py"]}'

See the official Claude Code MCP documentation for more details.

For Cursor

There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json file so that it is available in all of your projects.

If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json file.

Adding an MCP server to Cursor globally

To add a global MCP server go to Cursor Settings > Tools & Integrations and click "New MCP Server".

When you click that button the ~/.cursor/mcp.json file will be opened and you can add your server like this:

{
    "mcpServers": {
        "github": {
            "command": "python",
            "args": [
                "run.py"
            ]
        }
    }
}

Adding an MCP server to a project

To add an MCP server to a project you can create a new .cursor/mcp.json file or add it to the existing one. This will look exactly the same as the global MCP server example above.

How to use the MCP server

Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.

The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.

You can also explicitly ask the agent to use the tool by mentioning the tool name and describing what the function does.

For Claude Desktop

To add this MCP server to Claude Desktop:

1. Find your configuration file:

  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
  • Windows: %APPDATA%\Claude\claude_desktop_config.json
  • Linux: ~/.config/Claude/claude_desktop_config.json

2. Add this to your configuration file:

{
    "mcpServers": {
        "github": {
            "command": "python",
            "args": [
                "run.py"
            ]
        }
    }
}

3. Restart Claude Desktop for the changes to take effect

Want to 10x your AI skills?

Get a free account and learn to code + market your apps using AI (with or without vibes!).

Nah, maybe later