mcp-pr-reviewer

mcp-pr-reviewer

Analyzes GitHub Pull Requests using AI via MCP, providing detailed feedback and approve/reject decisions.

Category
访问服务器

README

MCP PR Reviewer

npm version License: MIT

Intelligent PR reviews powered by the Model Context Protocol and LLMs.

MCP PR Reviewer analyzes GitHub Pull Requests using AI, leveraging the Model Context Protocol for secure GitHub integration and providing detailed feedback.

🚀 Features

  • MCP GitHub Integration: Securely fetches PR data using @modelcontextprotocol/server-github.
  • AI-Powered Analysis: Uses configurable LLMs via OpenRouter for insightful code review.
  • Structured Feedback: Provides a clear decision (Approve/Reject), summary, and key points.
  • CLI & Server Modes: Usable both directly for analysis and as a server for integrations.
  • Customizable: Choose your preferred LLM model.

🔧 Installation

# Install globally
npm install -g mcp-pr-reviewer

# Or use with npx without installing
npx mcp-pr-reviewer --help

💻 Usage

Prerequisites

Set the following environment variables:

  • GITHUB_TOKEN: Your GitHub Personal Access Token with repo scope.
  • OPENROUTER_API_KEY: Your API key from OpenRouter.ai.

Analyze a Pull Request

# Format
mcp-pr-reviewer analyze <owner> <repo> <pr-number> [options]

# Example
mcp-pr-reviewer analyze octocat hello-world 123

# Example with specific ports and model
mcp-pr-reviewer analyze myorg my-repo 456 --mcp-port 8081 --llm-port 8091 --model openrouter/anthropic/claude-3-haiku

Options:

  • --mcp-port <port>: Port for the internal MCP GitHub server (default: 8080).
  • --llm-port <port>: Port for the internal LLM provider server (default: 8090).
  • -m, --model <model>: Specify the OpenRouter model ID (default: openrouter/optimus-alpha).

Run as a Server (for Integrations)

The server command starts only the LLM provider component, making it available as an MCP server for other tools or integrations (like GitHub Actions).

# Start the LLM Provider server
mcp-pr-reviewer server --port 8012 --model openrouter/google/gemini-pro

This allows external systems to call its analyze_pr capability.

🧩 MCP Configuration (Example for Cursor)

You can integrate mcp-pr-reviewer with tools like Cursor using an mcp.json file. Here's an example configuration:

{
  "mcpServers": {
    "GitHub MCP": {
      "command": "npx",
      "type": "stdio",
      "env": {
        "GITHUB_PERSONAL_ACCESS_TOKEN": "YOUR_GITHUB_PAT_HERE"
      },
      "args": [
        "@modelcontextprotocol/server-github"
      ]
    },
    "PR Reviewer": {
      "command": "npx",
      "type": "http",
      "baseUrl": "http://localhost:8012",
      "env": {
        "OPENROUTER_API_KEY": "YOUR_OPENROUTER_KEY_HERE"
      },
      "args": [
        "mcp-pr-reviewer",
        "server",
        "--port",
        "8012"
      ]
    }
  }
}

Note: Replace placeholders like YOUR_GITHUB_PAT_HERE and YOUR_OPENROUTER_KEY_HERE with your actual credentials.

🏗️ Architecture

The analyze command orchestrates two main components:

  1. MCP GitHub Server: An instance of @modelcontextprotocol/server-github started internally to handle secure communication with the GitHub API.
  2. LLM Provider Server: A simple Express server (lib/mcp-llm-provider.js) started internally that:
    • Accepts analysis requests.
    • Communicates with the OpenRouter API to get the LLM analysis.

The lib/analyze-pr.js script coordinates the process:

  1. Connects to the running MCP GitHub Server (via HTTP) to fetch the PR diff.
  2. Sends the diff to the running LLM Provider Server (via HTTP) for analysis.
  3. Outputs the formatted review.

The server command only starts the LLM Provider Server, exposing it for external MCP calls.

🤝 Contributing

Contributions are welcome! Please fork the repository and submit a Pull Request.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

📜 License

MIT License - see the LICENSE file for details.

📚 FAQ

Q: What is Model Context Protocol (MCP)? A: An open standard allowing AI models to securely interact with tools and data sources. See modelcontext.dev.

Q: Does it work with private repositories? A: Yes, ensure your GITHUB_TOKEN has the necessary permissions (e.g., repo scope).

Q: Can I use models other than OpenRouter? A: Currently, it's hardcoded for OpenRouter. Modifying lib/mcp-llm-provider.js would be required to support other providers.

Q: How is this different from GitHub Copilot's PR Summary? A: This tool provides a more opinionated review, including an Approve/Reject decision and specific feedback points based on a configurable prompt, rather than just a summary.

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选