GitHub MCP Server
# š GitHub MCP Server
> **MCP server for GitHub operations ā 73 tools for repos, PRs, issues, actions, releases, search, and more.**
A comprehensive [Model Context Protocol (MCP)](https://modelcontextprotocol.io/) server that exposes the full GitHub REST API as AI-ready tools. Connect your AI assistant (Cursor, Claude Desktop, or any MCP client) to manage GitHub through natural language.
Author: **Pawan Gunjkar** (pawangunjkar@gmail.com)
---
## š„ Install
### Option 1: PyPI / uvx (Recommended)
No clone required ā install and run directly:
```bash
uvx pawangunjkar-github-mcp
```
**Cursor / Claude Desktop** ā add to `.cursor/mcp.json` or `claude_desktop_config.json`:
```json
{
"mcpServers": {
"github": {
"command": "uvx",
"args": ["pawangunjkar-github-mcp"],
"env": {
"GITHUB_TOKEN": "ghp_your-token-here",
"GITHUB_PROTOCOL": "ssh"
}
}
}
}
```
### Option 2: Smithery
```bash
npx -y @smithery/cli install github-mcp --client cursor
```
Or browse [smithery.ai](https://smithery.ai) and search for **github-mcp**.
### Option 3: Clone from GitHub
```bash
git clone https://github.com/Pawangunjkar/github-mcp.git
cd github-mcp
uv sync
uv run server.py
```
> See [PUBLISHING.md](PUBLISHING.md) for PyPI, Smithery, and directory submission steps.
---
## ⨠Features
- š **73 tools** across **12 categories** ā full GitHub API coverage
- š **PAT authentication** ā Personal Access Token with Bearer auth
- š **SSH + HTTPS** ā supports both clone/push protocols
- š **Auto-pagination** ā transparently handles paginated API responses
- ā” **Rate limit aware** ā tracks and warns on low rate limits
- š¾ **Credential caching** ā auto-connect from env vars or cached credentials
- š¢ **GitHub Enterprise** ā configurable API URL for GHE servers
- šÆ **Zero configuration** ā just set env vars and run
---
## š Quick Start
### Prerequisites
- **Python 3.10+**
- **[uv](https://docs.astral.sh/uv/)** package manager
- **GitHub account** with a Personal Access Token
### 1. Clone & Install
```bash
cd github-mcp
uv sync
```
### 2. Configure Credentials
**Option A: Environment Variables (Recommended)**
```bash
cp .env.example .env
# Set your GitHub PAT
GITHUB_TOKEN=ghp_your-personal-access-token
GITHUB_PROTOCOL=ssh # or 'https'
```
**Option B: Connect via chat**
```
github_connect(token="ghp_xxxxxxxxxxxx", protocol="ssh")
```
### 3. Generate a Personal Access Token
1. Go to **GitHub** ā **Settings** ā **Developer settings** ā **Personal access tokens**
2. Click **"Generate new token"** (classic)
3. Select scopes: `repo`, `workflow`, `read:org`, `gist`, `notifications`, `delete_repo`
4. Click **Generate** and copy the token
### 4. Run the Server
```bash
# For Cursor / Claude Desktop (stdio transport)
uv run server.py
# For testing with MCP Inspector
uv run mcp dev server.py
```
---
## š ļø Tool Reference (73 Tools)
### Category 1: Connection & Authentication (4 tools)
| Tool | Description |
|------|-------------|
| `github_connect` | Connect with Personal Access Token |
| `github_disconnect` | Disconnect current session |
| `github_status` | Show connection status, user info, rate limits |
| `github_save_credentials` | Save credentials to disk cache |
### Category 2: Repository Management (10 tools)
| Tool | Description |
|------|-------------|
| `github_list_repos` | List repos for authenticated user or any user/org |
| `github_get_repo` | Get detailed repo info (stars, forks, languages) |
| `github_create_repo` | Create a new repository |
| `github_delete_repo` | Delete a repository permanently |
| `github_fork_repo` | Fork a repository |
| `github_update_repo` | Update repo settings (description, visibility) |
| `github_list_topics` | Get repo topics/tags |
| `github_update_topics` | Set repo topics/tags |
| `github_list_languages` | Get language breakdown |
| `github_list_contributors` | List repo contributors |
### Category 3: Branch & Tag Management (8 tools)
| Tool | Description |
|------|-------------|
| `github_list_branches` | List all branches |
| `github_get_branch` | Get branch details and protection status |
| `github_create_branch` | Create a new branch from a ref |
| `github_delete_branch` | Delete a branch |
| `github_protect_branch` | Set branch protection rules |
| `github_list_tags` | List all tags |
| `github_create_tag` | Create a lightweight or annotated tag |
| `github_compare_branches` | Compare two branches (ahead/behind, diff) |
### Category 4: File & Content Operations (6 tools)
| Tool | Description |
|------|-------------|
| `github_get_file` | Get file content (auto-decodes base64) |
| `github_create_file` | Create a new file via commit |
| `github_update_file` | Update a file via commit |
| `github_delete_file` | Delete a file via commit |
| `github_get_tree` | Get directory tree listing |
| `github_get_clone_url` | Get SSH or HTTPS clone URL |
### Category 5: Pull Requests (10 tools)
| Tool | Description |
|------|-------------|
| `github_list_prs` | List pull requests (open, closed, all) |
| `github_get_pr` | Get PR details (diff stats, reviews, status) |
| `github_create_pr` | Create a new pull request |
| `github_update_pr` | Update PR title, body, base branch |
| `github_merge_pr` | Merge a PR (merge, squash, or rebase) |
| `github_close_pr` | Close a PR without merging |
| `github_list_pr_files` | List files changed in a PR |
| `github_list_pr_reviews` | List reviews on a PR |
| `github_request_reviewers` | Request reviewers for a PR |
| `github_create_pr_comment` | Add a comment on a PR |
### Category 6: Issues (8 tools)
| Tool | Description |
|------|-------------|
| `github_list_issues` | List issues with filters (state, labels, assignee) |
| `github_get_issue` | Get issue details |
| `github_create_issue` | Create a new issue |
| `github_update_issue` | Update issue title, body, labels, assignees |
| `github_close_issue` | Close an issue |
| `github_create_issue_comment` | Add a comment on an issue |
| `github_list_issue_comments` | List comments on an issue |
| `github_add_labels` | Add labels to an issue/PR |
### Category 7: Actions & Workflows (7 tools)
| Tool | Description |
|------|-------------|
| `github_list_workflows` | List all workflows in a repo |
| `github_trigger_workflow` | Trigger a workflow dispatch event |
| `github_list_workflow_runs` | List workflow runs |
| `github_get_workflow_run` | Get details of a specific run |
| `github_get_run_logs` | Get workflow run logs |
| `github_cancel_workflow_run` | Cancel a running workflow |
| `github_rerun_workflow` | Re-run a workflow |
### Category 8: Releases (5 tools)
| Tool | Description |
|------|-------------|
| `github_list_releases` | List all releases |
| `github_get_release` | Get release details and assets |
| `github_create_release` | Create a release (with auto-generated notes) |
| `github_delete_release` | Delete a release |
| `github_get_latest_release` | Get the latest release |
### Category 9: Users & Organizations (5 tools)
| Tool | Description |
|------|-------------|
| `github_get_user` | Get user profile info |
| `github_list_user_repos` | List repos for a specific user |
| `github_get_org` | Get organization info |
| `github_list_org_repos` | List repos for an organization |
| `github_list_org_members` | List organization members |
### Category 10: Search (4 tools)
| Tool | Description |
|------|-------------|
| `github_search_repos` | Search repositories (with qualifiers) |
| `github_search_code` | Search code across GitHub |
| `github_search_issues` | Search issues and PRs |
| `github_search_users` | Search users and organizations |
### Category 11: Gists (4 tools)
| Tool | Description |
|------|-------------|
| `github_list_gists` | List gists |
| `github_create_gist` | Create a new gist |
| `github_get_gist` | Get gist content and details |
| `github_delete_gist` | Delete a gist |
### Category 12: Webhooks & Notifications (2 tools)
| Tool | Description |
|------|-------------|
| `github_list_notifications` | List unread notifications |
| `github_mark_notifications_read` | Mark notifications as read |
---
## š SSH vs HTTPS Support
The server supports both protocols. Set your preference via:
- **Environment variable**: `GITHUB_PROTOCOL=ssh` (or `https`)
- **Connection parameter**: `github_connect(token="...", protocol="ssh")`
| Feature | SSH | HTTPS |
|---------|-----|-------|
| Clone URL | `git@github.com:user/repo.git` | `https://github.com/user/repo.git` |
| Auth | SSH key on machine | PAT or credential helper |
| Default | ā
Preferred | Fallback |
Tools like `github_create_repo`, `github_fork_repo`, and `github_get_clone_url` return URLs in both formats.
---
## āļø Configuration
### Environment Variables
| Variable | Required | Default | Description |
|----------|----------|---------|-------------|
| `GITHUB_TOKEN` | Yes | ā | Personal Access Token |
| `GITHUB_API_URL` | No | `https://api.github.com` | API URL (change for GitHub Enterprise) |
| `GITHUB_PROTOCOL` | No | `ssh` | Preferred clone protocol (`ssh` or `https`) |
| `GITHUB_TIMEOUT` | No | `30` | Request timeout in seconds |
| `GITHUB_MCP_CACHE_DIR` | No | `~/.github-mcp-cache` | Credential cache directory |
### Cursor Integration
Add to `.cursor/mcp.json`:
```json
{
"mcpServers": {
"github": {
"command": "uvx",
"args": ["pawangunjkar-github-mcp"],
"env": {
"GITHUB_TOKEN": "ghp_your-token-here",
"GITHUB_PROTOCOL": "ssh"
}
}
}
}
```
**Alternative (from source):**
```json
{
"mcpServers": {
"github": {
"command": "uv",
"args": ["run", "--directory", "/path/to/github-mcp", "server.py"],
"env": {
"GITHUB_TOKEN": "ghp_your-token-here",
"GITHUB_PROTOCOL": "ssh"
}
}
}
}
```
### Claude Desktop Integration
Add to `claude_desktop_config.json`:
```json
{
"mcpServers": {
"github": {
"command": "uvx",
"args": ["pawangunjkar-github-mcp"],
"env": {
"GITHUB_TOKEN": "ghp_your-token-here",
"GITHUB_PROTOCOL": "ssh"
}
}
}
}
```
---
## š” Example Usage
### Repository Management
```
"List all my repos sorted by recent activity"
ā github_list_repos(sort="updated")
"Show me the details of the linux-ssh-mcp repo"
ā github_get_repo(owner="Pawangunjkar", repo="linux-ssh-mcp")
"Fork the fastapi repo to my account"
ā github_fork_repo(owner="tiangolo", repo="fastapi")
```
### Pull Requests & Code Review
```
"Create a PR from feature-branch to main"
ā github_create_pr(owner="me", repo="my-app", title="Add login feature", head="feature-branch", base="main")
"Show me the files changed in PR #42"
ā github_list_pr_files(owner="me", repo="my-app", pr_number=42)
"Merge PR #42 with squash"
ā github_merge_pr(owner="me", repo="my-app", pr_number=42, merge_method="squash")
```
### GitHub Actions
```
"Trigger the deploy workflow on main branch"
ā github_trigger_workflow(owner="me", repo="my-app", workflow_id="deploy.yml", ref="main")
"Show recent workflow runs"
ā github_list_workflow_runs(owner="me", repo="my-app")
"Cancel the running workflow"
ā github_cancel_workflow_run(owner="me", repo="my-app", run_id=12345)
```
### Search
```
"Find popular Python MCP servers on GitHub"
ā github_search_repos(query="mcp server language:python stars:>10")
"Search for FastMCP usage in code"
ā github_search_code(query="FastMCP language:python")
```
---
## š Project Structure
```
github-mcp/
āāā server.py # Main MCP server ā 73 tool definitions
āāā github_client.py # GitHub REST API client (HTTP, auth, pagination)
āāā credential_store.py # Credential caching (env vars, memory, file)
āāā pyproject.toml # Project metadata & dependencies
āāā .env.example # Example environment variables
āāā .gitignore # Python gitignore
āāā LICENSE # MIT license
āāā README.md # This file
```
---
## š Security Notes
- **PAT tokens** are stored in `~/.github-mcp-cache/credentials.json` with restrictive file permissions (600)
- **Never commit** `.env` files or tokens to version control
- Use **fine-grained tokens** when possible for minimum required access
- The server tracks **rate limits** and warns when running low
---
## š License
MIT License ā see [LICENSE](LICENSE) for details.
TDQS
Scored across 73 tools
Multiple tools have overlapping purposes, such as github_list_repos, github_list_user_repos, and github_list_org_repos, where the first already supports owner filtering. Similarly, close_issue and close_pr duplicate the state-changing capabilities of update_issue and update_pr, creating ambiguity about the preferred tool. While descriptions are clear, the boundaries between these tools are not distinct enough for an agent to reliably choose.
All tool names follow a consistent 'github_verb_noun' pattern using snake_case, such as github_list_repos, github_create_branch, and github_merge_pr. The prefix and verb-first structure are uniform across the entire set, making the naming highly predictable and easy to navigate.
With 73 tools, this server vastly exceeds the typical 3-15 tool range and even the 50+ extreme threshold. Many tools are redundant or could be consolidated (e.g., repo listing variants, close vs update), inflating the count and overwhelming agents with too many choices.
The server provides broad coverage across repos, branches, files, PRs, issues, workflows, releases, users, search, gists, and notifications. However, notable gaps exist, such as lack of commit history APIs, no update for gists or releases, and no PR review submission, which are significant for a complete GitHub lifecycle.