Skip to main content
Glama

GitHub MCP 工具

通过 Claude Desktop 与 GitHub API 交互的多 Claude 程序 (MCP)。

特征

  • 搜索 GitHub 存储库和问题

  • 创建、更新和管理 GitHub 问题和拉取请求

  • 管理存储库设置和配置

  • 处理存储库工作流和操作

  • 搜索用户和组织

  • 管理存储库协作者和团队

Related MCP server: GitHub MCP Server

安装

  1. 克隆此存储库:

    git clone https://github.com/yourusername/github-mcp.git cd github-mcp
  2. 创建并激活虚拟环境:

    # On macOS/Linux python -m venv venv source venv/bin/activate # On Windows python -m venv venv .\venv\Scripts\activate
  3. 安装依赖项:

    pip install -r requirements.txt
  4. 在项目根目录中创建一个.env文件:

    touch .env
  5. 将您的 GitHub 凭据添加到.env文件:

    GITHUB_TOKEN=your_personal_access_token_here GITHUB_USERNAME=your_github_username
  6. 测试安装:

    # Run all tests python -m pytest # Run a specific test file python -m pytest tests/test_search_repos.py
  7. 启动 MCP 服务器:

    python run.py

环境设置

GitHub 个人访问令牌

您需要一个细粒度的个人访问令牌来向 GitHub 进行身份验证:

  1. 登录你的 GitHub 帐户

  2. 转到“设置”>“开发者设置”>“个人访问令牌”>“细粒度令牌”

  3. 点击“生成新令牌”

  4. 配置令牌:

    • 代币名称:“Claude Desktop Integration”

    • 描述:“Claude Desktop GitHub 集成令牌”

    • 到期日期:选择合适的到期日期

    • 存储库访问:选择“所有存储库”或特定存储库

    • 权限:

      • 存储库权限:

        • 行动:阅读和写作

        • 内容:阅读和写作

        • 问题:阅读和写作

        • 拉取请求:读取和写入

        • 存储库钩子:读取和写入

        • 存储库设置:读取和写入

      • 组织权限(如果使用组织存储库):

        • 成员:只读

        • 团队:只读

  5. 点击“生成token”,并安全保存生成的token

工具

搜索存储库

使用各种标准搜索 GitHub 存储库。

参数:

  • 查询:搜索查询字符串

  • 排序:排序字段(星级、分叉、更新等)

  • order:排序顺序(升序或降序)

  • max_results:返回的最大结果数(默认值:10)

创建问题

在指定的存储库中创建一个新的 GitHub 问题。

参数:

  • 所有者:存储库所有者

  • repo:存储库名称

  • title:问题标题

  • 正文:问题描述

  • 标签:要应用的标签列表

  • 受让人:受让人用户名列表

创建拉取请求

创建一个新的拉取请求。

参数:

  • 所有者:存储库所有者

  • repo:存储库名称

  • 标题:PR 标题

  • 正文:PR 描述

  • head:源分支

  • 基础:目标分支

  • draft:是否创建为 PR 草稿

管理存储库设置

更新存储库设置和配置。

参数:

  • 所有者:存储库所有者

  • repo:存储库名称

  • 设置:要更新的设置词典

搜索问题

跨存储库搜索问题。

参数:

  • 查询:搜索查询字符串

  • 状态:问题状态(打开、关闭、全部)

  • 排序:排序字段

  • 顺序:排序顺序

  • max_results:最大结果数

管理工作流程

管理 GitHub Actions 工作流程。

参数:

  • 所有者:存储库所有者

  • repo:存储库名称

  • workflow_file:工作流文件路径

  • 动作:要执行的动作(启用、禁用、触发)

管理合作者

管理存储库合作者。

参数:

  • 所有者:存储库所有者

  • repo:存储库名称

  • 用户名:合作者用户名

  • 权限:权限级别(拉取、推送、管理、维护、分类)

示例用法

# Search for repositories search_repos(query="python web framework", sort="stars", max_results=5) # Create a new issue create_issue( owner="username", repo="repository", title="Bug: Login not working", body="Users cannot log in using the login button", labels=["bug", "high-priority"] ) # Create a pull request create_pull_request( owner="username", repo="repository", title="Feature: Add user authentication", body="Implements JWT-based authentication", head="feature/auth", base="main" ) # Search for issues search_issues(query="is:open is:issue author:username", max_results=10) # Manage repository settings manage_repo_settings( owner="username", repo="repository", settings={ "has_issues": True, "has_projects": True, "has_wiki": True } )

发展

运行测试

# Run all tests python -m pytest # Run with coverage python -m pytest --cov=src tests/ # Run specific test file python -m pytest tests/test_search_repos.py

添加新工具

  1. src/tools/中创建一个新文件

  2. 实现你的工具功能

  3. src/main.py中注册该工具

  4. tests/中添加测试

  5. 更新 README.md 中的文档

贡献

  1. 分叉存储库

  2. 创建功能分支

  3. 进行更改

  4. 运行测试

  5. 提交拉取请求

执照

MIT 许可证

-
security - not tested
F
license - not found
-
quality - not tested

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/NZenitram/github-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server