Set Up GitHub MCP Server
Access GitHub repos, issues, and PRs from Claude, Cursor, or VS Code. Guided setup with automatic configuration — takes 2 minutes.
Your OS:
Quick Install (Automated)
Our script guides you through PAT creation, verifies it works, and configures your AI tools automatically.
Terminal (Linux)
curl -fsSL https://contextbharat.com/setup/github-mcp.sh | bash
Or clone and run locally:
bash tools/setup-github-mcp.shManual Setup
1Create a Fine-Grained PAT
- Go to github.com/settings/tokens (Fine-grained tokens)
- Click Generate new token
- Set token name to
MCP Server, expiration to90 days - Repository access: All repositories (or select specific ones)
- Set these permissions under "Repository permissions":
Contents
Read-only
Read code & files
Issues
Read & Write
View & create issues
Pull requests
Read & Write
View & create PRs
Metadata
Read-only
Auto-selected
2Add to your AI tool
MCP config for Linux
{
"mcpServers": {
"github": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-github"],
"env": {
"GITHUB_PERSONAL_ACCESS_TOKEN": "YOUR_TOKEN_HERE"
}
}
}
}Paste the config into the right file for your tool:
C
Claude Desktop
~/.config/Claude/claude_desktop_config.json
CC
Claude Code
~/.claude.json
Cu
Cursor
~/.cursor/mcp.json
VS
VS Code
.vscode/mcp.json (project root)
W
Windsurf
~/.codeium/windsurf/mcp_config.json
3Restart your AI tool
Close and reopen Claude Desktop / Cursor / VS Code. The GitHub MCP server will load automatically.
Fixing Org Access
If you get "Resource not accessible by personal access token" on org repos:
- When creating the PAT, select your org as Resource Owner
- After creation, go to github.com/settings/tokens
- Click your token → Request access for your org
- Ask your org admin to approve at:
github.com/organizations/YOUR_ORG/settings/personal-access-token-requests
This is a GitHub security policy, not a bug. Fine-grained PATs for org repos require explicit admin approval.
What You Get
Once configured, your AI tool can use these GitHub MCP tools:
get_file_contents
Read any file from a repo
search_code
Search code across repos
create_issue
Create a new issue
list_issues
List issues on a repo
create_pull_request
Open a PR
get_pull_request
View PR details
create_branch
Create a new branch
list_commits
View commit history
push_files
Push multiple files
create_or_update_file
Create or edit files
search_repositories
Search GitHub repos
fork_repository
Fork a repo
Troubleshooting
spawn npx ENOENT
Make sure Node.js is in your PATH. If using NVM, the full path to npx may be needed: which npx to find it.
Token expired
Re-run the setup script to generate and configure a new token.
MCP server not loading (no errors shown)
Check your JSON config for syntax errors (no trailing commas). Try running the npx command manually in your terminal to see error output.
Rate limiting (HTTP 429)
Authenticated PATs get 5,000 requests/hour. If you hit limits, wait for the rate limit to reset (shown in response headers).
Security
✓Token stays on your machine in local config files
✓Context Bharat never receives or stores your GitHub token
✓Use fine-grained tokens with minimum required permissions
✓Set 90-day expiration — regenerate when needed
Want Indian API docs too?
Set up Context Bharat MCP to get Razorpay, ONDC, Zerodha, UPI docs in your AI editor.