代码审查服务器

一个通过MCP协议连接Cursor和OpenRouter API的服务器实现,提供代码审查和AI聊天功能。

  • by arahisman
  • JavaScript
  • 本地部署
  • 更新于
在 GitHub 查看 arahisman/mcp-server-code-review

使用说明

MCP服务器-代码审查

模型上下文协议(MCP)的服务器实现,通过stdio将Cursor连接到OpenRouter API,实现代码审查和AI聊天功能。

特性

  • 连接到OpenRouter API以访问各种大型语言模型
  • 提供两个主要功能:
    • 简单的文本提示响应(ask 工具)
    • 带有项目上下文分析的自动代码审查(code_review 工具)
  • 与repomix集成,用于代码库打包和分析
  • 支持多语言项目检测
  • 作为与MCP协议兼容的stdio服务器运行

安装

# Install globally
npm install -g mcp-server-code-review

# Or install locally in your project
npm install mcp-server-code-review

需求

  • Node.js v16或更高版本
  • OpenRouter API密钥-在获取 OpenRouter 的

用法

命令行

mcp-server-code-review --api-key YOUR_OPENROUTER_API_KEY [--default-model MODEL_ID]

选项

  • --api-key, -k (必需):您的OpenRouter API密钥
  • --default-model, -m (可选):要使用的默认模型(默认为 google/gemini-2.0-flash-thinking-exp:free)

示例

mcp-server-code-review --api-key sk-or-v1-xxxxxxxxxxxx --default-model anthropic/claude-3-haiku:free

MCP工具

此服务器实现了两个主要的MCP工具:

1.问工具

向OpenRouter API发送简单的文本提示并返回响应。

"mcp-openrouter-stdio": {
      "name": "mcp-openrouter-stdio",
      "command": "npx",
      "args": [
        "mcp-openrouter-stdio",
        "--api-key",
        "sk-or-v1-your_key",
        "--default-model",
        "google/gemini-2.0-flash-thinking-exp:free"
      ],
      "transport": "stdio"
    },

2.代码审查工具

使用带有项目上下文分析的OpenRouter API执行代码审查。

{
  name: "code_review",
  arguments: {
    completed_tasks: ["Task 1", "Task 2"],
    work_report: "Details of the work performed",
    project_path: "/absolute/path/to/project",
    planned_tasks: ["Future task 1", "Future task 2"],
    language: "js", // Primary language of the project
    model: "optional-model-id" // Uses default if not specified
  }
}

支持的语言

服务器可以自动检测和分析各种编程语言的项目:

  • JavaScript/TypeScript(js)
  • Python(Python)
  • C#(csharp)
  • PHP(PHP)
  • Java(Java)
  • 红宝石(Ruby)
  • 走(走)
  • 锈(锈)
  • C++(cpp)
  • Swift(Swift)

发展

# Clone the repository
git clone https://github.com/arahisman/mcp-server-code-review.git
cd mcp-server-code-review

# Install dependencies
npm install

# Build the project
npm run build

# Watch mode for development
npm run watch

测试

存储库包括几个测试脚本:

# Basic server test
node test-mcp-server.js

# Test the ask tool
node test-ask.js

# Simple functionality test
node simple-test.js

许可证

麻省理工学院

作者

亚当 拉希斯曼