How to Set Up the GitHub MCP Server (2026)
Updated July 18, 2026• Web MCP Guide
The GitHub MCP server gives Claude, Cursor, or VS Code direct access to your repositories: reading issues and pull requests, browsing code and file history, triggering and inspecting Actions runs, and pulling security alerts. GitHub ships an official server — a Go binary distributed as a Docker image, plus a remote hosted endpoint — authenticated with a personal access token or OAuth.
Prerequisites
- A GitHub account with access to the repositories you want to expose
- A personal access token (classic or fine-grained), or a client that supports remote MCP with OAuth
- Docker installed if you run the local server; nothing extra if you use the remote endpoint
- An MCP-compatible client: Claude Desktop, Cursor, or VS Code
Step 1 — Create a Personal Access Token
Generate a token at github.com/settings/tokens. A classic token with the repo scope is enough for reading and writing repository content, issues, and pull requests. Add workflow if you want to trigger Actions, and read:org for organization data.
Fine-grained tokens are the better choice for scoped access: pick the exact repositories and grant only the permissions you need (Contents, Issues, Pull requests), so a leaked token can't touch everything you own.
⚠️ Don't hand it a token that can touch every repo
The MCP server acts with the full authority of the token you give it. If the assistant only needs to read one project, use a fine-grained token scoped to that single repository — not a classic token with repo across your whole account. Pair it with read-only mode (Step 3) when you don't want any writes at all.
Step 2 — Choose Local (Docker) or Remote
The official server runs two ways. The remote endpoint is hosted by GitHub and needs no install — just a URL and a token (or OAuth). The local build runs the ghcr.io/github/github-mcp-server Docker image on your machine, which is the option for GitHub Enterprise Server or when you want the process fully under your control.
If you have Docker and want to confirm the image pulls, run it once:
docker pull ghcr.io/github/github-mcp-serverStep 3 — Configure Your MCP Client
Add the server to your client config. The Docker examples pass the token through as an environment variable; note the -e GITHUB_PERSONAL_ACCESS_TOKEN flag forwards it into the container.
Claude Desktop (local Docker)
Config: ~/Library/Application Support/Claude/claude_desktop_config.json
{
"mcpServers": {
"github": {
"command": "docker",
"args": [
"run", "-i", "--rm",
"-e", "GITHUB_PERSONAL_ACCESS_TOKEN",
"ghcr.io/github/github-mcp-server"
],
"env": {
"GITHUB_PERSONAL_ACCESS_TOKEN": "ghp_your_token_here"
}
}
}
}Cursor IDE (remote endpoint)
Config: ~/.cursor/mcp.json
{
"mcpServers": {
"github": {
"url": "https://api.githubcopilot.com/mcp/",
"headers": {
"Authorization": "Bearer ghp_your_token_here"
}
}
}
}To narrow the tool surface and disable writes, add the toolset and read-only settings via environment variables (Docker) or query parameters (remote):
{
"mcpServers": {
"github": {
"command": "docker",
"args": [
"run", "-i", "--rm",
"-e", "GITHUB_PERSONAL_ACCESS_TOKEN",
"-e", "GITHUB_TOOLSETS",
"-e", "GITHUB_READ_ONLY",
"ghcr.io/github/github-mcp-server"
],
"env": {
"GITHUB_PERSONAL_ACCESS_TOKEN": "ghp_your_token_here",
"GITHUB_TOOLSETS": "repos,issues,pull_requests",
"GITHUB_READ_ONLY": "1"
}
}
}
}Restart your MCP client after saving. GitHub should appear in the available tools list.
Step 4 — Test the Connection
Ask your client something that requires a live API call:
"List the 5 most recently updated open issues in my-org/my-repo"A real list of issues confirms the token and connection are working. A 401 means the token is wrong or expired; a 403 usually means the token is valid but missing the scope for that action.
What You Can Do With the GitHub MCP Server
- Read, create, comment on, and close issues and pull requests
- Browse repository files, commits, and branch history without cloning
- Open a PR, request reviews, and merge once checks pass
- Trigger and inspect GitHub Actions workflow runs and read failing logs
- Pull Dependabot and code-scanning alerts to triage security findings
- Search code and issues across repositories you have access to
Pairing GitHub with an error-tracking source is a common setup — the Sentry MCP server guide covers pulling stack traces in so the assistant can move from a crash straight to the commit that caused it.
When Not to Use It
If all you need is to search public repositories or read documentation, the MCP server is overkill — a plain web fetch is simpler and needs no token. Skip it too on shared or untrusted machines where the token would sit in a config file; the remote endpoint with short-lived OAuth is safer there. And for pure local development where you already have the repo cloned, the filesystem MCP server gives faster access to the working tree than round-tripping through the GitHub API.
Troubleshooting
| Problem | Likely Cause | Fix |
|---|---|---|
| 401 Unauthorized | Token expired, revoked, or mistyped | Regenerate the PAT and update the config env value |
| 403 on a write action | Token missing the scope for that operation | Add repo/workflow scope, or the matching fine-grained permission |
| Server never starts | Docker not running, or image not pulled | Start Docker; run docker pull ghcr.io/github/github-mcp-server |
| Calls hit github.com on Enterprise | GITHUB_HOST not set for GitHub Enterprise Server | Set GITHUB_HOST to your Enterprise instance URL |
Frequently Asked Questions
Is the GitHub MCP server official, and which one should I use?
GitHub maintains the official server at github/github-mcp-server, written in Go and shipped as a Docker image and a remote hosted endpoint. Use it rather than the old @modelcontextprotocol/server-github npm package, which was an early reference implementation and is no longer the maintained path. The remote server (api.githubcopilot.com/mcp/) is the least-effort option if your client supports remote MCP with OAuth; the Docker build is the choice when you want a self-hosted process or need to run against GitHub Enterprise.
What personal access token scopes does the GitHub MCP server need?
It depends on which toolsets you enable. A classic PAT with the repo scope covers reading and writing repository content, issues, and pull requests. For Actions you also need workflow, and for reading org or user data add read:org and read:user. Fine-grained tokens work too — grant only the specific repository permissions the assistant needs (Contents, Issues, Pull requests) rather than a blanket token. Start narrow and add scopes when a tool call fails with a permissions error.
Can I run the GitHub MCP server in read-only mode?
Yes. Pass the --read-only flag (or set GITHUB_READ_ONLY=1) and every write tool — creating issues, merging PRs, dispatching workflows — is disabled, leaving only the read tools registered. This is worth doing when you want the assistant to browse and summarize a repository without any risk of it pushing changes, and it pairs well with a token that only has read scopes so the restriction is enforced on both sides.
How do I limit which tools the GitHub MCP server exposes?
The server groups tools into toolsets. The default set is context, repos, issues, pull_requests and users; actions, code_security, dependabot, discussions, notifications, orgs, projects and others are opt-in. On the local server, enable a subset with the --toolsets flag or the GITHUB_TOOLSETS environment variable (for example GITHUB_TOOLSETS=repos,issues,pull_requests), or name individual tools with --tools / GITHUB_TOOLS — the two combine additively. On the remote server each toolset has its own URL (api.githubcopilot.com/mcp/x/repos), or you can send an X-MCP-Toolsets header with a comma-separated list. Fewer toolsets means a shorter tool list for the model to reason over, which improves reliability.
Does the GitHub MCP server work with GitHub Enterprise Server?
Yes, but you have to point it at your instance. Set the GITHUB_HOST environment variable to your Enterprise Server hostname (for example https://github.your-company.com) so API calls go to the right place instead of github.com. Enterprise Cloud with data residency uses a different host again, so check your organization's API base URL before assuming the default endpoint will work.
Related Articles
PostgreSQL MCP Server Setup
Query and inspect your database from your AI assistant
Sentry MCP Server Setup
Pull error context into your AI assistant
Browse the full MCP server directory for more setup guides, including Playwright and Redis.