GitCode API服务

GitCode MCP Server是一个为AI助手提供GitCode API交互功能的服务,支持访问仓库、问题、拉取请求等核心开发操作。

  • by ZoroPoskai
  • Python
  • 本地部署
  • 1 星标
  • 更新于
在 GitHub 查看 ZoroPoskai/gitcode-mcp-server

使用说明

Gitcode MCP服务器

LLM安装提示 --将此粘贴到Claude Code、Gemini CLI、Codex或OpenCode中:

Clone https://github.com/ZoroPoskai/gitcode-mcp-server.git, create a Python venv inside it, pip install -r requirements.txt, then add it to my MCP config with command pointing to .venv/bin/python and args pointing to server.py. Set env GITCODE_TOKEN to <my-token> and GITCODE_TOOLSETS to core.

MCP服务器 Gitcode: API,使Claude和其他人工智能助手能够与GitCode存储库、问题、拉取请求等进行交互。

特性

  • 152工具 涵盖GitCode API v5和v8
  • 3个工具集级别 要控制上下文使用,请执行以下操作:
    • core (22个工具,约2K个令牌)——基本的开发工作流程
    • extended (106个工具,约10K个令牌)——完整的CRUD操作
    • all (152个工具,约15K个令牌)——每个可用端点
  • 承载令牌身份验证
  • 异步HTTP与连接池

快速开始

先决条件

安装

git clone https://github.com/ZoroPoskai/gitcode-mcp-server.git
cd gitcode-mcp-server
python -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt

配置Claude代码

添加到您的 ~/.claude.json:

{
  "mcpServers": {
    "gitcode": {
      "type": "stdio",
      "command": "/path/to/gitcode-mcp-server/.venv/bin/python",
      "args": ["/path/to/gitcode-mcp-server/server.py"],
      "env": {
        "GITCODE_TOKEN": "your-token-here",
        "GITCODE_TOOLSETS": "core"
      }
    }
  }
}

配置Claude桌面

添加到您的 claude_desktop_config.json:

{
  "mcpServers": {
    "gitcode": {
      "command": "/path/to/gitcode-mcp-server/.venv/bin/python",
      "args": ["/path/to/gitcode-mcp-server/server.py"],
      "env": {
        "GITCODE_TOKEN": "your-token-here",
        "GITCODE_TOOLSETS": "core"
      }
    }
  }
}

工具集

级别 工具 ~令牌 描述
core 22 ~2K 仓库、文件、分支、提交、问题、PR、搜索
extended 106 ~10K +标签、里程碑、标签、发布、webhooks、组织、成员
all 152 ~15K +企业、受保护的分支机构/标签、公关审查员/测试人员

通过设置 GITCODE_TOOLSETS 环境变量。违约: core.

您还可以通过逗号分隔工具集和单个工具来混合使用:

GITCODE_TOOLSETS=core,gitcode_list_releases,gitcode_list_tags

核心工具(默认)

工具 说明
gitcode_get_user 获取经过身份验证的用户配置文件
gitcode_get_repo 获取存储库详细信息
gitcode_search_repos 搜索存储库
gitcode_get_contents 获取文件或目录内容
gitcode_get_raw_file 获取原始文件内容
gitcode_create_file 创建新文件
gitcode_update_file 更新现有文件
gitcode_list_branches 列出存储库分支
gitcode_get_branch 获取分行详细信息
gitcode_list_commits 列表存储库提交
gitcode_get_commit 获得特定的承诺
gitcode_list_issues 列出存储库问题
gitcode_get_issue 获取特定问题
gitcode_create_issue 创建新问题
gitcode_create_issue_comment 对一个问题的评论
gitcode_list_pulls 列出拉取请求
gitcode_get_pull 获取特定的拉取请求
gitcode_create_pull 创建pull请求
gitcode_merge_pull 合并拉取请求
gitcode_create_pull_comment 对pull请求发表评论
gitcode_list_pull_files 列出PR中更改的文件
gitcode_search_issues 搜索问题

所有可用工具

按类别组织的所有152种工具的完整参考。

存储库(11个工具)

工具 说明
gitcode_get_repo 获取存储库
gitcode_delete_repo 删除存储库
gitcode_update_repo 更新存储库设置
gitcode_get_readme 获取存储库的README
gitcode_list_languages 列出使用的编程语言
gitcode_list_contributors 列出贡献者
gitcode_list_stargazers 列出在repo中担任主角的用户
gitcode_list_subscribers 列出观看repo的用户
gitcode_list_forks 列表分叉
gitcode_create_fork 分叉存储库
gitcode_search_repos 搜索存储库

事件和通知(3个工具)

工具 说明
gitcode_list_events 列出存储库的事件
gitcode_list_repo_notifications 列出存储库的通知
gitcode_mark_repo_notifications_read 将所有通知标记为已读

文件和内容(8个工具)

工具 说明
gitcode_get_contents 获取文件或目录内容
gitcode_get_file_list 获取平面文件列表
gitcode_get_raw_file 获取原始文件内容
gitcode_get_blob 通过SHA获取git blob
gitcode_get_tree 获取SHA的git树
gitcode_create_file 创建新文件
gitcode_update_file 更新现有文件
gitcode_delete_file 删除文件

分支机构(8个工具)

工具 说明
gitcode_list_branches 列出所有分支
gitcode_get_branch 获得一个分支
gitcode_create_branch 创建新分支
gitcode_delete_branch 删除分支
gitcode_list_protected_branches 列出受保护的分支
gitcode_create_branch_protection 创建分支保护规则
gitcode_update_branch_protection 更新分支保护规则
gitcode_delete_branch_protection 删除分支保护规则

提交(11个工具)

工具 说明
gitcode_list_commits 列表提交
gitcode_get_commit 获得一次提交
gitcode_compare_commits 比较两个提交或分支
gitcode_get_commit_diff 获取提交的差异
gitcode_get_commit_patch 获取提交补丁
gitcode_list_commit_comments 列出对提交的评论
gitcode_create_commit_comment 对承诺发表评论
gitcode_list_repo_comments 列出所有提交评论
gitcode_get_comment 获取一条提交评论
gitcode_update_comment 更新提交评论
gitcode_delete_comment 删除提交评论

问题(18个工具)

工具 说明
gitcode_list_issues 列出问题
gitcode_get_issue 获取一个问题
gitcode_create_issue 创建新问题
gitcode_update_issue 更新问题
gitcode_list_issue_comments 列出对某个问题的评论
gitcode_create_issue_comment 对一个问题的评论
gitcode_update_issue_comment 更新问题评论
gitcode_delete_issue_comment 删除问题注释
gitcode_list_all_issue_comments 列出回购的所有发行评论
gitcode_get_issue_comment 获取单个问题评论
gitcode_add_issue_labels 为问题添加标签
gitcode_remove_issue_label 从问题中删除标签
gitcode_remove_all_issue_labels 从问题中删除所有标签
gitcode_replace_issue_labels 替换问题上的所有标签
gitcode_get_issue_related_branches 获取与问题相关的分支
gitcode_list_user_issues 列出分配给您的问题
gitcode_list_org_issues 列出组织的问题
gitcode_search_issues 搜索问题

拉取请求(31个工具)

工具 说明
gitcode_list_pulls 列出拉取请求
gitcode_get_pull 获取单个pull请求
gitcode_create_pull 创建pull请求
gitcode_update_pull 更新拉取请求
gitcode_list_pull_files 列出PR中更改的文件
gitcode_list_pull_commits PR上的列表提交
gitcode_list_pull_comments 列出PR的审核意见
gitcode_create_pull_comment 对pull请求发表评论
gitcode_get_pull_comment 获取一条评论
gitcode_update_pull_comment 更新评论
gitcode_delete_pull_comment 删除评论
gitcode_check_pull_merged 检查PR是否已合并
gitcode_merge_pull 合并拉取请求
gitcode_list_pull_labels 在PR上列出标签
gitcode_add_pull_labels 向PR添加标签
gitcode_replace_pull_labels 替换PR上的所有标签
gitcode_remove_pull_label 从PR中删除标签
gitcode_assign_pull_reviewers 将审阅者分配给PR
gitcode_reset_pull_review 重置审核状态
gitcode_remove_pull_reviewers 从PR中删除审阅者
gitcode_assign_pull_testers 将测试人员分配给PR
gitcode_reset_pull_test 重置测试状态
gitcode_remove_pull_testers 从PR中删除测试人员
gitcode_submit_pull_review 提交评论
gitcode_submit_pull_test 提交测试结果
gitcode_link_pull_issues 将问题链接到PR
gitcode_unlink_pull_issues 从PR中取消链接问题
gitcode_list_pull_issues 列出与PR相关的问题
gitcode_get_pull_settings 获取回购的PR设置
gitcode_list_user_pulls 列出您的拉取请求
gitcode_list_org_pulls 列出组织的PR

标签(4个工具)

工具 说明
gitcode_list_labels 列出标签
gitcode_create_label 创建标签
gitcode_update_label 更新标签
gitcode_delete_label 删除标签

里程碑(5个工具)

工具 说明
gitcode_list_milestones 列出里程碑
gitcode_get_milestone 获得一个里程碑
gitcode_create_milestone 创建里程碑
gitcode_update_milestone 更新里程碑
gitcode_delete_milestone 删除里程碑

标签(8工具)

工具 说明
gitcode_list_tags 列表标签
gitcode_create_tag 创建标签
gitcode_delete_tag 删除标签
gitcode_list_protected_tags 列出受保护的标签
gitcode_get_protected_tag 获取受保护的标签
gitcode_create_protected_tag 创建受保护的标签
gitcode_update_protected_tag 更新受保护的标签
gitcode_delete_protected_tag 删除受保护的标签

发布(6个工具)

工具 说明
gitcode_list_releases 列表发布
gitcode_get_latest_release 获取最新版本
gitcode_get_release 按标签名称获取发布
gitcode_get_release_by_tag 按标签获取发布(显式查找)
gitcode_create_release 创建发布
gitcode_update_release 更新版本

Webhooks(6个工具)

工具 说明
gitcode_list_webhooks 列出webhooks
gitcode_get_webhook 获取单个webhook
gitcode_create_webhook 创建webhook
gitcode_update_webhook 更新webhook
gitcode_delete_webhook 删除webhook
gitcode_test_webhook 触发测试交付

协作者和成员(9个工具)

工具 说明
gitcode_list_collaborators 列出合作者
gitcode_check_collaborator 检查用户是否为合作者
gitcode_get_collaborator_permission 获取合作者的权限级别
gitcode_add_collaborator 添加合作者
gitcode_remove_collaborator 删除合作者
gitcode_list_org_members 列出组织成员
gitcode_get_org_member 获取组织成员
gitcode_invite_org_member 邀请用户加入组织
gitcode_remove_org_member 删除组织成员

组织(6种工具)

工具 说明
gitcode_get_org 组建一个组织
gitcode_update_org 更新组织
gitcode_list_org_repos 列出组织存储库
gitcode_create_org_repo 创建组织存储库
gitcode_list_user_orgs 列出您的组织
gitcode_list_user_orgs_by_name 列出用户的组织

用户(13工具)

工具 说明
gitcode_get_user 获取经过身份验证的用户
gitcode_update_user 更新您的个人资料
gitcode_get_user_by_name 按用户名获取用户
gitcode_list_user_repos_by_name 列出用户的存储库
gitcode_list_user_events 列出用户执行的事件
gitcode_list_my_repos 列出您的存储库
gitcode_list_my_starred 列出你的星级repos
gitcode_list_my_subscriptions 列出您关注的repos
gitcode_list_ssh_keys 列出您的SSH密钥
gitcode_get_ssh_key 获取单个SSH密钥
gitcode_add_ssh_key 添加SSH密钥
gitcode_delete_ssh_key 删除SSH密钥
gitcode_list_emails 列出您的电子邮件地址

搜索(1个工具)

工具 说明
gitcode_search_users 搜索用户

企业(4个工具)

工具 说明
gitcode_list_enterprise_members 列出企业成员
gitcode_list_enterprise_issues 列出企业问题
gitcode_get_enterprise_issue 获取单个企业问题
gitcode_list_enterprise_pulls 列出企业拉取请求

环境变量

变量 必填 默认 描述
GITCODE_TOKEN 是 -- GitCode个人访问令牌
GITCODE_TOOLSETS 没有 core 工具集级别: core, extended, all,或逗号分隔的混合

你也可以把这些放在 .env 项目目录中的文件。

许可证

麻省理工学院