这是一个使用 GitHub 私人访问令牌获取 GitHub 拉取请求评论的模型上下文协议(MCP)服务器,能帮助用户方便地获取 PR 评论信息,以结构化的 JSON 格式呈现,便于后续处理和使用。
本服务器提供了自动和手动两种安装方式,你可以根据自己的需求进行选择。
安装完成后,按照步骤构建项目、运行服务器,即可使用 get_pr_comments 工具获取 PR 评论。
要通过 Smithery 自动为 Claude Desktop 安装 github - pr - mcp,可执行以下命令:
npx -y @smithery/cli install github-pr-mcp --client claude
npm install
.env 文件:GITHUB_TOKEN=your_github_token_here
npm run build
npm start
或直接使用 GitHub 令牌运行:
node dist/server.js your_github_token_here
get_pr_comments 的工具,接受以下参数:
owner: 仓库所有者(用户名或组织)repo: 仓库名称pull_number: 拉取请求编号要将此服务器集成到 Cursor,请在 Cursor 的 MCP 服务器配置中使用以下命令:
node /path/to/dist/server.js your_github_token_here
请将 /path/to 替换为实际项目路径,并将 your_github_token_here 替换为你的 GitHub 个人访问令牌。
包含一个测试客户端来验证服务器功能:
npm run build
npm test
测试客户端将启动服务器,连接到它,并调用 get_pr_comments 工具,使用示例参数。
服务器返回以下 JSON 格式评论:
{
"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 许可证。