GitHub拉取请求数据服务

提供全面的GitHub拉取请求数据服务,包括评论、标签、管道状态等信息。

  • by YahyaQandel
  • JavaScript
  • 本地部署
  • 更新于
在 GitHub 查看 YahyaQandel/github-mcp-server

使用说明

GitHub MCP服务器

一个模型上下文协议(MCP)服务器,提供全面的GitHub拉取请求数据,包括注释、标签、管道状态等。

特性

  • 完整的公关数据:获取完整的拉取请求信息,包括:

    • PR元数据(标题、状态、时间戳、草稿状态)
    • 创建者/作者信息
    • 受让人和审查人
    • 标签和里程碑
    • 文件更改统计
    • 合并状态
  • 评论支持:检索拉取请求的所有注释:

    • 发布评论
    • 评审意见
    • 按时间顺序排序
  • 管道/CI状态:获取CI/CD管道信息:

    • GitHub检查运行(操作,第三方CI)
    • 提交状态
    • 完成情况和结论
  • 分页支持:自动获取所有拉取请求,而不仅仅是第一页

  • 灵活过滤:按状态过滤PR(打开、关闭或全部)

安装

npm install
npm run build

配置

  1. 创建GitHub个人访问令牌:

    • 首选https://github.com/settings/tokens
    • 使用生成新令牌 repo 范围(用于私有仓库)或 public_repo 范围(公共回购)
  2. 设置环境变量:

    cp .env.example .env
    # Edit .env and add your GitHub token
    

使用MCP客户端

添加到MCP设置

将此服务器添加到MCP客户端配置中:

{
  "mcpServers": {
    "github": {
      "command": "node",
      "args": ["path/to/github-mcp-server/dist/index.js"],
      "env": {
        "GITHUB_TOKEN": "your_github_token_here"
      }
    }
  }
}

可用工具

1. github_set_token

在运行时设置或更新GitHub身份验证令牌。

参数:

  • token (string,必填):GitHub个人访问令牌

2. github_list_pull_requests

在存储库中列出所有拉取请求,并提供全面的详细信息。

参数:

  • owner (字符串,必填):存储库所有者(用户或组织)
  • repo (字符串,必填):存储库名称
  • state (字符串,可选):按状态筛选-“打开”、“关闭”或“全部”(默认值:“全部”)
  • include_comments (布尔值,可选):包括每个PR的所有注释(默认值:false)
  • include_checks (布尔值,可选):包括每个PR的CI/CD状态(默认值:false)

示例响应:

{
  "repository": "owner/repo",
  "total_count": 25,
  "state_filter": "all",
  "pull_requests": [
    {
      "number": 123,
      "title": "Add new feature",
      "state": "open",
      "created_at": "2024-01-01T00:00:00Z",
      "user": {
        "login": "developer",
        "avatar_url": "https://...",
        "html_url": "https://github.com/developer"
      },
      "labels": [
        {
          "name": "enhancement",
          "color": "a2eeef",
          "description": "New feature or request"
        }
      ],
      "assignees": [...],
      "comments": 5,
      "review_comments": 3,
      "check_runs": [...],
      "statuses": [...]
    }
  ]
}

3. github_get_pr_comments

获取特定拉取请求的所有评论。

参数:

  • owner (字符串,必填):存储库所有者
  • repo (字符串,必填):存储库名称
  • pull_number (number,必填):拉取请求编号

示例响应:

{
  "repository": "owner/repo",
  "pull_request": 123,
  "total_comments": 8,
  "comments": [
    {
      "id": 1234567,
      "user": {
        "login": "reviewer",
        "avatar_url": "https://..."
      },
      "body": "Great work! Just one suggestion...",
      "created_at": "2024-01-02T10:00:00Z",
      "html_url": "https://github.com/owner/repo/pull/123#issuecomment-1234567"
    }
  ]
}

4. github_get_pr_checks

获取特定拉取请求的CI/CD检查运行和状态。

参数:

  • owner (字符串,必填):存储库所有者
  • repo (字符串,必填):存储库名称
  • pull_number (number,必填):拉取请求编号

示例响应:

{
  "repository": "owner/repo",
  "pull_request": 123,
  "head_sha": "abc123...",
  "check_runs": [
    {
      "id": 9876543,
      "name": "build",
      "status": "completed",
      "conclusion": "success",
      "started_at": "2024-01-02T10:00:00Z",
      "completed_at": "2024-01-02T10:05:00Z",
      "html_url": "https://github.com/owner/repo/actions/runs/9876543"
    }
  ],
  "statuses": [
    {
      "state": "success",
      "context": "continuous-integration/travis-ci",
      "description": "The Travis CI build passed",
      "target_url": "https://travis-ci.org/owner/repo/builds/12345"
    }
  ]
}

发展

# Install dependencies
npm install

# Run in development mode
npm run dev

# Build for production
npm run build

# Start production server
npm start

需求

  • Node.js 18+
  • GitHub个人访问令牌
  • MCP兼容客户端

许可证

麻省理工学院