GitHub MCP server

Integrates with GitHub's API to enable repository management, code manipulation, issue tracking, and pull request handling for streamlined development workflows.
Back to servers
Provider
cyanheads
Release date
Mar 15, 2025
Language
TypeScript
Stats
6 stars

The GitHub MCP Server allows LLM agents to interact with GitHub repositories, issues, pull requests, branches, files, and releases through a standardized Model Context Protocol (MCP) interface. It acts as a bridge between AI models and the GitHub API, providing a set of well-defined tools for GitHub operations.

Installation

Prerequisites

  • Node.js (v16 or newer)
  • A GitHub personal access token with appropriate permissions

Setup

  1. Clone the repository:

    git clone https://github.com/cyanheads/github-mcp-server.git
    cd github-mcp-server
    
  2. Install dependencies:

    npm install
    
  3. Create a .env file in the project root with your GitHub token:

    GITHUB_TOKEN=your_github_personal_access_token
    LOG_LEVEL=info
    SERVER_NAME=github-mcp-server
    
  4. Build the project:

    npm run build
    
  5. Start the server:

    node build/index.js
    

Configuration

The server can be configured through environment variables:

Environment Variable Description Default
GITHUB_TOKEN GitHub personal access token (required) -
LOG_LEVEL Logging level (debug, info, warn, error, fatal) info
SERVER_NAME MCP server name github-mcp-server
SERVER_VERSION MCP server version 0.1.0
API_TIMEOUT_MS Timeout for API calls in milliseconds 10000
RATE_LIMITING_ENABLED Whether rate limiting is enabled true
RATE_LIMITING_MIN_REMAINING Minimum remaining requests before throttling 100
RATE_LIMITING_RESET_BUFFER_MS Time buffer to add to rate limit reset time 5000

MCP Client Settings

Add to your MCP client settings:

{
  "mcpServers": {
    "github": {
      "command": "node",
      "args": ["/path/to/github-mcp-server/build/index.js"],
      "env": {
        "GITHUB_TOKEN": "your_github_personal_access_token",
        "LOG_LEVEL": "info",
        "SERVER_NAME": "github-mcp-server"
      }
    }
  }
}

Available Tools

GitHub MCP Server provides tools organized by functionality:

Repository Management Tools

Tool Description
get_repository Get detailed information about a specific repository
Parameters: owner, repo
list_repositories List repositories for the authenticated user
Parameters: type (optional), sort (optional)
create_repository Create a new GitHub repository
Parameters: name, description (optional), private (optional)

Branch Management Tools

Tool Description
list_branches List branches in a repository
Parameters: owner, repo, protected (optional), per_page (optional)
create_branch Create a new branch
Parameters: owner, repo, branch, sha
delete_branch Delete a branch
Parameters: owner, repo, branch

Issue Management Tools

Tool Description
create_issue Create a new issue in a repository
Parameters: owner, repo, title, body (optional), labels (optional)
list_issues List issues in a repository
Parameters: owner, repo, state (optional), labels (optional)

Pull Request Management Tools

Tool Description
create_pull_request Create a new pull request
Parameters: owner, repo, title, head, base, body (optional)
merge_pull_request Merge a pull request
Parameters: owner, repo, pull_number, commit_title (optional), commit_message (optional), merge_method (optional)
update_pull_request Update an existing pull request
Parameters: owner, repo, pull_number, title (optional), body (optional), state (optional), base (optional), maintainer_can_modify (optional)
list_pull_requests List pull requests in a repository
Parameters: owner, repo, state (optional), head (optional), base (optional), sort (optional), direction (optional)

File Management Tools

Tool Description
update_file Create or update a file in a repository
Parameters: owner, repo, path, message, content, sha (optional), branch (optional)

Release Management Tools

Tool Description
create_release Create a new release
Parameters: owner, repo, tag_name, name (optional), body (optional), draft (optional), prerelease (optional)

Error Handling

The server implements comprehensive error handling with:

  • Standardized error objects with consistent formatting
  • Input validation using Zod schemas
  • Automatic handling of GitHub API rate limits
  • Categorized errors (network, authentication, validation, GitHub API, system)
  • Detailed structured logging

How to add this MCP server to 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 > MCP and click "Add new global MCP server".

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

{
    "mcpServers": {
        "cursor-rules-mcp": {
            "command": "npx",
            "args": [
                "-y",
                "cursor-rules-mcp"
            ]
        }
    }
}

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 explictly ask the agent to use the tool by mentioning the tool name and describing what the function does.

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