🚀 Socket Launch Week Day 5:Introducing Repository Access Permissions and Custom Roles.Learn more
Sign In

ai-code-review-mcp

Package Overview
Dependencies
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ai-code-review-mcp

AI代码审查MCP服务 - 基于DeepSeek和Gitee的智能代码审查工具

latest
Source
npmnpm
Version
1.1.3
Version published
Weekly downloads
46
130%
Maintainers
1
Weekly downloads
 
Created
Source

AI 代码审查系统 (MCP 版本)

基于 MCP (Model Context Protocol) 的智能代码审查系统,集成 DeepSeek AI 和 Gitee 平台,为代码审查提供智能化支持。

功能特性

  • 🤖 智能代码审查: 基于 DeepSeek AI 的深度代码分析
  • 🔄 自动化流程: 与 Gitee 平台深度集成,支持 PR 自动审查
  • 🎯 多语言支持: 支持 Python、JavaScript、Java、Go 等主流编程语言
  • 📊 详细报告: 提供代码质量、安全性、性能等多维度分析
  • 🔧 MCP 协议: 基于标准 MCP 协议,易于集成和扩展
  • 📦 便捷部署: 支持 npm 全局安装,一键启动

系统架构

┌─────────────────┐    ┌─────────────────┐    ┌─────────────────┐
│   MCP Client    │    │   MCP Server    │    │  External APIs  │
│   (Claude等)    │◄──►│  (本系统)       │◄──►│  DeepSeek/Gitee │
└─────────────────┘    └─────────────────┘    └─────────────────┘

快速开始

环境要求

  • Python 3.8+
  • Node.js 16+ (用于 npm 安装)
  • Git

安装部署

方式 1: npm 全局安装 (推荐)

# 全局安装
npm install -g ai-code-review-mcp

# 初始化配置
ai-code-review-mcp --setup

# 启动服务
ai-code-review-mcp

方式 2: 本地开发安装

# 克隆项目
git clone <repository-url>
cd ai-code-review

# 安装依赖
npm install

# 初始化配置
npm run setup

# 启动服务
npm start

环境配置

必需环境变量

# DeepSeek API配置
export DEEPSEEK_API_KEY="your_deepseek_api_key"

# Gitee API配置
export GITEE_ACCESS_TOKEN="your_gitee_access_token"

可选环境变量

# DeepSeek API配置
export DEEPSEEK_BASE_URL="https://api.deepseek.com"  # 默认值
export DEEPSEEK_MODEL="deepseek-coder"               # 默认值

# 日志配置
export LOG_LEVEL="INFO"                              # 默认值
export LOG_FILE="logs/mcp_server.log"               # 默认值

# MCP服务配置
export MCP_SERVER_NAME="ai-code-review"             # 默认值
export MCP_SERVER_VERSION="1.0.0"                   # 默认值

配置文件方式

创建 .env 文件:

# 复制示例配置
cp .env.example .env

# 编辑配置文件
vim .env

或者在用户主目录创建全局配置:

# 创建全局配置文件
touch ~/.ai-code-review-mcp.env

# 添加配置
echo "DEEPSEEK_API_KEY=your_key_here" >> ~/.ai-code-review-mcp.env
echo "GITEE_ACCESS_TOKEN=your_token_here" >> ~/.ai-code-review-mcp.env

使用方式

MCP 客户端配置

在支持 MCP 的客户端(如 Claude Desktop)中配置:

{
  "mcpServers": {
    "ai-code-review": {
      "command": "ai-code-review-mcp",
      "args": []
    }
  }
}

命令行使用

# 显示帮助
ai-code-review-mcp --help

# 显示版本
ai-code-review-mcp --version

# 初始化配置
ai-code-review-mcp --setup

# 启动服务(默认)
ai-code-review-mcp

MCP 工具说明

系统提供以下 MCP 工具:

1. review_code

审查代码片段或文件

参数:

  • code: 要审查的代码内容
  • language: 编程语言 (可选)
  • context: 额外上下文信息 (可选)

2. review_pull_request

审查 Gitee Pull Request

参数:

  • repo_url: 仓库 URL
  • pr_number: PR 编号
  • review_scope: 审查范围 (可选: 'full', 'diff', 'files')

3. get_pr_info

获取 Pull Request 信息

参数:

  • repo_url: 仓库 URL
  • pr_number: PR 编号

4. create_review_comment

创建审查评论

参数:

  • repo_url: 仓库 URL
  • pr_number: PR 编号
  • comment: 评论内容
  • file_path: 文件路径 (可选)
  • line_number: 行号 (可选)

开发指南

项目结构

ai-code-review/
├── bin/                    # 可执行脚本
│   └── ai-code-review-mcp
├── mcp/                    # MCP服务核心
│   ├── __init__.py
│   ├── mcp_server.py      # MCP服务器
│   ├── mcp_adapter.py     # MCP适配器
│   ├── mcp_config.py      # 配置管理
│   └── services/          # 业务服务
│       ├── code_review_service.py
│       ├── deepseek_service.py
│       ├── gitee_service.py
│       └── pr_automation_service.py
├── start_mcp.py           # 启动脚本
├── requirements.txt       # Python依赖
├── package.json          # npm配置
└── README.md

本地开发

# 安装开发依赖
pip install -r requirements.txt

# 运行测试
pytest

# 代码格式化
black .

# 类型检查
mypy .

故障排除

常见问题

  • 环境变量未设置

    错误: 缺少必要的环境变量: DEEPSEEK_API_KEY
    

    解决: 设置相应的环境变量或创建 .env 文件

  • Python 版本不兼容

    错误: 未找到python3命令
    

    解决: 安装 Python 3.8+

  • 依赖安装失败

    错误: 无法安装Python依赖
    

    解决: 检查网络连接,或使用国内镜像源

日志查看

# 查看服务日志
tail -f logs/mcp_server.log

# 查看错误日志
grep ERROR logs/mcp_server.log

贡献指南

  • Fork 项目
  • 创建特性分支 (git checkout -b feature/AmazingFeature)
  • 提交更改 (git commit -m 'Add some AmazingFeature')
  • 推送到分支 (git push origin feature/AmazingFeature)
  • 打开 Pull Request

许可证

本项目采用 MIT 许可证 - 查看 LICENSE 文件了解详情。

支持

如有问题或建议,请:

Keywords

mcp

FAQs

Package last updated on 23 Oct 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts