Github Repos Manager Mcp

Github Repos Manager Mcp

🚀 GitHub Repos Manager MCP Server

这是一个全面的模型上下文协议(MCP)服务器,允许你的MCP客户端(如Claude Desktop、Roo Code、Cline、Cursor、Windsurf等)使用你的GitHub个人访问令牌与GitHub仓库进行交互。它基于令牌实现了GitHub自动化管理,无需Docker以实现最佳性能,并且提供灵活的配置,支持细粒度控制,拥有89个可直接集成API的工具。

🚀 快速开始

前提条件

  • Node.js(版本18或更高)
  • GitHub个人访问令牌(PAT):这是唯一需要配置的内容。你可以前往GitHub → 设置 → 开发者设置 → 个人访问令牌 → 令牌(经典)或细粒度令牌,生成一个至少具有以下作用域的新令牌:
    • repo(对私有仓库的完全控制):推荐用于完整功能。
    • user:readuser:email(用于读取用户个人资料数据)。
    • read:org(如果你需要访问组织信息)。

快速设置和MCP客户端配置

使用npx(最简单 - 无需安装!)

确保你已安装Node.js,然后使用 npx 直接运行服务器。检查你是否已将GitHub令牌导出为名为 GH_TOKEN 的环境变量,或者将其包含在你的MCP客户端配置中。

# 使用npx直接运行
npx -y github-repos-manager-mcp

对于macOS/Linux:

{
"mcpServers": {
"github-repos-manager": {
"command": "npx",
"args": [
"-y",
"github-repos-manager-mcp"
],
"env": {
"GH_TOKEN": "ghp_YOUR_ACTUAL_TOKEN_HERE"
}
}
}
}

对于Windows,某些情况下你可能需要使用npx.cmd而不是npx:

{
"mcpServers": {
"github-repos-manager": {
"command": "npx.cmd",
"args": [
"-y",
"github-repos-manager-mcp"
],
"env": {
"GH_TOKEN": "ghp_YOUR_ACTUAL_TOKEN_HERE"
}
}
}
}

此命令将自动下载并运行服务器的最新版本,无需在本地进行安装。

克隆、安装并在本地运行

如果你更喜欢在本地运行服务器,可以克隆仓库并安装依赖项:

git clone https://github.com/kurdin/github-repos-manager.git
cd github-repos-manager
npm install

然后,配置你的MCP客户端,使其指向 server.cjs 的完整路径:

{
"mcpServers": {
"github-repos-manager": {
"command": "node",
"args": ["/full/path/to/your/project/github-repos-manager-mcp/server.cjs"],
"env": {
"GH_TOKEN": "ghp_YOUR_ACTUAL_TOKEN_HERE"
}
}
}
}

重要提示:请将 "ghp_YOUR_ACTUAL_TOKEN_HERE" 替换为你实际的GitHub个人访问令牌。

测试服务器

一旦MCP客户端配置了正确的 server.cjs 路径和你的 GH_TOKEN,当客户端尝试使用其工具之一时,服务器应自动启动。 你也可以直接测试服务器脚本以进行基本身份验证,但这需要在你的shell中临时设置 GH_TOKEN 环境变量以进行此特定测试

# 仅用于直接脚本测试(正常操作使用MCP客户端配置)
export GH_TOKEN="ghp_YOUR_TEMPORARY_TEST_TOKEN"
node server.cjs
unset GH_TOKEN # 重要:测试后取消设置

如果成功,你应该会看到 "GitHub API authentication successful" 和 "GitHub Repos Manager MCP Server running on stdio"。

注意:服务器仅在你通过环境变量、命令行参数或使用 set_default_repo 工具明确配置时才会设置默认仓库,它不会自动设置默认仓库。

Claude Desktop claude_desktop_config.json 的示例文件位置

  • macOS~/Library/Application Support/Claude/claude_desktop_config.json
  • Windows%APPDATA%\Claude\claude_desktop_config.json
  • Linux~/.config/Claude/claude_desktop_config.json(路径可能会有所不同)

✨ 主要特性

相较于其他GitHub自动化MCP服务器的关键优势

🎯 简单性:基于令牌的访问消除了复杂性。 🌿 高效性:无需Docker,确保轻量级和最佳性能。 💪 强大功能:89个可直接集成API的工具提供了无与伦比的灵活性。 🔒 灵活性:可配置的工具支持细粒度控制。

简单的设置和操作

无需Docker - 一个简单的Node.js服务器,可以在任何地方运行 ✅ 单令牌设置 - 仅需一个GitHub个人访问令牌即可工作 ✅ 直接API集成 - 不依赖 gh CLI,更快、更可靠 ✅ 零配置 - 只需令牌即可开箱即用

高级安全和控制

允许的仓库 - 将操作限制在特定的仓库或所有者范围内 ✅ 工具管理 - 启用/禁用特定工具以进行细粒度控制 ✅ 默认仓库 - 设置默认仓库以简化工作流程 ✅ 灵活的权限 - 精确配置服务器可以访问的内容

强大的功能

全面的工具包 - 89个强大的工具,可实现完整的GitHub工作流程 ✅ 分支和提交管理 - 创建分支、查看历史记录、比较更改 ✅ 图像上传支持 - 直接在问题中上传和嵌入图像 ✅ 高级过滤 - 支持多种条件的排序、过滤和搜索 ✅ 速率限制处理 - 内置GitHub API速率限制管理

📦 安装指南

最低要求 - 就这么简单!

  1. Node.js(版本18或更高)
  2. GitHub个人访问令牌(PAT):这是唯一需要的配置。你可以前往GitHub → 设置 → 开发者设置 → 个人访问令牌 → 令牌(经典)或细粒度令牌,生成一个至少具有以下作用域的新令牌:
    • repo(对私有仓库的完全控制):推荐用于完整功能。
    • user:readuser:email(用于读取用户个人资料数据)。
    • read:org(如果你需要访问组织信息)。
    • 重要提示:请安全地存储此令牌,你需要在MCP客户端的配置中直接提供它。

💻 使用示例

基础用法

配置完成后,你可以让你的MCP客户端(如Claude)执行强大的GitHub操作:

# 仓库发现和管理
"List my GitHub repositories, sort by creation date and show only private repos."
"Set default repository to `octocat/Spoon-Knife` for easier workflow."
"Get detailed information about the `microsoft/vscode` repository."
"Show me the contents of the `src/main.js` file in microsoft/vscode on the `develop` branch."
"Show me the contents of the `src/main.js` file in the default repository on the `develop` branch." # 需要设置默认仓库
"List all collaborators for `my-org/my-repo` who have admin permissions."
"Search for repositories matching 'tensorflow examples language:python' and sort by stars."

# 高级问题管理
"Create an issue in `my-org/my-repo` with title 'Urgent: UI Bug' and body 'The login button is broken on mobile.' Assign it to `user1` and `user2` and add the `bug` label."
"Create an issue with title 'Feature Request' and add the `enhancement` label." # 需要设置默认仓库
"Upload a screenshot from `/Users/me/screenshots/bug_report.png` to issue #42 in microsoft/vscode."
"Upload a screenshot from `/Users/me/screenshots/bug_report.png` to issue #42 in the default repository." # 需要设置默认仓库
"Edit issue #15: change title to 'Feature Request: Dark Mode', add the `enhancement` label, and close it."
"Lock issue #23 with reason 'resolved' to prevent further discussion."
"Get complete details for issue #7 including all metadata and current state."
"Remove `old-assignee` from issue #12 and add `new-assignee` instead."

# 问题讨论管理
"List all comments on issue #7 from the last week."
"Add a comment 'This looks great! Ready for merge.' to issue #15."
"Edit comment ID 123456 to say 'Updated: This needs more testing before merge.'"
"Delete comment ID 789012 from issue #20."

# 标签和里程碑管理
"List all labels in `my-org/my-repo` to see current organization system."
"List all labels in the default repository to see current organization system." # 需要设置默认仓库
"Create a new label called 'urgent' with red color (#ff0000) and description 'Requires immediate attention'."
"Edit the 'bug' label to change its color to orange (#FFA500) and update the description."
"Delete the outdated 'legacy' label from the repository."
"List all open milestones in `my-org/project-x` sorted by due date."
"Create a milestone 'v2.0 Release' with due date '2025-12-31T23:59:59Z' and description 'Major version release'."
"Edit milestone #3 to change the title to 'Q2 Goals' and extend the due date."
"Delete milestone #5 as it's no longer relevant to the project."

# 拉取请求和协作
"List all open pull requests for `microsoft/vscode`."
"List all open pull requests for the default repository." # 需要设置默认仓库
"Show me closed pull requests from the last month for `my-org/project-x`."
"Get my GitHub user profile information."
"Get user profile details for `github_username`."

# 分支和提交管理
"List all branches in `my-org/my-repo` and show their protection status."
"List all branches in the default repository and show their protection status." # 需要设置默认仓库
"Show only protected branches in `my-org/secure-repo`."
"Create a new feature branch called `feature/dark-mode` from the `develop` branch."
"List the last 10 commits on the `main` branch."
"Show me all commits by `john-doe` from the last week."
"Get detailed information about commit `abc123def` including all file changes."
"Compare the `main` branch with `feature/new-ui` to see what's different."
"Show me the commit history between `v1.0.0` and `v2.0.0` tags."

# 工作流自动化示例
"Set `my-org/main-project` as default, then list all open issues assigned to me."
"Create a bug report issue with title 'Login Error', upload the error screenshot from `/path/to/error.png`, assign to `dev-team`, and add labels `bug` and `high-priority`."
"For issue #50: add assignee `reviewer1`, lock it with reason 'resolved', and add a final comment 'Issue resolved in PR #51'."

📚 详细文档

完整的功能集

仓库管理

  • 智能仓库列表:支持按可见性(公共/私有/全部)过滤和排序选项
  • 详细的仓库信息:包括统计数据、URL和元数据
  • 文件和目录浏览:支持特定分支/提交
  • 仓库搜索:支持在整个GitHub上进行高级排序搜索
  • 默认仓库设置:简化工作流程

高级问题管理

  • 完整的问题生命周期 - 创建、编辑、列出和管理状态
  • 丰富的内容支持 - 直接在问题中上传和嵌入图像
  • 标签管理 - 添加、删除和组织自定义标签
  • 受让人管理 - 分配/取消分配团队成员
  • 问题锁定/解锁:支持自定义原因
  • 评论系统 - 创建、编辑、删除和列出问题评论
  • 状态管理 - 打开、关闭和跟踪问题进度

拉取请求管理

  • 拉取请求列表:支持状态过滤和排序
  • 全面的PR信息:包括分支详细信息和状态

分支和提交管理

  • 分支操作 - 列出所有分支及其保护状态和最新提交
  • 分支创建 - 从现有分支或提交创建新分支
  • 提交历史 - 支持高级过滤(日期、作者、分支)查看提交历史
  • 提交详情 - 获取包括文件更改在内的全面提交信息
  • 提交比较 - 比较任意两个提交、分支或标签以查看差异

协作和用户管理

  • 任何GitHub用户或你自己账户的用户资料信息
  • 仓库协作者管理:支持权限过滤
  • 团队协作工具:用于管理访问和权限

高级功能

  • 图像上传和嵌入 - 直接将本地图像上传到GitHub
  • 批量操作 - 管理多个受让人、标签和评论
  • 灵活的身份验证 - 基于安全令牌的GitHub API访问
  • 智能错误处理 - 全面的错误报告和恢复

配置选项

默认仓库设置

你可以设置默认仓库以简化工作流程,避免在每个命令中都指定 ownerrepo。有三种配置方式:

1. 环境变量(推荐用于MCP客户端)

在MCP客户端配置中添加环境变量:

使用npx

{
"mcpServers": {
"github-repos-manager": {
"command": "npx",
"args": ["-y", "github-repos-manager-mcp"],
"env": {
"GH_TOKEN": "ghp_YOUR_ACTUAL_TOKEN_HERE",
"GH_DEFAULT_OWNER": "octocat",
"GH_DEFAULT_REPO": "Hello-World"
}
}
}
}

使用本地安装

{
"mcpServers": {
"github-repos-manager": {
"command": "node",
"args": ["/full/path/to/your/project/github-repos-manager-mcp/server.cjs"],
"env": {
"GH_TOKEN": "ghp_YOUR_ACTUAL_TOKEN_HERE",
"GH_DEFAULT_OWNER": "octocat",
"GH_DEFAULT_REPO": "Hello-World"
}
}
}
}
2. 命令行参数

直接运行服务器时,可以传递默认仓库设置:

node server.cjs --default-owner octocat --default-repo Hello-World
3. 运行时工具调用

在会话期间使用 set_default_repo 工具设置或更改默认仓库:

  • "Set default repository to microsoft/vscode"
  • "Change the default to my own repo username/my-project"

配置优先级(从高到低)

  1. 命令行参数 (--default-owner, --default-repo)
  2. 环境变量 (GH_DEFAULT_OWNER, GH_DEFAULT_REPO)
  3. 运行时工具调用 (set_default_repo)

默认仓库的好处

  • 无需在每个命令中指定 ownerrepo
  • 主要处理一个仓库时简化工作流程
  • 可以在会话期间随时使用 set_default_repo 工具更改
  • 可选 - 所有工具在未设置默认仓库的情况下也能工作

一旦设置了默认仓库,你可以在命令中省略 ownerrepo 参数:

  • 之前:"List issues for microsoft/vscode"
  • 之后:"List issues"(在将microsoft/vscode设置为默认仓库后)

仓库访问控制

你可以使用 GH_ALLOWED_REPOS 环境变量或 --allowed-repos 命令行参数限制服务器可以访问的仓库。这是一项安全功能,确保服务器只能在批准的仓库上操作。

允许的仓库配置

1. 环境变量(用于MCP客户端)

{
"mcpServers": {
"github-repos-manager": {
"command": "node",
"args": ["/path/to/server.cjs"],
"env": {
"GH_TOKEN": "ghp_YOUR_TOKEN",
"GH_ALLOWED_REPOS": "owner1/repo1,owner2/repo2,owner3"
}
}
}
}

2. 命令行参数

node server.cjs --allowed-repos "microsoft/vscode,facebook/react,google"

工作原理

  • 完整的仓库路径 (owner/repo):仅允许该特定仓库
  • 仅所有者 (owner):允许该所有者的所有仓库
  • 混合:可以组合两种格式

示例

  • "microsoft/vscode" - 仅允许Microsoft的vscode仓库
  • "kurdin" - 允许kurdin拥有的所有仓库
  • "kurdin,microsoft/vscode,facebook/react" - 允许kurdin的所有仓库以及特定的仓库

工具访问控制

禁用特定工具

通过设置 GH_DISABLED_TOOLS 环境变量或使用 --disabled-tools 命令行参数禁用你不希望使用的工具。

仅允许特定工具

为了最大程度的安全,你可以通过设置 GH_ALLOWED_TOOLS 环境变量或使用 --allowed-tools 命令行参数将服务器限制为仅允许特定工具。

重要提示:如果同时设置了 GH_ALLOWED_TOOLSGH_DISABLED_TOOLSGH_ALLOWED_TOOLS 优先。

完整的配置示例

使用npx(macOS/Linux)

{
"mcpServers": {
"github-repos-manager": {
"command": "npx",
"args": ["-y", "github-repos-manager-mcp"],
"env": {
"GH_TOKEN": "ghp_YOUR_ACTUAL_TOKEN_HERE",
"GH_DEFAULT_OWNER": "mycompany",
"GH_DEFAULT_REPO": "main-project",
"GH_ALLOWED_REPOS": "mycompany,trusted-org/specific-repo",
"GH_ALLOWED_TOOLS": "list_issues,create_issue,list_prs,get_repo_info"
}
}
}
}

使用npx(Windows)

{
"mcpServers": {
"github-repos-manager": {
"command": "npx.cmd",
"args": ["-y", "github-repos-manager-mcp"],
"env": {
"GH_TOKEN": "ghp_YOUR_ACTUAL_TOKEN_HERE",
"GH_DEFAULT_OWNER": "mycompany",
"GH_DEFAULT_REPO": "main-project",
"GH_ALLOWED_REPOS": "mycompany,trusted-org/specific-repo",
"GH_ALLOWED_TOOLS": "list_issues,create_issue,list_prs,get_repo_info"
}
}
}
}

使用本地安装

{
"mcpServers": {
"github-repos-manager": {
"command": "node",
"args": ["/full/path/to/your/project/github-repos-manager-mcp/server.cjs"],
"env": {
"GH_TOKEN": "ghp_YOUR_ACTUAL_TOKEN_HERE",
"GH_DEFAULT_OWNER": "mycompany",
"GH_DEFAULT_REPO": "main-project",
"GH_ALLOWED_REPOS": "mycompany,trusted-org/specific-repo",
"GH_ALLOWED_TOOLS": "list_issues,create_issue,list_prs,get_repo_info"
}
}
}
}

命令行等效配置

node server.cjs \
--default-owner mycompany \
--default-repo main-project \
--allowed-repos "mycompany,trusted-org/specific-repo" \
--allowed-tools "list_issues,create_issue,list_prs,get_repo_info"

完整的工具参考

这个服务器提供了89个全面的工具,用于完整的GitHub工作流程管理:

增强的拉取请求管理

  • create_pull_request:创建一个新的拉取请求,指定标题、正文和分支。
    • 参数: owner (字符串, 可选), repo (字符串, 可选), title (字符串, 必需), body (字符串, 可选), head (字符串, 必需 - 包含更改的分支), base (字符串, 必需 - 目标分支), draft (布尔值, 可选), maintainer_can_modify (布尔值, 可选)
  • edit_pull_request:更新现有拉取请求的标题、正文、状态或基础分支。
    • 参数: owner (字符串, 可选), repo (字符串, 可选), pull_number (整数, 必需), title (字符串, 可选), body (字符串, 可选), state (字符串, 可选 - "open" 或 "closed"), base (字符串, 可选)
  • get_pr_details:获取拉取请求的全面信息,包括状态和合并细节。
    • 参数: owner (字符串, 可选), repo (字符串, 可选), pull_number (整数, 必需)
  • list_pr_reviews:列出拉取请求的所有审查,包括状态和评论。
    • 参数: owner (字符串, 可选), repo (字符串, 可选), pull_number (整数, 必需), per_page (整数, 可选, 默认30)
  • create_pr_review:提交对拉取请求的审查,包括评论和批准状态。
    • 参数: owner (字符串, 可选), repo (字符串, 可选), pull_number (整数, 必需), body (字符串, 可选), event (字符串, 可选 - "APPROVE", "REQUEST_CHANGES", "COMMENT"), comments (数组, 可选)
  • list_pr_files:列出拉取请求中更改的所有文件,包括添加/删除统计信息。
    • 参数: owner (字符串, 可选), repo (字符串, 可选), pull_number (整数, 必需), per_page (整数, 可选, 默认30)

文件和内容管理

  • create_file:在仓库中创建一个新文件,指定内容和提交消息。
    • 参数: owner (字符串, 可选), repo (字符串, 可选), path (字符串, 必需), content (字符串, 必需), message (字符串, 必需), branch (字符串, 可选), committer (对象, 可选)
  • update_file:使用新提交更新现有文件的内容。
    • 参数: owner (字符串, 可选), repo (字符串, 可选), path (字符串, 必需), content (字符串, 必需), message (字符串, 必需), sha (字符串, 必需 - 当前文件的SHA), branch (字符串, 可选)
  • upload_file:将本地文件上传到仓库(支持二进制文件)。
    • 参数: owner (字符串, 可选), repo (字符串, 可选), local_path (字符串, 必需), repo_path (字符串, 必需), message (字符串, 必需), branch (字符串, 可选)
  • delete_file:从仓库中删除一个文件,指定提交消息。
    • 参数: owner (字符串, 可选), repo (字符串, 可选), path (字符串, 必需), message (字符串, 必需), sha (字符串, 必需 - 当前文件的SHA), branch (字符串, 可选)

安全和访问管理

  • list_deploy_keys:列出仓库的所有部署密钥及其权限。
    • 参数: owner (字符串, 可选), repo (字符串, 可选), per_page (整数, 可选, 默认30)
  • create_deploy_key:向仓库添加一个新的部署密钥,以实现安全访问。
    • 参数: owner (字符串, 可选), repo (字符串, 可选), title (字符串, 必需), key (字符串, 必需 - 公共SSH密钥), read_only (布尔值, 可选, 默认true)
  • delete_deploy_key:从仓库中删除一个部署密钥。
    • 参数: owner (字符串, 可选), repo (字符串, 可选), key_id (整数, 必需)
  • list_webhooks:列出为仓库配置的所有Webhook。
    • 参数: owner (字符串, 可选), repo (字符串, 可选), per_page (整数, 可选, 默认30)
  • create_webhook:为仓库事件创建一个新的Webhook。
    • 参数: owner (字符串, 可选), repo (字符串, 可选), config (对象, 必需 - url和content_type), events (数组, 可选, 默认 ["push"]), active (布尔值, 可选)
  • edit_webhook:更新Webhook的配置、事件或活动状态。
    • 参数: owner (字符串, 可选), repo (字符串, 可选), hook_id (整数, 必需), config (对象, 可选), events (数组, 可选), active (布尔值, 可选)
  • delete_webhook:从仓库中删除一个Webhook。
    • 参数: owner (字符串, 可选), repo (字符串, 可选), hook_id (整数, 必需)
  • list_secrets:列出仓库的秘密(仅名称,值已加密)。
    • 参数: owner (字符串, 可选), repo (字符串, 可选), per_page (整数, 可选, 默认30)
  • update_secret:为Actions创建或更新仓库的秘密。
    • 参数: owner (字符串, 可选), repo (字符串, 可选), secret_name (字符串, 必需), encrypted_value (字符串, 必需), key_id (字符串, 必需)

GitHub Actions和工作流

注意: 这些工具是未来GitHub Actions集成的占位符。

  • list_workflows:列出仓库中的所有GitHub Actions工作流。
  • list_workflow_runs:列出工作流运行,并支持过滤选项。
  • get_workflow_run_details:获取工作流运行的详细信息。
  • trigger_workflow:手动触发工作流调度事件。
  • download_workflow_artifacts:从工作流运行中下载工件。
  • cancel_workflow_run:取消正在进行的工作流运行。

仓库分析和洞察

  • get_repo_stats:获取仓库的全面统计信息,包括贡献者活动。
    • 参数: owner (字符串, 可选), repo (字符串, 可选)
  • list_repo_topics:列出与仓库关联的所有主题(标签)。
    • 参数: owner (字符串, 可选), repo (字符串, 可选)
  • update_repo_topics:更新主题,以提高仓库的发现性。
    • 参数: owner (字符串, 可选), repo (字符串, 可选), names (字符串数组, 必需)
  • get_repo_languages:获取仓库中使用的编程语言及其字节数。
    • 参数: owner (字符串, 可选), repo (字符串, 可选)
  • list_stargazers:列出为仓库加星的用户。
    • 参数: owner (字符串, 可选), repo (字符串, 可选), per_page (整数, 可选, 默认30)
  • list_watchers:列出关注仓库以获取通知的用户。
    • 参数: owner (字符串, 可选), repo (字符串, 可选), per_page (整数, 可选, 默认30)
  • list_forks:列出仓库的所有分叉,并支持排序选项。
    • 参数: owner (字符串, 可选), repo (字符串, 可选), sort (字符串, 可选 - "newest", "oldest", "stargazers"), per_page (整数, 可选)
  • get_repo_traffic:获取仓库的流量数据,包括视图和克隆(需要管理员访问权限)。
    • 参数: owner (字符串, 可选), repo (字符串, 可选)

高级搜索和发现

  • search_issues:在GitHub上搜索问题和拉取请求。
    • 参数: query (字符串, 必需), sort (字符串, 可选 - "comments", "reactions", "interactions", "created", "updated"), order (字符串, 可选 - "asc", "desc"), per_page (整数, 可选)
  • search_commits:在仓库中搜索提交。
    • 参数: query (字符串, 必需), sort (字符串, 可选 - "author-date", "committer-date"), order (字符串, 可选), per_page (整数, 可选)
  • search_code:在GitHub仓库中搜索代码。
    • 参数: query (字符串, 必需), sort (字符串, 可选 - "indexed"), order (字符串, 可选), per_page (整数, 可选)
  • search_users:搜索用户和组织。
    • 参数: query (字符串, 必需), sort (字符串, 可选 - "followers", "repositories", "joined"), order (字符串, 可选), per_page (整数, 可选)
  • search_topics:搜索仓库主题。
    • 参数: query (字符串, 必需), per_page (整数, 可选, 默认30)

组织管理

  • list_org_repos:列出组织中的所有仓库。
    • 参数: org (字符串, 必需), type (字符串, 可选 - "all", "public", "private", "forks", "sources", "member"), sort (字符串, 可选), per_page (整数, 可选)
  • list_org_members:列出组织的成员。
    • 参数: org (字符串, 必需), filter (字符串, 可选 - "2fa_disabled", "all"), role (字符串, 可选 - "all", "admin", "member"), per_page (整数, 可选)
  • get_org_info:获取组织的详细信息。
    • 参数: org (字符串, 必需)
  • list_org_teams:列出组织中的所有团队。
    • 参数: org (字符串, 必需), per_page (整数, 可选, 默认30)
  • get_team_members:列出特定团队的成员。
    • 参数: org (字符串, 必需), team_slug (字符串, 必需), role (字符串, 可选 - "member", "maintainer", "all"), per_page (整数, 可选)
  • manage_team_repos:为团队添加或删除仓库访问权限。
    • 参数: org (字符串, 必需), team_slug (字符串, 必需), owner (字符串, 必需), repo (字符串, 必需), permission (字符串, 可选 - "pull", "push", "admin"), action (字符串, 必需 - "add" 或 "remove")

项目和高级功能

注意: 其中一些工具是未来增强功能的占位符。

  • list_repo_projects:列出仓库项目(经典项目)。
  • code_quality_checks:未来代码质量分析的占位符。
  • custom_dashboards:自定义仪表板创建的占位符。
  • automated_reporting:自动报告生成的占位符。
  • notification_management:通知设置的占位符。
  • release_management:版本管理功能的占位符。
  • dependency_analysis:依赖扫描的占位符。

仓库管理工具

  • set_default_repo:为后续命令设置默认的所有者和仓库,以简化工作流程。
    • 参数: owner (字符串, 必需), repo (字符串, 必需)
  • list_repos:列出经过身份验证的用户的GitHub仓库,并支持高级过滤。
    • 参数: per_page (数字, 可选, 默认10, 最大100), visibility (字符串, 可选, 枚举: "all", "public", "private", 默认 "all"), sort (字符串, 可选, 枚举: "created", "updated", "pushed", "full_name", 默认 "updated")
  • get_repo_info:获取特定仓库的全面信息,包括统计数据和元数据。
    • 参数: owner (字符串, 必需, 如果没有默认值), repo (字符串, 必需, 如果没有默认值)
  • search_repos:在GitHub上搜索仓库,并支持高级排序选项。
    • 参数: query (字符串, 必需), per_page (数字, 可选, 默认10, 最大100), sort (字符串, 可选, 枚举: "stars", "forks", "help-wanted-issues", "updated", 默认 "stars")
  • get_repo_contents:浏览任何仓库中的文件和目录,并支持分支/提交。
    • 参数: owner (字符串, 必需, 如果没有默认值), repo (字符串, 必需, 如果没有默认值), path (字符串, 可选, 默认 ""), ref (字符串, 可选, 例如分支名称或提交SHA)

高级问题管理工具

  • list_issues:列出问题,并支持按状态过滤和全面的分页。
    • 参数: owner (字符串, 必需, 如果没有默认值), repo (字符串, 必需, 如果没有默认值), state (字符串, 可选, 枚举: "open", "closed", "all", 默认 "open"), per_page (数字, 可选, 默认10, 最大100)
  • create_issue:创建功能丰富的问题,支持图像上传、标签和受让人。
    • 参数: owner (字符串, 必需, 如果没有默认值), repo (字符串, 必需, 如果没有默认值), title (字符串, 必需), body (字符串, 可选), image_path (字符串, 可选, 本地图像的完整路径), labels (字符串数组, 可选), assignees (字符串数组, 可选)
  • edit_issue:修改现有问题,包括标题、正文、状态、标签、受让人以及图像上传。
    • 参数: owner (字符串, 可选), repo (字符串, 可选), issue_number (整数, 必需), title (字符串, 可选), body (字符串, 可选), state (字符串, 可选, 枚举: "open", "closed"), image_path (字符串, 可选, 本地图像的完整路径), labels (字符串数组, 可选), assignees (字符串数组, 可选)
  • get_issue_details:获取任何特定问题的全面信息。
    • 参数: owner (字符串, 可选), repo (字符串, 可选), issue_number (整数, 必需)
  • lock_issue:锁定问题,防止进一步评论,并支持自定义原因。
    • 参数: owner (字符串, 可选), repo (字符串, 可选), issue_number (整数, 必需), lock_reason (字符串, 可选, 枚举: "off-topic", "too heated", "resolved", "spam")
  • unlock_issue:解锁之前锁定的问题,恢复讨论。
    • 参数: owner (字符串, 可选), repo (字符串, 可选), issue_number (整数, 必需)
  • add_assignees_to_issue:为问题添加一个或多个团队成员。
    • 参数: owner (字符串, 可选), repo (字符串, 可选), issue_number (整数, 必需), assignees (字符串数组, 必需)
  • remove_assignees_from_issue:从问题中移除受让人,以更好地管理任务。
    • 参数: owner (字符串, 可选), repo (字符串, 可选), issue_number (整数, 必需), assignees (字符串数组, 必需)

问题评论管理工具

  • list_issue_comments:列出问题的所有评论,并支持时间戳过滤。
    • 参数: owner (字符串, 可选), repo (字符串, 可选), issue_number (整数, 必需), per_page (整数, 可选, 默认30, 最大100), since (字符串, 可选, ISO 8601格式的日期时间)
  • create_issue_comment:在正在进行的问题讨论中添加新评论。
    • 参数: owner (字符串, 可选), repo (字符串, 可选), issue_number (整数, 必需), body (字符串, 必需)
  • edit_issue_comment:修改现有评论,进行更正或更新。
    • 参数: owner (字符串, 可选), repo (字符串, 可选), comment_id (整数, 必需), body (字符串, 必需)
  • delete_issue_comment:在必要时删除评论,以进行内容管理。
    • 参数: owner (字符串, 可选), repo (字符串, 可选), comment_id (整数, 必需)

拉取请求管理工具

  • list_prs:列出拉取请求,并支持状态过滤和分页。
    • 参数: owner (字符串, 必需, 如果没有默认值), repo (字符串, 必需, 如果没有默认值), state (字符串, 可选, 枚举: "open", "closed", "all", 默认 "open"), per_page (数字, 可选, 默认10, 最大100)

分支和提交管理工具

  • list_branches:列出仓库中的所有分支,并显示其保护状态和提交信息。
    • 参数: owner (字符串, 可选), repo (字符串, 可选), protected_only (布尔值, 可选, 默认false), per_page (数字, 可选, 默认30)
  • create_branch:从现有分支或提交创建一个新分支。
    • 参数: owner (字符串, 可选), repo (字符串, 可选), branch_name (字符串, 必需), from_branch (字符串, 可选, 默认仓库的默认分支)
  • list_commits:列出仓库中的提交,并提供详细信息和过滤选项。
    • 参数: owner (字符串, 可选), repo (字符串, 可选), sha (字符串, 可选, 要列出的分支/标签/提交), per_page (数字, 可选, 默认20), since (字符串, 可选, ISO 8601日期时间), until (字符串, 可选, ISO 8601日期时间), author (字符串, 可选, GitHub用户名或电子邮件)
  • get_commit_details:获取特定提交的详细信息,包括文件更改。
    • 参数: owner (字符串, 可选), repo (字符串, 可选), commit_sha (字符串, 必需)
  • compare_commits:比较两个提交或分支,查看差异。
    • 参数: owner (字符串, 可选), repo (字符串, 可选), base (字符串, 必需, 基础分支或提交SHA), head (字符串, 必需, 头部分支或提交SHA)

用户和协作工具

  • get_user_info:获取任何GitHub用户或你自己的详细信息。
    • 参数: username (字符串, 可选 - 默认经过身份验证的用户)
  • list_repo_collaborators:列出仓库的协作者,并支持基于权限的过滤。
    • 参数: owner (字符串, 可选), repo (字符串, 可选), affiliation (字符串, 可选, 枚举: "outside", "direct", "all", 默认 "all"), permission (字符串, 可选, 枚举: "pull", "triage", "push", "maintain", "admin"), per_page (整数, 可选, 默认30, 最大100)

标签和里程碑管理工具

  • list_repo_labels:列出仓库中的所有标签及其颜色和描述。
    • 参数: owner (字符串, 可选), repo (字符串, 可选), per_page (整数, 可选, 默认30, 最大100)
  • create_label:创建自定义标签,指定颜色和描述,以更好地组织问题。
    • 参数: owner (字符串, 可选), repo (字符串, 可选), name (字符串, 必需), color (字符串, 可选, 不带#的十六进制颜色, 默认 "f29513"), description (字符串, 可选)
  • edit_label:修改现有标签的属性,包括名称、颜色和描述。
    • 参数: owner (字符串, 可选), repo (字符串, 可选), current_name (字符串, 必需), name (字符串, 可选), color (字符串, 可选, 不带#的十六进制颜色), description (字符串, 可选)
  • delete_label:在不再需要时从仓库中删除标签。
    • 参数: owner (字符串, 可选), repo (字符串, 可选), name (字符串, 必需)
  • list_milestones:列出仓库的里程碑,并支持按状态过滤和排序选项。
    • 参数: owner (字符串, 可选), repo (字符串, 可选), state (字符串, 可选, 枚举: "open", "closed", "all", 默认 "open"), sort (字符串, 可选, 枚举: "due_on", "completeness", 默认 "due_on"), direction (字符串, 可选, 枚举: "asc", "desc", 默认 "asc"), per_page (整数, 可选, 默认30, 最大100)
  • create_milestone:创建新的里程碑,指定截止日期,用于项目规划。
    • 参数: owner (字符串, 可选), repo (字符串, 可选), title (字符串, 必需), state (字符串, 可选, 枚举: "open", "closed", 默认 "open"), description (字符串, 可选), due_on (字符串, 可选, ISO 8601日期时间格式)
  • edit_milestone:更新里程碑的详细信息,包括标题、描述、状态和截止日期。
    • 参数: owner (字符串, 可选), repo (字符串, 可选), milestone_number (整数, 必需), title (字符串, 可选), state (字符串, 可选, 枚举: "open", "closed"), description (字符串, 可选), due_on (字符串, 可选, ISO 8601日期时间格式)
  • delete_milestone:在不再需要时从仓库中删除里程碑。
    • 参数: owner (字符串, 可选), repo (字符串, 可选), milestone_number (整数, 必需)

🔧 技术细节

故障排除

身份验证问题

  1. 令牌问题

    • 仔细检查MCP客户端配置中的 GH_TOKEN 值是否正确,没有拼写错误
    • 确保令牌未过期或被撤销
    • 使用curl验证令牌有效性:
      export TEMP_TOKEN="ghp_YOUR_TOKEN_TO_TEST"
      curl -H "Authorization: token $TEMP_TOKEN" https://api.github.com/user
      unset TEMP_TOKEN
      
      这应该返回你的GitHub用户信息。
  2. 配置问题

    • 验证 GH_TOKEN 是否正确放置在MCP客户端服务器配置的 env 对象中
    • 确保 server.cjs 的路径是绝对且正确的
    • 检查Node.js版本是否为18或更高:node --version
    • 默认仓库:如果你设置了 GH_DEFAULT_OWNERGH_DEFAULT_REPO 环境变量,验证它们是否正确且仓库存在
  3. 权限问题

    • 确保你的令牌具有所需的作用域:
      • repopublic_repo(用于仓库访问)
      • user(用于用户信息)
      • read:org(如果需要访问组织信息)
    • 默认仓库访问:如果使用默认仓库,确保你的令牌可以访问该特定仓库

默认仓库配置问题

  • 环境变量不生效:仔细检查MCP客户端配置中 GH_DEFAULT_OWNERGH_DEFAULT_REPO 的拼写
  • 命令行参数:确保使用 --default-owner--default-repo 标志时语法正确
  • 工具调用问题:在 set_default_repo 工具中使用准确的仓库名称:owner/repo 格式
  • 覆盖行为:请记住,运行时工具调用可以覆盖环境变量,而命令行参数可以覆盖两者

性能和速率限制

  • GitHub API速率限制:经过身份验证的用户每小时允许5000个请求
  • 如果达到限制,请等待重置窗口或使用不同的令牌
  • 服务器包含内置的速率限制错误处理

常见设置问题

  • 路径问题:验证Claude Desktop配置中的绝对路径是否正确
  • Node.js版本:确保使用的是Node.js 18或更高版本
  • 文件权限:确保 server.cjs 是可执行的:chmod +x server.cjs

图像上传故障排除

  • 确保图像文件存在于指定的本地路径
  • 支持的格式:PNG、JPG、JPEG、GIF、WebP
  • 检查文件权限和可访问性
  • 验证文件未损坏或过大(GitHub有大小限制)

API速率限制和性能

  • 标准速率限制:GitHub API允许经过身份验证的用户每小时进行5000次请求
  • 内置处理:服务器包含全面的速率限制响应错误处理
  • 性能优化:直接的HTTP请求确保比CLI工具更快的响应时间
  • 缓存建议:考虑为频繁访问的数据实施缓存策略

安全最佳实践

  • 令牌安全:切勿将你的 GH_TOKEN 提交到版本控制或公开共享
  • 最小权限:使用仅具有你的用例所需最小作用域的令牌
  • 环境变量:始终通过MCP客户端配置中的 env 块提供令牌
  • 令牌轮换:定期轮换你的GitHub令牌以增强安全性
  • 安全存储:使用系统的凭证管理安全地存储令牌

开发和贡献

本地开发设置

# 克隆并设置
mkdir github-repos-manager-mcp
cd github-repos-manager-mcp
# 添加服务器文件
npm install
chmod +x server.cjs

# 使用nodemon进行开发测试
npm run dev

使用MCP客户端进行测试

推荐的方法是配置你的MCP客户端(如Claude Desktop)指向你的开发版本,并正确配置 GH_TOKEN。对 server.cjs 的更改需要重新启动服务器连接。

直接脚本测试

# 临时设置令牌以进行快速验证
export GH_TOKEN="ghp_YOUR_DEVELOPMENT_TOKEN"
node server.cjs
unset GH_TOKEN  # 测试后始终清理

📄 许可证

本MCP服务器采用MIT许可证,你可以自由使用、修改和分发。

  • 0 关注
  • 0 收藏,8 浏览
  • system 提出于 2025-09-27 06:57

相似服务问题