A comprehensive, intelligent code generation and review system with dual modes: Simple for quick tasks and Advanced for complex projects with iterative improvement.
- Simple Mode: Fast, straightforward code generation and review
- Advanced Mode: LangChain + LangGraph with iterative improvement
- Seamless Switching: Change modes without restarting
- โ Quick code generation with Gemini 2.5
- โ Comprehensive code reviews
- โ Session-based history
- โ Fast response times
- โ Perfect for quick tasks and learning
- โ Iterative code improvement (up to 3 cycles)
- โ Quality metrics with numerical scores (1-10)
- โ LangGraph workflow orchestration
- โ State management and memory checkpointing
- โ Conditional routing based on code quality
- โ Structured reviews with priority issues
- โ Perfect for complex projects
mcp_code_review_assistant/
โโโ unified_main.py # ๐ฏ Single entry point
โโโ config.py # โ๏ธ Unified configuration
โโโ utils.py # ๐ ๏ธ Common utilities
โโโ unified_requirements.txt # ๐ฆ All dependencies
โโโ test_unified.py # ๐งช Comprehensive tests
โโโ UNIFIED_README.md # ๐ This documentation
โ
โโโ # Core Components (Simple Mode)
โโโ orchestrator.py # Simple workflow orchestrator
โโโ schemas.py # Basic MCP message schemas
โโโ agents/
โ โโโ coder_agent.py # Basic code generation
โ โโโ reviewer_agent.py # Basic code review
โ
โโโ # Enhanced Components (Advanced Mode)
โโโ langgraph_orchestrator.py # LangGraph workflow
โโโ enhanced_schemas.py # Advanced schemas with metrics
โโโ langchain_agents/
โ โโโ enhanced_coder_agent.py # LangChain-powered coder
โ โโโ enhanced_reviewer_agent.py # Structured reviewer
โ
โโโ # Configuration & Environment
โโโ .env # API key configuration
โโโ .gitignore # Git ignore rules
# Clone or download the project
cd mcp_code_review_assistant
# Install core dependencies (required)
pip install google-generativeai pydantic python-dotenv
# Install advanced dependencies (optional, for advanced mode)
pip install langchain langgraph langchain-google-genai langchain-coreCreate or edit .env file:
GEMINI_API_KEY=your_actual_api_key_hereGet your API key from: Google AI Studio
python unified_main.pyWhen you start the application, you'll see:
๐ฏ Choose Your Experience Mode:
1. ๐ Simple Mode - Quick code generation and review
2. โก Advanced Mode - LangChain + LangGraph with iterative improvement
3. โน๏ธ Show feature comparison
4. ๐ช Exit
๐ Simple Mode Commands:
โข Enter any code request
โข 'history' - View workflow history
โข 'clear' - Clear message history
โข 'mode' - Switch to advanced mode
โข 'quit' - Exit application
๐ Advanced Mode Commands:
โข Enter any code request for iterative improvement
โข 'workflow' - Show LangGraph workflow visualization
โข 'history' - Show current thread history
โข 'clear' - Clear thread memory
โข 'mode' - Switch to simple mode
โข 'quit' - Exit application
| Feature | Simple Mode | Advanced Mode |
|---|---|---|
| Code Generation | โ Single pass | โ Iterative (up to 3x) |
| Code Review | โ Text-based | โ Structured metrics |
| Quality Scores | โ No | โ 1-10 scale |
| Auto Improvement | โ No | โ Yes |
| Workflow Control | โ Linear | โ Conditional routing |
| State Management | โ Basic | โ Advanced (LangGraph) |
| Memory | โ Session | โ Persistent threads |
| Error Handling | โ Basic | โ Robust with fallbacks |
| Speed | โ Fast | โก Moderate (thorough) |
| Best For | ๐ Quick tasks | ๐ฏ Complex projects |
Run comprehensive tests:
python test_unified.pyExpected output:
โ
Core Imports: PASSED
โ
Simple Mode Imports: PASSED
โ
Advanced Mode Imports: PASSED
โ
Configuration: PASSED
โ
Utilities: PASSED
โ
Simple Mode Functionality: PASSED
โ
Advanced Mode Functionality: PASSED
โ
Unified Main Module: PASSED
Tests passed: 8/8
๐ All tests passed!
Edit config.py to customize:
# API Configuration
GEMINI_MODEL = "gemini-2.5-flash-lite-preview-06-17"
# Simple Mode Settings
SIMPLE_MODE = {
'temperature': 0.3,
'max_tokens': 2000,
'timeout': 30
}
# Advanced Mode Settings
ADVANCED_MODE = {
'temperature': 0.3,
'max_tokens': 2000,
'timeout': 30,
'max_iterations': 3,
'quality_threshold': 8.0
}Your request: Create a function to calculate factorial
๐ง Generated Code:
def factorial(n):
if n == 0 or n == 1:
return 1
return n * factorial(n - 1)
๐ Code Review:
The function correctly implements factorial calculation using recursion...
Your request: Create a function to calculate factorial
๐ง Generating code (iteration 1)...
๐ Reviewing code (iteration 1)...
๐ Code needs improvement (iteration 1)
โก Improving code (iteration 1)...
๐ Reviewing code (iteration 2)...
๐ฏ Code quality is satisfactory, finalizing...
๐ Code Quality Metrics:
๐ Readability: 9.0/10
๐ง Maintainability: 8.5/10
โก Performance: 8.0/10
๐ Security: 9.0/10
๐ฏ Overall Score: 8.6/10
๐ Workflow Summary:
๐ Total iterations: 2
๐ฌ Messages processed: 6
๐ Final step: completed
-
"GEMINI_API_KEY not set"
- Solution: Add your API key to the
.envfile
- Solution: Add your API key to the
-
"Advanced mode import error"
- Solution: Install advanced dependencies:
pip install langchain langgraph langchain-google-genai
- Solution: Install advanced dependencies:
-
"Configuration issue"
- Solution: Check your
.envfile and API key validity
- Solution: Check your
- Run tests:
python test_unified.py - Check configuration: Verify
.envfile - Check dependencies: Ensure all packages are installed
[START] โ Generate Code โ Review Code โ Decision Point
โ
Needs Improvement?
โ
YES โ Improve Code โโโ
โ โ
โโโโโโโโโโโโโโโโโโโโโ
โ
NO โ Finalize โ [END]
- Readability: Code clarity and documentation
- Maintainability: Ease of modification and extension
- Performance: Efficiency and optimization
- Security: Vulnerability assessment
- Overall: Comprehensive quality score
- Persistent conversation threads
- Memory checkpointing
- Session management
- History tracking
google-generativeai- Gemini API integrationpydantic- Data validation and schemaspython-dotenv- Environment variable management
langchain- LLM application frameworklangchain-google-genai- Gemini integration for LangChainlanggraph- State management and workflow orchestrationlangchain-core- Core LangChain functionality
- Single Entry Point: One command to rule them all
- Mode Flexibility: Choose the right tool for the task
- Seamless Switching: Change modes without restart
- Consistent Interface: Same commands across modes
- Progressive Enhancement: Start simple, upgrade when needed
- Comprehensive Testing: Full test coverage
- Clean Configuration: Centralized settings management
- Web interface for better user experience
- Support for multiple programming languages
- Integration with popular IDEs
- Team collaboration features
- Custom workflow templates
- Performance analytics and insights
Ready to start coding smarter? ๐
python unified_main.py