github-mcp
Provides 39 tools to manage GitHub repositories, branches, issues, PRs, workflows, and more via the GitHub CLI, enabling natural language interaction with GitHub.
README
🐙 GitHub MCP Server
A Model Context Protocol (MCP) server that wraps the GitHub CLI (gh) to provide 39 tools across 12 categories — manage repos, branches, issues, PRs, workflows, collaborators, and more, directly from Claude Desktop or Claude Code.
🚀 Features
- Repository Management — Create, clone, list, view, and delete repos
- Git Operations — Add, commit, push, pull, init + push in one command
- Branch Management — Create, list, switch, and delete branches
- Forking — Fork repos and sync forks with upstream
- Issues — Create, list, and comment on issues
- Pull Requests — Create, list, comment, merge, review, and diff PRs
- Collaborators — List and add collaborators to repos
- File Operations — Read and create/update files via the GitHub API
- Workflows — List, trigger, and inspect GitHub Actions workflow runs
- Releases — Create and list releases
- Gists — Create gists from content
- Search — Search repositories across GitHub
- Security — Path sandboxing, input validation, read-only mode, audit logging
- Remote Access — SSE transport with OAuth 2.0 authentication via ngrok tunnel
📦 Prerequisites
1. Install GitHub CLI
# macOS
brew install gh
# Ubuntu/Debian
sudo apt install gh
# Windows
winget install GitHub.cli
2. Authenticate
gh auth login
gh auth status # Verify you're logged in
3. Python 3.10+
python --version # Must be 3.10 or higher
🔧 Installation
# Clone the repository
git clone https://github.com/prateekaryann/github-mcp.git
cd github-mcp
# Create virtual environment
python -m venv venv
source venv/bin/activate # Windows: venv\Scripts\activate
# Install dependencies
pip install -r requirements.txt
🔌 Usage — Local (stdio)
This is the simplest setup. Claude Desktop or Claude Code launches the server as a subprocess.
Claude Desktop
Add to your claude_desktop_config.json:
| OS | Config path |
|---|---|
| macOS | ~/Library/Application Support/Claude/claude_desktop_config.json |
| Windows | %APPDATA%\Claude\claude_desktop_config.json |
| Linux | ~/.config/claude/claude_desktop_config.json |
{
"mcpServers": {
"github": {
"command": "python",
"args": ["/path/to/github-mcp/server.py"],
"cwd": "/path/to/github-mcp"
}
}
}
Restart Claude Desktop after adding the configuration.
Claude Code
claude mcp add github -- python /path/to/github-mcp/server.py
🌐 Usage — Remote (SSE + OAuth)
For remote access, the server runs an SSE endpoint with OAuth 2.0 authentication, exposed via an ngrok tunnel.
Step 1: Start an ngrok tunnel
ngrok http 8080
# Note the HTTPS forwarding URL, e.g. https://abc123.ngrok-free.app
Or use the included helper scripts:
# Linux/macOS
./tunnel.sh
# Windows (PowerShell)
.\tunnel.ps1
Step 2: Start the server in SSE mode
export MCP_TRANSPORT=sse
export MCP_PORT=8080
export MCP_SERVER_URL=https://abc123.ngrok-free.app # Your ngrok URL
python server.py
Step 3: Connect from Claude Desktop
{
"mcpServers": {
"github-remote": {
"url": "https://abc123.ngrok-free.app/sse"
}
}
}
The OAuth flow will prompt you to authorize when you first connect.
🛠️ Tools Reference
Auth (3)
| Tool | Description |
|---|---|
auth_status |
Check GitHub CLI authentication status |
whoami |
Get currently authenticated username |
switch_account |
Switch between GitHub accounts |
Repos (5)
| Tool | Description |
|---|---|
create_repo |
Create a new GitHub repository |
list_repos |
List repositories for a user/org |
repo_view |
View repository details |
clone_repo |
Clone a repository locally |
delete_repo |
Delete a repository (requires confirm=True) |
Git (4)
| Tool | Description |
|---|---|
git_status |
Get status of a local repository |
git_add_commit_push |
Add, commit, and push in one command |
git_init_and_push |
Initialize local dir, create GitHub repo, and push |
git_pull |
Pull latest changes from remote |
Branches (4)
| Tool | Description |
|---|---|
create_branch |
Create a new branch |
list_branches |
List branches in a repository |
switch_branch |
Switch to a different branch |
delete_branch |
Delete a branch |
Forks (2)
| Tool | Description |
|---|---|
fork_repo |
Fork a repository |
sync_fork |
Sync a fork with its upstream repository |
Issues (3)
| Tool | Description |
|---|---|
create_issue |
Create a new issue |
list_issues |
List repository issues |
comment_on_issue |
Add a comment to an issue |
Pull Requests (6)
| Tool | Description |
|---|---|
create_pr |
Create a pull request |
list_prs |
List pull requests |
comment_on_pr |
Add a comment to a PR |
merge_pr |
Merge a pull request |
review_pr |
Submit a review on a PR |
pr_diff |
View the diff of a pull request |
Collaborators (2)
| Tool | Description |
|---|---|
list_collaborators |
List collaborators on a repository |
add_collaborator |
Add a collaborator to a repository |
File Operations (2)
| Tool | Description |
|---|---|
get_file_contents |
Get the contents of a file from a repository |
create_or_update_file |
Create or update a file in a repository |
Gists (1)
| Tool | Description |
|---|---|
create_gist |
Create a GitHub gist |
Workflows (4)
| Tool | Description |
|---|---|
list_workflows |
List GitHub Actions workflows for a repo |
run_workflow |
Trigger a workflow dispatch event |
list_workflow_runs |
List recent workflow runs |
view_workflow_run |
View details of a specific workflow run |
Search (1)
| Tool | Description |
|---|---|
search_repos |
Search GitHub repositories |
Releases (2)
| Tool | Description |
|---|---|
create_release |
Create a new GitHub release |
list_releases |
List releases for a repository |
🔒 Security
Path Sandboxing
All local file operations are restricted to the WORK_DIR directory (default: ~/projects). Any path outside this directory is rejected, preventing unauthorized filesystem access.
Input Validation
Repository names, usernames, branch names, and file paths are validated against strict regex patterns to prevent injection attacks.
Read-Only Mode
Set READ_ONLY=true to restrict the server to safe, non-destructive operations only (list, view, search). All write operations will be blocked.
Audit Logging
Every tool invocation is logged with parameters to mcp_audit.log (configurable via LOG_FILE), providing a full audit trail of all operations.
OAuth 2.0 (Remote Mode)
When running in SSE mode, the server requires OAuth 2.0 authentication with configurable scopes (read, write). Client registration and token revocation are supported.
Dangerous Operation Confirmation
Destructive operations like delete_repo require an explicit confirm=True parameter to prevent accidental data loss.
⚙️ Configuration
| Variable | Description | Default |
|---|---|---|
WORK_DIR |
Base directory for git operations (path sandbox root) | ~/projects |
READ_ONLY |
Block all write operations when true |
false |
LOG_FILE |
Path to the audit log file | mcp_audit.log |
MCP_TRANSPORT |
Transport mode: stdio or sse |
stdio |
MCP_PORT |
Port for SSE server | 8080 |
MCP_SERVER_URL |
Public URL for OAuth issuer (ngrok URL) | http://localhost:8080 |
🏗️ Architecture
github-mcp/
├── server.py # Main MCP server — all 39 tools
├── oauth_provider.py # In-memory OAuth 2.0 provider (SSE mode)
├── requirements.txt # mcp[cli], uvicorn, starlette
├── tunnel.sh # ngrok tunnel helper (Linux/macOS)
├── tunnel.ps1 # ngrok tunnel helper (Windows)
├── README.md
├── LICENSE
└── .claude/
└── CLAUDE.md # Claude Code project instructions
📝 License
MIT License — See LICENSE for details.
👤 Author
Prateek Aryan — @prateekaryann
Built for seamless GitHub integration with Claude.
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。