github-mcp-server
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
Chinesegithub-mcp-server
github-mcp-server
Skill by ara.so — MCP Skills collection.
The GitHub MCP Server is GitHub's official Model Context Protocol server that connects AI tools directly to GitHub's platform. It enables AI agents to read repositories, manage issues and PRs, analyze code, monitor CI/CD pipelines, and automate workflows through natural language interactions.
由ara.so提供的Skill — MCP Skills合集。
GitHub MCP Server是GitHub官方的模型上下文协议(Model Context Protocol)服务器,可将AI工具直接连接到GitHub平台。它支持AI Agent通过自然语言交互读取仓库、管理Issue和PR、分析代码、监控CI/CD流水线并自动化工作流。
What It Does
功能介绍
- Repository Management: Browse code, search files, analyze commits, understand project structure
- Issue & PR Automation: Create, update, and manage issues and pull requests
- CI/CD Intelligence: Monitor GitHub Actions, analyze build failures, manage releases
- Code Analysis: Review security findings, Dependabot alerts, code patterns
- Team Collaboration: Access discussions, manage notifications, analyze team activity
- 仓库管理:浏览代码、搜索文件、分析提交、了解项目结构
- Issue与PR自动化:创建、更新和管理Issue与拉取请求(PR)
- CI/CD智能监控:监控GitHub Actions、分析构建失败原因、管理版本发布
- 代码分析:查看安全检测结果、Dependabot告警、代码模式
- 团队协作:访问讨论内容、管理通知、分析团队活动
Installation
安装
Remote Server (Recommended)
远程服务器(推荐)
The remote GitHub MCP Server is hosted by GitHub and requires no local installation.
远程GitHub MCP Server由GitHub托管,无需本地安装。
VS Code (1.101+)
VS Code(1.101及以上版本)
Using OAuth (Recommended):
json
{
"servers": {
"github": {
"type": "http",
"url": "https://api.githubcopilot.com/mcp/"
}
}
}Using GitHub PAT:
json
{
"servers": {
"github": {
"type": "http",
"url": "https://api.githubcopilot.com/mcp/",
"headers": {
"Authorization": "Bearer ${input:github_mcp_pat}"
}
}
},
"inputs": [
{
"type": "promptString",
"id": "github_mcp_pat",
"description": "GitHub Personal Access Token",
"password": true
}
]
}使用OAuth(推荐):
json
{
"servers": {
"github": {
"type": "http",
"url": "https://api.githubcopilot.com/mcp/"
}
}
}使用GitHub PAT:
json
{
"servers": {
"github": {
"type": "http",
"url": "https://api.githubcopilot.com/mcp/",
"headers": {
"Authorization": "Bearer ${input:github_mcp_pat}"
}
}
},
"inputs": [
{
"type": "promptString",
"id": "github_mcp_pat",
"description": "GitHub Personal Access Token",
"password": true
}
]
}Claude Desktop
Claude Desktop
json
{
"mcpServers": {
"github": {
"url": "https://api.githubcopilot.com/mcp/",
"headers": {
"Authorization": "Bearer YOUR_GITHUB_PAT"
}
}
}
}Note: Replace with if your host supports environment variables.
YOUR_GITHUB_PAT${GITHUB_PAT}json
{
"mcpServers": {
"github": {
"url": "https://api.githubcopilot.com/mcp/",
"headers": {
"Authorization": "Bearer YOUR_GITHUB_PAT"
}
}
}
}注意:如果你的宿主环境支持环境变量,请将替换为。
YOUR_GITHUB_PAT${GITHUB_PAT}Cursor
Cursor
json
{
"mcpServers": {
"github": {
"type": "http",
"url": "https://api.githubcopilot.com/mcp/",
"headers": {
"Authorization": "Bearer ${GITHUB_PAT}"
}
}
}
}json
{
"mcpServers": {
"github": {
"type": "http",
"url": "https://api.githubcopilot.com/mcp/",
"headers": {
"Authorization": "Bearer ${GITHUB_PAT}"
}
}
}
}Local Server (Docker)
本地服务器(Docker)
For hosts without remote MCP support or GitHub Enterprise Server:
json
{
"servers": {
"github": {
"command": "docker",
"args": [
"run",
"-i",
"--rm",
"-e",
"GITHUB_PERSONAL_ACCESS_TOKEN",
"ghcr.io/github/github-mcp-server"
],
"env": {
"GITHUB_PERSONAL_ACCESS_TOKEN": "${GITHUB_PAT}"
}
}
}
}适用于不支持远程MCP或使用GitHub Enterprise Server的环境:
json
{
"servers": {
"github": {
"command": "docker",
"args": [
"run",
"-i",
"--rm",
"-e",
"GITHUB_PERSONAL_ACCESS_TOKEN",
"ghcr.io/github/github-mcp-server"
],
"env": {
"GITHUB_PERSONAL_ACCESS_TOKEN": "${GITHUB_PAT}"
}
}
}
}Authentication
身份验证
Creating a GitHub Personal Access Token (PAT)
创建GitHub个人访问令牌(PAT)
- Go to https://github.com/settings/personal-access-tokens/new
- Select permissions based on your needs:
- - Full repository access (read/write code, issues, PRs)
repo - - Read organization data
read:org - - Update GitHub Actions workflows
workflow - - Manage organization (if needed)
admin:org
- Generate token and store securely
- Set as environment variable:
bash
export GITHUB_PAT=ghp_yourTokenHere
- 访问https://github.com/settings/personal-access-tokens/new
- 根据需求选择权限:
- - 完整仓库访问权限(读写代码、Issue、PR)
repo - - 读取组织数据
read:org - - 更新GitHub Actions工作流
workflow - - 管理组织(如需)
admin:org
- 生成令牌并安全存储
- 设置为环境变量:
bash
export GITHUB_PAT=ghp_yourTokenHere
Token Security
令牌安全
Store tokens in environment variables, never hardcode:
bash
undefined将令牌存储在环境变量中,切勿硬编码:
bash
undefined.env file
.env文件
GITHUB_PAT=ghp_yourTokenHere
GITHUB_PAT=ghp_yourTokenHere
Add to .gitignore
添加到.gitignore
echo ".env" >> .gitignore
undefinedecho ".env" >> .gitignore
undefinedConfiguration
配置
Toolsets
工具集
Configure which GitHub APIs are available:
json
{
"servers": {
"github": {
"type": "http",
"url": "https://api.githubcopilot.com/mcp/",
"headers": {
"X-GitHub-MCP-Toolsets": "repos,issues,pulls"
}
}
}
}Available Toolsets:
- - Repository operations
repos - - Issue management
issues - - Pull request operations
pulls - - GitHub Actions workflows
actions - - Code and repository search
search - - Gist management
gists - - Notification access
notifications
Default Toolset (when not specified):
repos,issues,pulls,actions,search配置可用的GitHub API:
json
{
"servers": {
"github": {
"type": "http",
"url": "https://api.githubcopilot.com/mcp/",
"headers": {
"X-GitHub-MCP-Toolsets": "repos,issues,pulls"
}
}
}
}可用工具集:
- - 仓库操作
repos - - Issue管理
issues - - 拉取请求操作
pulls - - GitHub Actions工作流
actions - - 代码与仓库搜索
search - - Gist管理
gists - - 通知访问
notifications
默认工具集(未指定时):
repos,issues,pulls,actions,searchGitHub Enterprise Cloud (ghe.com)
GitHub Enterprise Cloud (ghe.com)
json
{
"servers": {
"github-enterprise": {
"type": "http",
"url": "https://copilot-api.octocorp.ghe.com/mcp",
"headers": {
"Authorization": "Bearer ${GITHUB_ENTERPRISE_PAT}"
}
}
}
}json
{
"servers": {
"github-enterprise": {
"type": "http",
"url": "https://copilot-api.octocorp.ghe.com/mcp",
"headers": {
"Authorization": "Bearer ${GITHUB_ENTERPRISE_PAT}"
}
}
}
}GitHub Enterprise Server
GitHub Enterprise Server
json
{
"servers": {
"github-ghes": {
"command": "docker",
"args": [
"run",
"-i",
"--rm",
"-e",
"GITHUB_PERSONAL_ACCESS_TOKEN",
"-e",
"GITHUB_HOST",
"ghcr.io/github/github-mcp-server"
],
"env": {
"GITHUB_PERSONAL_ACCESS_TOKEN": "${GITHUB_PAT}",
"GITHUB_HOST": "https://github.yourcompany.com"
}
}
}
}json
{
"servers": {
"github-ghes": {
"command": "docker",
"args": [
"run",
"-i",
"--rm",
"-e",
"GITHUB_PERSONAL_ACCESS_TOKEN",
"-e",
"GITHUB_HOST",
"ghcr.io/github/github-mcp-server"
],
"env": {
"GITHUB_PERSONAL_ACCESS_TOKEN": "${GITHUB_PAT}",
"GITHUB_HOST": "https://github.yourcompany.com"
}
}
}
}Insiders Mode
内测模式
Access experimental features:
Via URL:
json
{
"servers": {
"github": {
"type": "http",
"url": "https://api.githubcopilot.com/mcp/insiders"
}
}
}Via Header:
json
{
"servers": {
"github": {
"type": "http",
"url": "https://api.githubcopilot.com/mcp/",
"headers": {
"X-MCP-Insiders": "true"
}
}
}
}访问实验性功能:
通过URL:
json
{
"servers": {
"github": {
"type": "http",
"url": "https://api.githubcopilot.com/mcp/insiders"
}
}
}通过请求头:
json
{
"servers": {
"github": {
"type": "http",
"url": "https://api.githubcopilot.com/mcp/",
"headers": {
"X-MCP-Insiders": "true"
}
}
}
}Usage Patterns
使用场景
Repository Operations
仓库操作
List repository files:
Show me all Python files in github/github-mcp-serverRead file contents:
Show me the contents of main.go in github/github-mcp-serverSearch code:
Find all functions that use the GitHub API in github/github-mcp-serverAnalyze commits:
Show recent commits in github/github-mcp-server main branch列出仓库文件:
Show me all Python files in github/github-mcp-server读取文件内容:
Show me the contents of main.go in github/github-mcp-server搜索代码:
Find all functions that use the GitHub API in github/github-mcp-server分析提交记录:
Show recent commits in github/github-mcp-server main branchIssue Management
Issue管理
List issues:
Show open issues in github/github-mcp-server labeled as bugCreate issue:
Create an issue in github/github-mcp-server titled "Add support for X" with description "We need X because..."Update issue:
Add comment to issue #123 in github/github-mcp-server saying "Working on this"Close issue:
Close issue #456 in github/github-mcp-server列出Issue:
Show open issues in github/github-mcp-server labeled as bug创建Issue:
Create an issue in github/github-mcp-server titled "Add support for X" with description "We need X because..."更新Issue:
Add comment to issue #123 in github/github-mcp-server saying "Working on this"关闭Issue:
Close issue #456 in github/github-mcp-serverPull Request Operations
拉取请求操作
List PRs:
Show all open pull requests in github/github-mcp-serverCreate PR:
Create a pull request in github/github-mcp-server from feature-branch to main with title "Add new feature"Review PR:
Show me the diff for PR #789 in github/github-mcp-serverMerge PR:
Merge pull request #101 in github/github-mcp-server列出PR:
Show all open pull requests in github/github-mcp-server创建PR:
Create a pull request in github/github-mcp-server from feature-branch to main with title "Add new feature"评审PR:
Show me the diff for PR #789 in github/github-mcp-server合并PR:
Merge pull request #101 in github/github-mcp-serverGitHub Actions
GitHub Actions
List workflows:
Show all GitHub Actions workflows in github/github-mcp-serverView workflow runs:
Show recent workflow runs for CI in github/github-mcp-serverAnalyze failures:
Why did the latest build fail in github/github-mcp-server?Trigger workflow:
Trigger the deploy workflow in github/github-mcp-server列出工作流:
Show all GitHub Actions workflows in github/github-mcp-server查看工作流运行记录:
Show recent workflow runs for CI in github/github-mcp-server分析构建失败原因:
Why did the latest build fail in github/github-mcp-server?触发工作流:
Trigger the deploy workflow in github/github-mcp-serverCode Analysis
代码分析
Security alerts:
Show Dependabot alerts for github/github-mcp-serverCode search across organization:
Find all repositories in github org using deprecated APIAnalyze repository structure:
What's the directory structure of github/github-mcp-server?安全告警:
Show Dependabot alerts for github/github-mcp-server跨组织代码搜索:
Find all repositories in github org using deprecated API分析仓库结构:
What's the directory structure of github/github-mcp-server?Common Patterns
常见使用模式
Multi-Repository Analysis
多仓库分析
Compare the CI/CD setup between github/repo1 and github/repo2Compare the CI/CD setup between github/repo1 and github/repo2Automated Triage
自动分类
Label all open issues in github/github-mcp-server that mention "authentication" with "auth"Label all open issues in github/github-mcp-server that mention "authentication" with "auth"Release Management
版本发布管理
Create a release for github/github-mcp-server version 2.0.0 with notes from recent PRsCreate a release for github/github-mcp-server version 2.0.0 with notes from recent PRsTeam Coordination
团队协作
Show me all PRs assigned to me across github organizationShow me all PRs assigned to me across github organizationCode Review Assistance
代码评审辅助
Review PR #234 in github/github-mcp-server and suggest improvementsReview PR #234 in github/github-mcp-server and suggest improvementsTroubleshooting
故障排查
Connection Issues
连接问题
Problem: Server not connecting
Error: Unable to connect to GitHub MCP serverSolution: Verify server configuration
- Check URL is correct:
https://api.githubcopilot.com/mcp/ - For local Docker: Ensure Docker is running
- Restart your IDE/MCP host
问题:服务器无法连接
Error: Unable to connect to GitHub MCP server解决方案:验证服务器配置
- 检查URL是否正确:
https://api.githubcopilot.com/mcp/ - 本地Docker环境:确保Docker正在运行
- 重启你的IDE/MCP宿主环境
Authentication Failures
身份验证失败
Problem: 401 Unauthorized
Error: Authentication failedSolution: Verify token
- Check PAT is valid: https://github.com/settings/tokens
- Ensure token has required scopes
- Verify environment variable is set correctly:
bash
echo $GITHUB_PAT - Restart MCP host after updating token
问题:401 Unauthorized
Error: Authentication failed解决方案:验证令牌
- 检查PAT是否有效:访问https://github.com/settings/tokens
- 确保令牌拥有所需权限
- 验证环境变量是否正确设置:
bash
echo $GITHUB_PAT - 更新令牌后重启MCP宿主环境
Permission Errors
权限错误
Problem: 403 Forbidden or 404 Not Found
Error: Resource not accessibleSolution: Check token permissions
- Verify PAT has required scope (e.g., for private repos)
repo - Confirm you have access to the repository
- For organizations, check if SSO is required:
- Go to https://github.com/settings/tokens
- Click "Configure SSO" next to your token
- Authorize the organization
问题:403 Forbidden或404 Not Found
Error: Resource not accessible解决方案:检查令牌权限
- 验证PAT拥有所需权限(例如,私有仓库需要权限)
repo - 确认你拥有该仓库的访问权限
- 针对组织,检查是否需要SSO:
- 访问https://github.com/settings/tokens
- 点击令牌旁的"Configure SSO"
- 授权该组织
Docker Issues
Docker问题
Problem: Image pull failed
Error: failed to pull ghcr.io/github/github-mcp-serverSolution:
- Check Docker is running:
docker ps - Logout if you have expired credentials:
bash
docker logout ghcr.io - Pull manually to test:
bash
docker pull ghcr.io/github/github-mcp-server
问题:镜像拉取失败
Error: failed to pull ghcr.io/github/github-mcp-server解决方案:
- 检查Docker是否正在运行:
docker ps - 如果凭证过期,登出:
bash
docker logout ghcr.io - 手动拉取测试:
bash
docker pull ghcr.io/github/github-mcp-server
Rate Limiting
速率限制
Problem: API rate limit exceeded
Error: API rate limit exceededSolution: Authenticated requests have higher limits
- Ensure PAT is properly configured
- Wait for rate limit reset (check response headers)
- For heavy usage, consider GitHub Apps instead of PATs
问题:API速率限制超出
Error: API rate limit exceeded解决方案:已认证请求拥有更高限制
- 确保PAT已正确配置
- 等待速率限制重置(查看响应头)
- 对于高频使用场景,考虑使用GitHub Apps替代PAT
Enterprise Server Connection
Enterprise Server连接问题
Problem: Cannot connect to GitHub Enterprise Server
Error: Connection timeoutSolution: Check GITHUB_HOST configuration
- Ensure URL includes scheme:
https://json"GITHUB_HOST": "https://github.company.com" - Verify server is accessible from your network
- Check firewall/VPN settings
问题:无法连接到GitHub Enterprise Server
Error: Connection timeout解决方案:检查GITHUB_HOST配置
- 确保URL包含协议:
https://json"GITHUB_HOST": "https://github.company.com" - 验证服务器在你的网络中可访问
- 检查防火墙/VPN设置
Toolset Not Available
工具集不可用
Problem: Tool not found
Error: Tool 'create_gist' not availableSolution: Enable required toolset
json
{
"headers": {
"X-GitHub-MCP-Toolsets": "repos,issues,pulls,gists"
}
}问题:工具未找到
Error: Tool 'create_gist' not available解决方案:启用所需工具集
json
{
"headers": {
"X-GitHub-MCP-Toolsets": "repos,issues,pulls,gists"
}
}VS Code Integration Issues
VS Code集成问题
Problem: Server not appearing in VS Code
Server 'github' not foundSolution:
- Ensure VS Code version is 1.101+
- Reload VS Code: Cmd/Ctrl + Shift + P → "Developer: Reload Window"
- Check settings location: or user settings
.vscode/settings.json - Enable Agent mode in Copilot Chat
问题:服务器未在VS Code中显示
Server 'github' not found解决方案:
- 确保VS Code版本为1.101及以上
- 重新加载VS Code:Cmd/Ctrl + Shift + P → "开发者:重新加载窗口"
- 检查设置位置:或用户设置
.vscode/settings.json - 在Copilot Chat中启用Agent模式
Environment Variable Not Resolved
环境变量未解析
Problem: Token showing as literal string
Authorization: Bearer ${GITHUB_PAT}Solution: Host-specific syntax
- Some hosts use
${GITHUB_PAT} - Others use
${input:github_token} - Some require hardcoded values
- Check host documentation for variable syntax
问题:令牌显示为字面字符串
Authorization: Bearer ${GITHUB_PAT}解决方案:根据宿主环境使用对应语法
- 部分宿主使用
${GITHUB_PAT} - 其他宿主使用
${input:github_token} - 部分环境需要硬编码值
- 查看宿主文档了解变量语法
Testing Connection
测试连接
Verify server is working:
List repositories in github organizationIf successful, you should see a list of repositories. If not, check logs in your MCP host.
验证服务器是否正常工作:
List repositories in github organization如果成功,你将看到仓库列表。如果失败,请查看MCP宿主环境中的日志。