On this page
- What does connecting an agent to GitHub actually mean?
- Cursor's built-in GitHub connection
- Claude Code's GitHub app and Actions
- Get a token first
- Connect Cursor to GitHub
- Add the GitHub MCP server to Claude Code
- Connect Codex CLI to GitHub
- Remote server or local Docker?
- Keep the tool list short with toolsets
- What the GitHub MCP server does not give the agent
- Add repowise next to the GitHub server
- Troubleshooting
- FAQ
To connect Cursor to GitHub, add GitHub's official MCP server to ~/.cursor/mcp.json with the URL https://api.githubcopilot.com/mcp/ and a personal access token (PAT) in an Authorization header, then restart Cursor. Claude Code and Codex CLI use the same URL with a different config shape. All three are below, each with a check that proves the server is live. If you only want Cursor or Claude Code to work on a GitHub repo through git, or to review pull requests, the two short sections before the MCP setup cover that.
The server is github/github-mcp-server. As of November 2026 its Cursor install guide says the remote server needs a PAT, not OAuth, so have a token ready before you start.
What does connecting an agent to GitHub actually mean?
There are two separate things, and people mix them up. Git and GitHub sign-in is how your machine pushes and pulls: SSH keys, gh auth login, or your editor's GitHub account. An agent that runs git in your terminal already uses that.
The GitHub MCP server is something else. It gives the agent tools that call GitHub's API: read a file on any branch, search code, list and comment on issues, open and review pull requests, check Actions runs. It works from a laptop with no clone, and it works on repos you have not checked out. That is the part you want when someone says "github mcp".
Cursor's built-in GitHub connection
Cursor has its own GitHub link that is separate from MCP. For cloud agents and Bugbot, open Integrations in the Cursor dashboard (cursor.com/dashboard/integrations), click Connect next to GitHub, and choose All repositories or Selected repositories. Per Cursor's GitHub docs this needs Cursor admin access and GitHub org admin access, and one GitHub installation can belong to only one Cursor account or team at a time.
That link lets Cursor's hosted agents clone and push. It does not add tools to the agent in your editor. For local git, Cursor uses the git and GitHub credentials already on your machine. Use MCP when you want the editor agent to read issues, pull requests and Actions runs.
Claude Code's GitHub app and Actions
Claude Code also has a GitHub integration that is not MCP: the Claude GitHub App plus the anthropics/claude-code-action workflow. Run claude in the repository, then /install-github-app. It installs the app, stores a secret (ANTHROPIC_API_KEY or CLAUDE_CODE_OAUTH_TOKEN), and opens a pull request with workflow files. After you merge it, mentioning @claude in an issue or pull request comment starts a run. The GitHub Actions docs note it needs admin access to the repository and works with github.com repositories only.
That runs Claude in your CI. The MCP server below is different: it gives your own interactive session GitHub tools.
Get a token first
Create a PAT at github.com/settings/personal-access-tokens/new and give it the least access that does the job. The Codex install guide suggests starting with the repo scope and adding workflow, read:org, project or gist only when a tool call fails for lack of permission. A fine-grained token limited to the repos you work in is the safer start.
Treat the token like a password. Never commit a mcp.json that has it typed in; use the environment variable forms below where the agent supports them.
Connect Cursor to GitHub
Cursor reads MCP servers from ~/.cursor/mcp.json (all projects) or .cursor/mcp.json (one project). This is the remote config from GitHub's guide. It needs Cursor v0.48.0 or later for Streamable HTTP, per GitHub's guide.
{
"mcpServers": {
"github": {
"url": "https://api.githubcopilot.com/mcp/",
"headers": {
"Authorization": "Bearer YOUR_GITHUB_PAT"
}
}
}
}
Cursor's MCP docs say header values accept interpolation, so "Bearer ${env:GITHUB_PAT}" keeps the token out of the file. Set the variable in your shell profile, because remote servers do not support envFile.
Restart Cursor completely. Verify: open Customize in the sidebar and check that github is listed and toggled on. Then ask in chat: "List my GitHub repositories." If nothing shows, open the Output panel (Cmd+Shift+U, or Ctrl+Shift+U on Windows and Linux) and choose MCP Logs.
Add the GitHub MCP server to Claude Code
Claude Code adds an HTTP server with one command, and the token goes in a header. This is the example in the Claude Code MCP docs:
claude mcp add --transport http github https://api.githubcopilot.com/mcp/ \
--header "Authorization: Bearer YOUR_GITHUB_PAT"
Run it in your terminal, not inside Claude Code. The default scope is local, which stores it in ~/.claude.json for the current project. Add --scope user to get it in every project, or --scope project to write .mcp.json for the team (then keep the token out of that file). The command saves what you give it without testing the token, so a typo only shows up later.
Verify: inside Claude Code run /mcp. A good row reads Connected. A bad token shows Failed to connect with the HTTP status, usually 401. From a shell, claude mcp list shows the same health check and claude mcp get github prints the entry.
Connect Codex CLI to GitHub
Codex reads the token from an environment variable named in ~/.codex/config.toml. GitHub's Codex guide uses this:
[mcp_servers.github]
url = "https://api.githubcopilot.com/mcp/"
bearer_token_env_var = "GITHUB_PAT_TOKEN"
Export GITHUB_PAT_TOKEN in the shell that launches codex. The keys url and bearer_token_env_var are the ones listed for streamable HTTP servers in the Codex MCP docs. GitHub's guide also gives a one-liner that writes the same block:
codex mcp add github --url https://api.githubcopilot.com/mcp/ --bearer-token-env-var GITHUB_PAT_TOKEN
Verify: start codex, run /mcp, and confirm github lists its tools. Then ask it to list your repositories.
Remote server or local Docker?
The remote server is the default choice: no Docker, nothing to update. The local option runs the ghcr.io/github/github-mcp-server image on your machine, and it is the one that supports an OAuth browser login on github.com (the Cursor guide shows both an OAuth and a PAT variant). Pick local when your company blocks the hosted endpoint or you run GitHub Enterprise Server, where you set GITHUB_HOST.
Remote (api.githubcopilot.com/mcp/) | Local Docker | |
|---|---|---|
| Setup | URL plus a header | Docker running, image pulled |
| Auth | PAT | PAT, or OAuth login on github.com |
| Updates | Handled by GitHub | You pull the image |
| Fits | Most laptops | Locked-down networks, Enterprise Server |
Scroll the table sideways to see every column.
Do not use @modelcontextprotocol/server-github. The install guide notes it has not been supported since April 2025.
Keep the tool list short with toolsets
The default toolsets are context, repos, issues, pull_requests and users, and every enabled tool costs context on every turn. Trim what you do not use. On the remote server, set the X-MCP-Toolsets header (for example repos,issues) or add X-MCP-Readonly: true to expose only read tools, per the remote server docs. Adding /readonly to the end of the URL does the same for the default set.
In Cursor that is one more line in headers. In Claude Code add a second --header. For read-only exploration of a repo you do not own, I would turn read-only on and leave it there.
What the GitHub MCP server does not give the agent
GitHub's server answers from GitHub's API, so it knows files, issues, pull requests and workflow runs, and nothing derived from them. Ask it which files import billing/invoice.py, who has changed that module most, or why the retry logic was written this way, and the agent falls back to searching and reading files one by one. That is slow, and it burns context.
The answers to those questions come from an index built on your code and history: the import graph, hotspots, owners, co-change pairs and recorded decisions. That is what repowise builds, and it exposes it through 10 MCP tools. Run it as a second server beside GitHub's, one per kind of fact. The longer case for that split is in Cursor MCP: real codebase context and the Claude Code options post; the wider field is in best MCP servers for coding agents.
Add repowise next to the GitHub server
Install the CLI, index the repo, and let it register itself in the agents it finds. From the repository root:
pipx install repowise # or: uv tool install repowise
repowise init
repowise agents add --target=cursor,claude-code,codex --yes
init indexes the repo and wires detected agents; agents add picks the targets explicitly (target ids are claude-code, codex and cursor, among others). The entries it writes sit next to your github entry and do not replace it. Cursor gets .cursor/mcp.json, Codex gets .codex/config.toml (Codex loads that file only for a trusted project, so run codex once in the repo and trust it). Details per agent are on the Cursor and Codex pages and the Claude Code page.
If you do not want to run anything locally, the hosted server takes a URL. repowise agents add --hosted writes https://api.repowise.dev/mcp/<owner>/<name> as a remote entry with no key, and you sign in with OAuth the first time the client connects: restart and run /mcp in Claude Code, click Needs login in Cursor's MCP settings, or run codex mcp login repowise in Codex. For a private repo through a chat app, see connecting Claude or ChatGPT to a private GitHub repo.
Then ask the agent a question GitHub's server cannot answer, like "what depends on this file and who owns it?" and check that it called a repowise tool.
Troubleshooting
| Symptom | Likely cause | Fix |
|---|---|---|
401 or Failed to connect in /mcp | Wrong, expired or revoked token, or Bearer missing from the header | Create a new PAT and re-run the add command; the header is Authorization: Bearer <token> |
| Server connects, tool calls return 403 or not found | The token's scopes or repo access are too narrow | Widen the fine-grained token to that repo, or add the scope the failing tool needs |
github never appears in Cursor | Cursor not fully restarted, JSON invalid, or older than v0.48.0 | Quit and reopen, validate the JSON, update Cursor, check MCP Logs |
| Server missing in Codex | Token env var not exported in that shell | Export GITHUB_PAT_TOKEN, restart codex, run /mcp |
| Docker image will not pull | Stale registry login | Run docker logout ghcr.io and try again |
| Agent is slow or picks wrong tools | Too many tools loaded | Narrow with X-MCP-Toolsets or turn on read-only |
Scroll the table sideways to see every column.
FAQ
- How do I connect Cursor to GitHub?
- Add the GitHub MCP server to
~/.cursor/mcp.jsonor.cursor/mcp.jsonwith the URLhttps://api.githubcopilot.com/mcp/and anAuthorization: Bearerheader holding a personal access token. Restart Cursor and check thatgithubis listed and enabled under Customize. That is separate from Cursor's own GitHub connection in the dashboard Integrations page, which cloud agents and Bugbot use, and from ordinary git pushes and pulls, which use your normal git credentials. - How do I use GitHub with Claude Code?
- Two ways. For pull request automation, run
/install-github-appin the repo, merge the pull request it opens, and mention@claudein issues and pull requests. For GitHub tools inside your own session, add the MCP server withclaude mcp add --transport http github https://api.githubcopilot.com/mcp/ --header "Authorization: Bearer YOUR_GITHUB_PAT". - Does Cursor have a GitHub MCP?
- Cursor supports MCP servers, and GitHub publishes an official one, github/github-mcp-server, with a Cursor install guide. It is not on by default; you add it to
mcp.jsonyourself. - How do I add the GitHub MCP server to Claude Code?
- Run
claude mcp add --transport http github https://api.githubcopilot.com/mcp/ --header "Authorization: Bearer YOUR_GITHUB_PAT"in your terminal, then run/mcpinside Claude Code to confirm it shows Connected. Add--scope userto make it available in every project. - Does Codex CLI support the GitHub MCP server?
- Yes. Add a
[mcp_servers.github]block to~/.codex/config.tomlwith the URL andbearer_token_env_var, or runcodex mcp add github --url https://api.githubcopilot.com/mcp/ --bearer-token-env-var GITHUB_PAT_TOKEN. Run/mcpin the Codex TUI to see its tools. - Is the GitHub MCP server free?
- The server is open source and you connect with your own token. The install guides list no fee for the server, but I could not find a pricing statement for the hosted endpoint, so check GitHub's current terms if your company has a policy. Your GitHub plan decides which repos the token can reach.
- PAT or OAuth for the GitHub MCP server?
- For the remote server in Cursor, GitHub's guide says a PAT is required. OAuth login is offered by the local Docker image on github.com. If you set a PAT on the local server, it takes precedence over OAuth. Use a fine-grained PAT limited to the repos you need.



