G

GitHub PR MCP 服务器

@shaileshahuja/github-pr-mcp
0 Stars 286 次浏览 shaileshahuja 更新于 2026-08-23

一个MCP服务器,它使用GitHub个人访问令牌获取带有文件路径、行范围的GitHub拉取请求评论并进行回复。

该服务暂未提供标准配置,请参考 README 手动接入

服务介绍

GitHub PR Comments MCP 服务器

smithery 徽章

这是一个使用 GitHub 个人访问令牌来获取 GitHub 拉取请求评论的 Model Context Protocol (MCP) 服务器。

功能

  • 获取带有文件路径、行范围和回复的 PR 评论
  • 通过 Octokit 使用 GitHub API
  • 采用 StdioServerTransport 实现 MCP 服务器
  • 以结构化的 JSON 格式返回评论

安装

通过 Smithery 安装

要通过 Smithery 自动为 Claude Desktop 安装 github-pr-mcp:

npx -y @smithery/cli install github-pr-mcp --client claude

手动安装

  1. 克隆仓库

  2. 安装依赖项:

    npm install
    
  3. 创建一个包含您的 GitHub 令牌的 .env 文件:

    GITHUB_TOKEN=your_github_token_here
    

使用方法

  1. 构建项目:

    npm run build
    
  2. 运行服务器:

    npm start
    

    或者直接使用 GitHub 令牌运行:

    node dist/server.js your_github_token_here
    
  3. 该服务器暴露了一个名为 get_pr_comments 的工具,接受以下参数:

    • owner: 仓库所有者(用户名或组织)
    • repo: 仓库名称
    • pull_number: 拉取请求编号

与 Cursor 集成

要在 Cursor 中集成,请在 Cursor 的 MCP 服务器配置中使用以下命令:

node /path/to/dist/server.js your_github_token_here

/path/to 替换为您项目的实际路径,并将 your_github_token_here 替换为您的 GitHub 个人访问令牌。

测试

包含了一个测试客户端来验证服务器的功能:

  1. 构建项目:

    npm run build
    
  2. 运行测试客户端:

    npm test
    

测试客户端将启动服务器,连接到它,并使用示例参数调用 get_pr_comments 工具。

响应格式

服务器以如下格式返回评论:

{
  "comments": [
    {
      "id": 123456789,
      "path": "src/example.js",
      "body": "This is a comment on a specific line",
      "line": 42,
      "start_line": 40,
      "user": {
        "login": "username"
      },
      "created_at": "2023-01-01T00:00:00Z",
      "replies": [
        {
          "id": 987654321,
          "body": "This is a reply to the comment",
          "user": {
            "login": "another-username"
          },
          "created_at": "2023-01-02T00:00:00Z"
        }
      ]
    }
  ]
}

开发

要在开发模式下运行服务器:

npm run dev

许可证

ISC

相关 MCP 服务