How to Set Up GitHub MCP Server (2026)
Connect GitHub to AI assistants via the Model Context Protocol
Start Building with Hypereal
Access Kling, Flux, Sora, Veo & more through a single API. Free credits to start, scale to millions.
No credit card required • 100k+ developers • Enterprise ready
How to Set Up GitHub MCP Server (2026)
The Model Context Protocol (MCP) lets AI assistants interact with external tools and services through a standardized interface. The GitHub MCP server is one of the most useful integrations available -- it lets AI assistants like Claude, Cursor, and other MCP-compatible clients create issues, review pull requests, search code, manage repositories, and more, all through natural language.
This guide walks you through setting up the GitHub MCP server from scratch and connecting it to your AI tools.
What Is the GitHub MCP Server?
The GitHub MCP server exposes GitHub's API as a set of tools that AI assistants can call. Instead of manually navigating the GitHub UI or writing API calls, you can tell your AI assistant things like:
- "Create an issue for the login bug we discussed"
- "Review the open pull requests on this repo"
- "Search for all files that reference the deprecated
handleAuthfunction" - "Create a branch and push a fix for issue #42"
The MCP server translates these natural language requests into GitHub API calls and returns the results to the AI.
Available Tools
The GitHub MCP server provides these capabilities:
| Tool Category | Operations |
|---|---|
| Repositories | Create, fork, list, search repositories |
| Issues | Create, read, update, comment, list, search issues |
| Pull Requests | Create, review, merge, list PRs, get diffs |
| Branches | Create, list, delete branches |
| Files | Read, create, update file contents |
| Code Search | Search code across repositories |
| Commits | List commits, get commit details |
| Actions | List workflow runs, get status |
| Users | Get user profiles, list collaborators |
Prerequisites
| Requirement | Details |
|---|---|
| GitHub account | Free or paid |
| GitHub Personal Access Token | Fine-grained or classic |
| Node.js | v18 or higher |
| MCP-compatible client | Claude Desktop, Claude Code, Cursor, etc. |
Step 1: Create a GitHub Personal Access Token
You need a token that gives the MCP server access to your GitHub resources.
Fine-Grained Token (Recommended)
- Go to github.com/settings/tokens.
- Click Generate new token under Fine-grained tokens.
- Set a descriptive name: "MCP Server Access".
- Set expiration (90 days recommended, or custom).
- Under Repository access, choose:
- All repositories for full access, or
- Only select repositories for specific repos.
- Under Permissions, grant:
| Permission | Access Level |
|---|---|
| Contents | Read and write |
| Issues | Read and write |
| Pull requests | Read and write |
| Metadata | Read-only |
| Actions | Read-only |
| Commit statuses | Read-only |
- Click Generate token and copy it immediately.
# Store the token as an environment variable
export GITHUB_PERSONAL_ACCESS_TOKEN="github_pat_your-token-here"
Classic Token (Simpler)
If fine-grained tokens feel complex, use a classic token:
- Go to github.com/settings/tokens.
- Click Generate new token (classic).
- Select scopes:
repo,read:org,read:user. - Generate and copy.
Step 2: Install the GitHub MCP Server
The official GitHub MCP server is maintained by GitHub (previously by Anthropic/community). Install it based on your setup:
Option A: Using npx (No Installation)
The simplest approach -- run the server directly with npx:
npx -y @modelcontextprotocol/server-github
This downloads and runs the server on demand. No global installation needed.
Option B: Global Installation
npm install -g @modelcontextprotocol/server-github
Option C: Docker
docker run -i --rm \
-e GITHUB_PERSONAL_ACCESS_TOKEN="your-token" \
ghcr.io/modelcontextprotocol/server-github
Step 3: Connect to Claude Desktop
If you use Claude Desktop (Anthropic's standalone app), add the GitHub MCP server to your configuration file.
macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
Windows: %APPDATA%\Claude\claude_desktop_config.json
{
"mcpServers": {
"github": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-github"],
"env": {
"GITHUB_PERSONAL_ACCESS_TOKEN": "github_pat_your-token-here"
}
}
}
}
Restart Claude Desktop after saving the configuration. You should see a hammer icon in the chat input indicating that tools are available.
Verify the Connection
Ask Claude: "List my GitHub repositories." If the MCP server is connected correctly, Claude will call the GitHub tool and return your repo list.
Step 4: Connect to Claude Code
Claude Code supports MCP servers natively. Add the GitHub MCP server to your project or global configuration:
Project-Level Configuration
Create or edit .mcp.json in your project root:
{
"mcpServers": {
"github": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-github"],
"env": {
"GITHUB_PERSONAL_ACCESS_TOKEN": "github_pat_your-token-here"
}
}
}
}
Global Configuration
claude mcp add github -- npx -y @modelcontextprotocol/server-github
Or edit ~/.claude/settings.json:
{
"mcpServers": {
"github": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-github"],
"env": {
"GITHUB_PERSONAL_ACCESS_TOKEN": "github_pat_your-token-here"
}
}
}
}
Test It
claude
> list open issues on owner/repo-name
> create a branch called fix-auth-bug from main
> show me the diff for PR #42
Step 5: Connect to Cursor
Cursor supports MCP servers through its settings. Add the GitHub MCP server:
- Open Cursor Settings (Cmd+, / Ctrl+,).
- Search for "MCP" or navigate to Features > MCP Servers.
- Click Add MCP Server and enter:
{
"github": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-github"],
"env": {
"GITHUB_PERSONAL_ACCESS_TOKEN": "github_pat_your-token-here"
}
}
}
Alternatively, create a .cursor/mcp.json file in your project:
{
"mcpServers": {
"github": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-github"],
"env": {
"GITHUB_PERSONAL_ACCESS_TOKEN": "github_pat_your-token-here"
}
}
}
}
Practical Use Cases
1. AI-Powered Code Review
Ask your AI assistant to review open pull requests:
Prompt: "Review PR #15 on owner/my-repo. Check for security issues,
performance problems, and code style. Leave a summary comment."
The AI reads the PR diff through the MCP server, analyzes the changes, and can post review comments directly on GitHub.
2. Issue Management
Create issues from natural language descriptions:
Prompt: "Create an issue on owner/my-repo titled 'Login timeout on mobile devices'.
Add the label 'bug' and 'priority: high'. In the description, mention that users
on iOS Safari are experiencing 30-second timeouts during OAuth redirect."
3. Code Search Across Repos
Search for patterns across your organization's repositories:
Prompt: "Search all repos in our org for usage of the deprecated
'legacyAuth()' function. List the files and line numbers."
4. Automated Branch and PR Creation
Combine Claude Code's coding abilities with GitHub MCP:
Prompt: "Create a branch called 'fix-memory-leak', fix the memory leak in
src/cache.ts where connections are not being released, commit the fix,
push the branch, and create a PR with a description of what was changed."
5. Release Notes Generation
Prompt: "Look at all merged PRs since the last release tag on owner/my-repo.
Generate release notes grouped by: Features, Bug Fixes, and Improvements."
Security Best Practices
Token Scoping
Use fine-grained tokens with minimal permissions. If you only need to read repositories, do not grant write access.
Environment Variables
Never hardcode tokens in configuration files that might be committed to Git:
# Add to .gitignore
echo ".mcp.json" >> .gitignore
# Use environment variables instead
export GITHUB_PERSONAL_ACCESS_TOKEN="your-token"
Then reference the environment variable in your config:
{
"mcpServers": {
"github": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-github"],
"env": {
"GITHUB_PERSONAL_ACCESS_TOKEN": "${GITHUB_PERSONAL_ACCESS_TOKEN}"
}
}
}
}
Token Rotation
Set expiration dates on tokens and rotate them regularly. GitHub's fine-grained tokens support custom expiration periods.
Audit Logging
GitHub's audit log tracks all API access. Monitor it periodically to ensure the MCP server is only accessing expected resources.
Troubleshooting
| Problem | Solution |
|---|---|
| "Bad credentials" error | Regenerate your token and update the config |
| Server not starting | Make sure Node.js v18+ is installed |
| Tools not appearing | Restart your MCP client after config changes |
| Rate limiting | GitHub allows 5,000 requests/hour for authenticated users. Reduce query frequency |
| Timeout errors | The MCP server has a default timeout. For large repos, increase it in the server config |
| Permission denied | Check that your token has the required scopes for the operation |
Frequently Asked Questions
Is the GitHub MCP server official?
The @modelcontextprotocol/server-github package is part of the official MCP servers collection, maintained in the MCP GitHub organization. GitHub has also released their own official MCP server.
Does it work with GitHub Enterprise?
Yes. Set the GITHUB_API_URL environment variable to your Enterprise instance URL.
Can multiple people use the same MCP server? Each person needs their own token. The MCP server runs locally on each developer's machine.
What about rate limits? Authenticated GitHub API requests are limited to 5,000 per hour. Normal MCP usage rarely hits this limit.
Can I use this with GitLab or Bitbucket? No. This server is GitHub-specific. There are separate MCP servers for GitLab and Bitbucket.
Wrapping Up
The GitHub MCP server turns your AI assistant into a GitHub power user. Instead of context-switching between your AI tool, the GitHub UI, and the terminal, you can manage issues, review PRs, search code, and create branches -- all through natural language conversation.
Setup takes less than five minutes, and the productivity gains are immediate. Once you have used AI-assisted GitHub management, going back to the manual workflow feels painfully slow.
If you are building projects that involve AI-generated media, try Hypereal AI free -- no credit card required. Its API integrates seamlessly with GitHub-based workflows for image and video generation features.
Related Articles
Start Building Today
Get 35 free credits on signup. No credit card required. Generate your first image in under 5 minutes.
