How to connect to GitHub with an AI agent
Use GitHub's official MCP server at https://api.githubcopilot.com/mcp/ with a fine-grained personal access token. One command adds it to Claude Code, a config.toml block adds it to Codex, and mcp.json adds it to Cursor. Give the token only the repos and permissions the agent needs.
Grok Bot steps tested by us on Oct 26, 2026 while building this page. Claude Code, Codex and Cursor steps checked against official docs on Oct 26, 2026.
Get the free starter kit. One short email a day when our setups change.
Free starter kit on signup: 2 Claude Code skills and 1 agent persona from our paid packs. By subscribing you agree to get The AI Loadout Daily, one email each morning. No spam, we never sell your email, and every email has a one-click unsubscribe link.
Claude Code
Create a fine-grained token at github.com/settings/personal-access-tokens/newclaude mcp add --transport http github https://api.githubcopilot.com/mcp/ --header "Authorization: Bearer YOUR_GITHUB_PAT"Ask: "List open issues labeled bug in this repo."
Codex
Add to ~/.codex/config.toml: [mcp_servers.github] url = "https://api.githubcopilot.com/mcp/" and bearer_token_env_var = "GITHUB_PAT_TOKEN"export GITHUB_PAT_TOKEN=your tokencodex mcp list to confirm
Cursor
Add to .cursor/mcp.json: {"mcpServers":{"github":{"url":"https://api.githubcopilot.com/mcp/","headers":{"Authorization":"Bearer ${env:GITHUB_PAT}"}}}}Set GITHUB_PAT in your shell, then reload the server
Grok Bot
Connect GitHub to Grok BotAsk it to read issues, open a branch or push a commitIt works in its own copy of the repo on its cloud computer
Gotchas
- A classic token with repo scope can touch every repo you own. Use fine-grained tokens.
- Keep tokens out of committed config. Use env variables.
- Agents can open PRs fast. Protect your main branch.
The loadout for this job
- Tools: GitHub Copilot, Cursor
- Skill: Claude TDD skill
- Repo: GitHub MCP Server
- Model: Claude Sonnet 5.5
- Bot: Grok Bot
- Full setup: Best AI coding agent
FAQ
Is there an official GitHub MCP server?
Yes. github/github-mcp-server, with a hosted endpoint at https://api.githubcopilot.com/mcp/.
Which token should I use?
A fine-grained personal access token limited to the repos the agent needs.
Related how-tos
Sources
Commands change. Check the linked docs before you run anything. All how-to guides