MCP Code Expert System
MCP代码专家系统
一个基于 Python 的代码审查系统,使用模型上下文协议 (MCP)。它通过模拟专家角色(例如 Martin Fowler 和 Robert C. Martin(鲍勃叔叔))提供代码审查功能。
特征
根据 Martin Fowler 的重构原则进行代码审查
根据 Robert C. Martin 的清洁代码原则进行代码审查
代码、评论和关系的知识图谱存储
与 Ollama 集成,实现人工智能评论
Web 集成的服务器端事件 (SSE) 支持
Related MCP server: greybeard
先决条件
Python 3.10+
该项目需要 Python 3.10 或更高版本。
奥拉马
人工智能代码审查需要Ollama 。
为您的平台安装 Ollama:
macOS :从ollama.com下载
Linux :
curl -fsSL https://ollama.com/install.sh | shWindows :通过 Linux 指令支持 Windows WSL2
拉个推荐模型:
ollama pull llama3:8b启动 Ollama 服务器:
ollama serve
安装
运行安装脚本来安装依赖项并创建虚拟环境:
chmod +x setup.sh
./setup.sh配置
编辑.env文件进行配置(如果需要,可以从.env.example创建):
# Knowledge Graph Settings
KNOWLEDGE_GRAPH_PATH=data/knowledge_graph.json
# Ollama Configuration (local AI models)
OLLAMA_HOST=http://localhost:11434
OLLAMA_MODEL=llama3:8b用法
运行服务器
标准模式(用于光标集成)
source .venv/bin/activate
python server.pyHTTP/SSE 模式(用于 Web 集成)
source .venv/bin/activate
python server.py --transport sse这将在http://localhost:8000/sse启动服务器以进行 SSE 传输。
对于自定义端口:
python server.py --transport sse --port 9000在光标处安装
要在 Cursor IDE 中安装:
source .venv/bin/activate
mcp install server.py --name "Code Expert System"可用工具
服务器公开了这些工具:
ask_martin:请 Martin Fowler 审查代码并提出重构建议ask_bob:请 Robert C. Martin(鲍勃大叔)根据清洁代码原则审查代码read_graph:读取整个知识图谱search_nodes:搜索知识图谱中的节点open_nodes:通过名称打开特定节点
示例用法
与 Martin Fowler 一起审查代码片段:
{
"code": "function calculateTotal(items) {\n var total = 0;\n for (var i = 0; i < items.length; i++) {\n total += items[i].price;\n }\n return total;\n}",
"language": "javascript",
"description": "Calculate the total price of items"
}项目结构
server.py:集成 MCP 的主服务器实现experts/:实现代码审查功能的专家模块__init__.py:共享模型和接口martin_fowler/:Martin Fowler 专家实施robert_c_martin/:Robert C. Martin 专家实施
knowledge_graph.py:用于存储代码和评论的知识图谱ollama_service.py:与 Ollama 集成,实现 AI 驱动的评论examples/:用于审查不同语言的示例代码requirements.txt:Python 依赖项setup.sh:安装脚本
建筑学
该系统采用模块化架构:
服务器层:处理 MCP 协议通信并路由请求
专家层:封装每个专家的代码审查逻辑
服务层:提供AI集成和知识图谱功能
每个专家都实现了一个标准接口,允许一致处理和轻松添加新专家。
执照
麻省理工学院
This server cannot be deployed
Maintenance
Related MCP Connectors
A Model Context Protocol (MCP) application for automated GitHub PR analysis and issue management.…
AI code review for GitHub PRs with an MCP autofix loop for Claude Code and Cursor
AI-native git hosting — repos, PRs, issues, CI gates, and AI code review over MCP (60 tools).
MCP server for AI agent profiles and smart notes. 60+ coding prompt packs with expert personas.
Related MCP Servers
- AlicenseNot gradedqualityCmaintenanceNeuroDev MCP is a smart Model Context Protocol server for Python development. It performs deep code review, generates high-quality unit tests, runs test suites with coverage, and formats code automatically — all through an AI assistant like Claude or Cline.MIT
- AlicenseNot gradedqualityCmaintenanceAn MCP server that provides AI-powered code review and architecture analysis, simulating the perspective of an experienced staff engineer. It integrates with IDEs to review diffs, design decisions, and tradeoffs through natural language.1MIT
- AlicenseNot gradedqualityDmaintenanceAn AI-powered code review agent that leverages Model Context Protocol (MCP) and Claude to provide intelligent, context-aware code reviews.MIT
- AlicenseAqualityDmaintenanceAn MCP server that performs automated code reviews by analyzing git diffs against configurable review standards with custom reviewer personas.72MIT