Code Expert System
STDIOPython-based code review system with simulated expert personas for code analysis.
Python-based code review system with simulated expert personas for code analysis.
A Python-based code review system using the Model Context Protocol (MCP). It provides code review capabilities through simulated expert personas like Martin Fowler and Robert C. Martin (Uncle Bob).
This project requires Python 3.10 or higher.
Ollama is required for AI-powered code reviews.
Install Ollama for your platform:
curl -fsSL https://ollama.com/install.sh | sh
Pull a recommended model:
ollama pull llama3:8b
Start the Ollama server:
ollama serve
Run the setup script to install dependencies and create the virtual environment:
chmod +x setup.sh ./setup.sh
Edit the .env
file to configure (create from .env.example
if needed):
# 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.py
source .venv/bin/activate python server.py --transport sse
This will start the server at http://localhost:8000/sse
for SSE transport.
For custom port:
python server.py --transport sse --port 9000
To install in Cursor IDE:
source .venv/bin/activate mcp install server.py --name "Code Expert System"
The server exposes these tools:
ask_martin
: Ask Martin Fowler to review code and suggest refactoringsask_bob
: Ask Robert C. Martin (Uncle Bob) to review code based on Clean Code principlesread_graph
: Read the entire knowledge graphsearch_nodes
: Search for nodes in the knowledge graphopen_nodes
: Open specific nodes by their namesTo review a code snippet with 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
: Main server implementation with MCP integrationexperts/
: Expert modules implementing the code review capabilities
__init__.py
: Shared models and interfacesmartin_fowler/
: Martin Fowler expert implementationrobert_c_martin/
: Robert C. Martin expert implementationknowledge_graph.py
: Knowledge graph for storing code and reviewsollama_service.py
: Integration with Ollama for AI-powered reviewsexamples/
: Example code for review in different languagesrequirements.txt
: Python dependenciessetup.sh
: Setup scriptThe system follows a modular architecture:
Each expert implements a standard interface allowing for consistent handling and easy addition of new experts.
MIT