GitHub - github/github-mcp-server: GitHub's official MCP Server (original) (raw)

GitHub MCP Server

The GitHub MCP Server is a Model Context Protocol (MCP)server that provides seamless integration with GitHub APIs, enabling advanced automation and interaction capabilities for developers and tools.

Use Cases


Remote GitHub MCP Server

Install in VS Code Install in VS Code Insiders

The remote GitHub MCP Server is hosted by GitHub and provides the easiest method for getting up and running. If your MCP host does not support remote MCP servers, don't worry! You can use the local version of the GitHub MCP Server instead.

Prerequisites

  1. An MCP host that supports the latest MCP specification and remote servers, such as VS Code.

Installation

Usage with VS Code

For quick installation, use one of the one-click install buttons above. Once you complete that flow, toggle Agent mode (located by the Copilot Chat text input) and the server will start. Make sure you're using VS Code 1.101 or later for remote MCP and OAuth support.

Alternatively, to manually configure VS Code, choose the appropriate JSON block from the examples below and add it to your host configuration:

Using OAuth Using a GitHub PAT
VS Code (version 1.101 or greater)
{ "servers": { "github-remote": { "type": "http", "url": "https://api.githubcopilot.com/mcp/" } } } { "servers": { "github-remote": { "type": "http", "url": "https://api.githubcopilot.com/mcp/", "headers": { "Authorization": "Bearer ${input:github_mcp_pat}", } } }, "inputs": [ { "type": "promptString", "id": "github_mcp_pat", "description": "GitHub Personal Access Token", "password": true } ] }

Usage in other MCP Hosts

For MCP Hosts that are Remote MCP-compatible, choose the appropriate JSON block from the examples below and add it to your host configuration:

Using OAuth Using a GitHub PAT
{ "mcpServers": { "github-remote": { "url": "https://api.githubcopilot.com/mcp/" } } } { "mcpServers": { "github-remote": { "url": "https://api.githubcopilot.com/mcp/", "authorization_token": "Bearer " } } }

Note: The exact configuration format may vary by host. Refer to your host's documentation for the correct syntax and location for remote MCP server setup.

Configuration

See Remote Server Documentation on how to pass additional configuration settings to the remote GitHub MCP Server.


Local GitHub MCP Server

Install with Docker in VS Code Install with Docker in VS Code Insiders

Prerequisites

  1. To run the server in a container, you will need to have Docker installed.
  2. Once Docker is installed, you will also need to ensure Docker is running. The image is public; if you get errors on pull, you may have an expired token and need to docker logout ghcr.io.
  3. Lastly you will need to Create a GitHub Personal Access Token. The MCP server can use many of the GitHub APIs, so enable the permissions that you feel comfortable granting your AI tools (to learn more about access tokens, please check out the documentation).

Installation

Usage with VS Code

For quick installation, use one of the one-click install buttons. Once you complete that flow, toggle Agent mode (located by the Copilot Chat text input) and the server will start.

Usage in other MCP Hosts

Add the following JSON block to your IDE MCP settings.

{ "mcp": { "inputs": [ { "type": "promptString", "id": "github_token", "description": "GitHub Personal Access Token", "password": true } ], "servers": { "github": { "command": "docker", "args": [ "run", "-i", "--rm", "-e", "GITHUB_PERSONAL_ACCESS_TOKEN", "ghcr.io/github/github-mcp-server" ], "env": { "GITHUB_PERSONAL_ACCESS_TOKEN": "${input:github_token}" } } } } }

Optionally, you can add a similar example (i.e. without the mcp key) to a file called .vscode/mcp.json in your workspace. This will allow you to share the configuration with others.

{ "inputs": [ { "type": "promptString", "id": "github_token", "description": "GitHub Personal Access Token", "password": true } ], "servers": { "github": { "command": "docker", "args": [ "run", "-i", "--rm", "-e", "GITHUB_PERSONAL_ACCESS_TOKEN", "ghcr.io/github/github-mcp-server" ], "env": { "GITHUB_PERSONAL_ACCESS_TOKEN": "${input:github_token}" } } } }

More about using MCP server tools in VS Code's agent mode documentation.

Usage with Claude Desktop

{ "mcpServers": { "github": { "command": "docker", "args": [ "run", "-i", "--rm", "-e", "GITHUB_PERSONAL_ACCESS_TOKEN", "ghcr.io/github/github-mcp-server" ], "env": { "GITHUB_PERSONAL_ACCESS_TOKEN": "" } } } }

Build from source

If you don't have Docker, you can use go build to build the binary in thecmd/github-mcp-server directory, and use the github-mcp-server stdio command with the GITHUB_PERSONAL_ACCESS_TOKEN environment variable set to your token. To specify the output location of the build, use the -o flag. You should configure your server to use the built executable as its command. For example:

{ "mcp": { "servers": { "github": { "command": "/path/to/github-mcp-server", "args": ["stdio"], "env": { "GITHUB_PERSONAL_ACCESS_TOKEN": "" } } } } }

Tool Configuration

The GitHub MCP Server supports enabling or disabling specific groups of functionalities via the --toolsets flag. This allows you to control which GitHub API capabilities are available to your AI tools. Enabling only the toolsets that you need can help the LLM with tool choice and reduce the context size.

Toolsets are not limited to Tools. Relevant MCP Resources and Prompts are also included where applicable.

Available Toolsets

The following sets of tools are available (all are on by default):

Toolset Description
context Strongly recommended: Tools that provide context about the current user and GitHub context you are operating in
code_security Code scanning alerts and security features
issues Issue-related tools (create, read, update, comment)
notifications GitHub Notifications related tools
pull_requests Pull request operations (create, merge, review)
repos Repository-related tools (file operations, branches, commits)
secret_protection Secret protection related tools, such as GitHub Secret Scanning
users Anything relating to GitHub Users
experiments Experimental features (not considered stable)

Specifying Toolsets

To specify toolsets you want available to the LLM, you can pass an allow-list in two ways:

  1. Using Command Line Argument:
    github-mcp-server --toolsets repos,issues,pull_requests,code_security
  2. Using Environment Variable:
    GITHUB_TOOLSETS="repos,issues,pull_requests,code_security" ./github-mcp-server

The environment variable GITHUB_TOOLSETS takes precedence over the command line argument if both are provided.

Using Toolsets With Docker

When using Docker, you can pass the toolsets as environment variables:

docker run -i --rm
-e GITHUB_PERSONAL_ACCESS_TOKEN=
-e GITHUB_TOOLSETS="repos,issues,pull_requests,code_security,experiments"
ghcr.io/github/github-mcp-server

The "all" Toolset

The special toolset all can be provided to enable all available toolsets regardless of any other configuration:

./github-mcp-server --toolsets all

Or using the environment variable:

GITHUB_TOOLSETS="all" ./github-mcp-server

Dynamic Tool Discovery

Note: This feature is currently in beta and may not be available in all environments. Please test it out and let us know if you encounter any issues.

Instead of starting with all tools enabled, you can turn on dynamic toolset discovery. Dynamic toolsets allow the MCP host to list and enable toolsets in response to a user prompt. This should help to avoid situations where the model gets confused by the sheer number of tools available.

Using Dynamic Tool Discovery

When using the binary, you can pass the --dynamic-toolsets flag.

./github-mcp-server --dynamic-toolsets

When using Docker, you can pass the toolsets as environment variables:

docker run -i --rm
-e GITHUB_PERSONAL_ACCESS_TOKEN=
-e GITHUB_DYNAMIC_TOOLSETS=1
ghcr.io/github/github-mcp-server

Read-Only Mode

To run the server in read-only mode, you can use the --read-only flag. This will only offer read-only tools, preventing any modifications to repositories, issues, pull requests, etc.

./github-mcp-server --read-only

When using Docker, you can pass the read-only mode as an environment variable:

docker run -i --rm
-e GITHUB_PERSONAL_ACCESS_TOKEN=
-e GITHUB_READ_ONLY=1
ghcr.io/github/github-mcp-server

GitHub Enterprise Server and Enterprise Cloud with data residency (ghe.com)

The flag --gh-host and the environment variable GITHUB_HOST can be used to set the hostname for GitHub Enterprise Server or GitHub Enterprise Cloud with data residency.

"github": { "command": "docker", "args": [ "run", "-i", "--rm", "-e", "GITHUB_PERSONAL_ACCESS_TOKEN", "-e", "GITHUB_HOST", "ghcr.io/github/github-mcp-server" ], "env": { "GITHUB_PERSONAL_ACCESS_TOKEN": "${input:github_token}", "GITHUB_HOST": "https://" } }

i18n / Overriding Descriptions

The descriptions of the tools can be overridden by creating agithub-mcp-server-config.json file in the same directory as the binary.

The file should contain a JSON object with the tool names as keys and the new descriptions as values. For example:

{ "TOOL_ADD_ISSUE_COMMENT_DESCRIPTION": "an alternative description", "TOOL_CREATE_BRANCH_DESCRIPTION": "Create a new branch in a GitHub repository" }

You can create an export of the current translations by running the binary with the --export-translations flag.

This flag will preserve any translations/overrides you have made, while adding any new translations that have been added to the binary since the last time you exported.

./github-mcp-server --export-translations cat github-mcp-server-config.json

You can also use ENV vars to override the descriptions. The environment variable names are the same as the keys in the JSON file, prefixed withGITHUB_MCP_ and all uppercase.

For example, to override the TOOL_ADD_ISSUE_COMMENT_DESCRIPTION tool, you can set the following environment variable:

export GITHUB_MCP_TOOL_ADD_ISSUE_COMMENT_DESCRIPTION="an alternative description"

Tools

Users

Issues

Pull Requests

Repositories

Users

Code Scanning

Secret Scanning

Notifications

Resources

Repository Content

Library Usage

The exported Go API of this module should currently be considered unstable, and subject to breaking changes. In the future, we may offer stability; please file an issue if there is a use case where this would be valuable.

License

This project is licensed under the terms of the MIT open source license. Please refer to MIT for the full terms.