使用说明
mcp服务器github
一个MCP(模型上下文协议)服务器,提供与GitHub API交互的工具,包括存储库、问题、提取请求、代码搜索、分支和GitHub操作工作流。
建筑
graph TB
subgraph Client
style Client fill:#4A90D9,stroke:#2E6BA6,color:#FFFFFF
MCP_Client["MCP Client"]
end
subgraph Server["mcp-server-github"]
style Server fill:#2ECC71,stroke:#1A9B52,color:#FFFFFF
Index["index.ts<br/>MCP Server Entry"]
subgraph Tools
style Tools fill:#F39C12,stroke:#C67D0A,color:#FFFFFF
T1["list_repos"]
T2["create_issue"]
T3["list_pull_requests"]
T4["get_file_contents"]
T5["search_code"]
T6["create_branch"]
T7["list_workflows"]
T8["get_workflow_runs"]
end
end
subgraph External["GitHub API"]
style External fill:#24292E,stroke:#1B1F23,color:#FFFFFF
Repos["Repos API"]
Issues["Issues API"]
PRs["Pull Requests API"]
Contents["Contents API"]
Search["Search API"]
Git["Git Refs API"]
Actions["Actions API"]
end
MCP_Client -- "stdio transport" --> Index
Index --> T1 & T2 & T3 & T4 & T5 & T6 & T7 & T8
T1 --> Repos
T2 --> Issues
T3 --> PRs
T4 --> Contents
T5 --> Search
T6 --> Git
T7 --> Actions
T8 --> Actions
安装
npm install
npm run build
配置
| 变量 | 描述 | 必填 |
|---|---|---|
GITHUB_TOKEN |
GitHub个人访问令牌 | 是 |
用法
独立
GITHUB_TOKEN=ghp_xxxx npm start
发展
npm run dev
码头工人
docker build -t mcp-server-github .
docker run -e GITHUB_TOKEN=ghp_xxxx mcp-server-github
MCP客户端配置
{
"mcpServers": {
"github": {
"command": "node",
"args": ["dist/index.js"],
"env": {
"GITHUB_TOKEN": "ghp_xxxx"
}
}
}
}
工具参考
| 工具 | 说明 | 参数 |
|---|---|---|
list_repos |
列出存储库 | owner?, type?, sort? |
create_issue |
创建问题 | owner, repo, title, body?, labels?, assignees? |
list_pull_requests |
列出拉取请求 | owner, repo, state?, sort? |
get_file_contents |
获取文件内容 | owner, repo, path, ref? |
search_code |
搜索代码 | query, per_page? |
create_branch |
创建分支 | owner, repo, branch, from_branch? |
list_workflows |
列出工作流 | owner, repo |
get_workflow_runs |
运行工作流 | owner, repo, workflow_id, status? |
许可证
麻省理工学院
