GitHub MCP Server

GitHub MCP Server

Connects Claude to GitHub repositories for querying repos, reviewing PRs, managing issues, searching code, and automating workflows.

Category
访问服务器

README

GitHub MCP Server

A Model Context Protocol (MCP) server that connects Claude to your GitHub repositories. Query repos, review PRs, manage issues, search code, and automate GitHub workflows—all from Claude.

Features

Included Tools

  • list_repos — List your repositories with metadata (stars, language, etc.)
  • read_file — Read files from any repo (source code, docs, configs)
  • list_prs — Fetch pull requests with filtering (open/closed/all)
  • get_pr — Get PR details including full diff for code review
  • list_issues — Search and filter issues by state, labels, etc.
  • create_issue — File new issues programmatically
  • add_pr_comment — Add review comments to pull requests
  • search_code — Search code across repos using GitHub search syntax
  • get_repo_info — Fetch repo metadata (description, stars, topics, etc.)

Quick Start

1. Set Up Authentication

Create a GitHub Personal Access Token:

  1. Go to github.com/settings/personal-access-tokens
  2. Click Generate new token → Generate new token (fine-grained)
  3. Name it claude-mcp
  4. Under Repository access, select All repositories or specific repos
  5. Under Permissions, grant:
    • Contents: Read-only
    • Issues: Read & write (if you want to create issues)
    • Pull requests: Read & write (if you want to comment on PRs)
  6. Click Generate token and copy it

2. Install Dependencies

cd /Users/maywu/Projects/github-mcp-server
python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txt

3. Set Your GitHub Token

cp .env.example .env
# Edit .env and paste your token:
# GITHUB_TOKEN=ghp_xxxxx

Or set it directly:

export GITHUB_TOKEN="your_github_pat_here"

4. Connect to Claude Code

# From the project root:
claude mcp add --env GITHUB_TOKEN="your_github_pat_here" \
  --transport stdio github \
  -- python server.py

Verify it connected:

claude mcp list

You should see: ✓ github — 9 tools

Usage

Once connected, you can ask Claude to:

List my repositories
Review PR #456 and suggest improvements for anthropic/claude-code
Create an issue for the bug we just found in my-repo
Find all instances of TODO comments in my codebase
Read the CONTRIBUTING.md from owner/repo
List all open issues labeled 'bug' and 'critical' in my-org/my-repo

Local Development & Testing

Run the server directly (for debugging)

export GITHUB_TOKEN="your_token"
python server.py

You should see:

INFO:mcp.server:Started MCP server

If there are errors, you'll see them here.

Test a tool manually

Once connected to Claude Code, run:

claude

Then in the session:

Use the github server to list my repos and show me the 5 most recently updated ones

Claude will call the list_repos tool and display results.

Common Issues

"Error: GITHUB_TOKEN environment variable not set"

  • Make sure your token is exported: echo $GITHUB_TOKEN
  • If using Claude, pass it with --env: claude mcp add --env GITHUB_TOKEN="token" ...

"Error: Unauthorized (401)"

  • Your token may have expired or insufficient permissions
  • Generate a new token at github.com/settings/personal-access-tokens
  • Check that the token has Contents and Issues scopes enabled

"Timeout connecting to server"

  • The server may be crashing on startup. Run it directly to see errors: python server.py
  • Try increasing the timeout: MCP_TIMEOUT=60000 claude

Architecture

Server Structure

server.py
├── list_tools()          — Define all available tools
├── call_tool()           — Route tool calls to handlers
└── _<tool_name>()        — Handler for each tool (async)

Adding New Tools

To add a new GitHub operation:

  1. Add the tool definition in list_tools():
Tool(
    name="my_new_tool",
    description="What this tool does",
    inputSchema={
        "type": "object",
        "properties": {...},
        "required": [...]
    }
)
  1. Add a handler function:
async def _my_new_tool(arguments: dict) -> list[ToolResult]:
    # Your implementation here
    return [ToolResult(content=[TextContent(text="result")])]
  1. Add a route in call_tool():
elif name == "my_new_tool":
    return await _my_new_tool(arguments)

GitHub API Limits

  • Authenticated requests: 5,000/hour
  • Unauthenticated: 60/hour

This server always uses your token, so you get the 5,000/hour limit.

Security

  • Never commit your .env file or tokens to version control
  • Use fine-grained personal access tokens (not classic tokens)
  • Scope tokens to minimal required permissions
  • Rotate tokens regularly
  • If a token is leaked, revoke it immediately at github.com/settings/personal-access-tokens

Troubleshooting

Check server status

claude mcp list

Should show:

github (stdio)
  ✓ Connected
  9 tools available

View server logs

If running in Claude Code, check the MCP logs:

claude mcp logs github

Test the API directly

curl -H "Authorization: Bearer $GITHUB_TOKEN" \
  https://api.github.com/user/repos

Next Steps

  • Share with teammates: Commit .env.example and server.py to a project repo, have teammates set their own GITHUB_TOKEN
  • Deploy as a service: Run on a server and use --transport http instead of stdio
  • Add more tools: Extend with webhooks, actions, releases, discussions, etc.
  • Integrate with workflows: Build Claude-assisted code review, release notes generation, or issue triage

Resources

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选