Skip to content

smit-faldu/mcp_code_review_assistant

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

1 Commit
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿš€ Unified MCP Code Review Assistant

A comprehensive, intelligent code generation and review system with dual modes: Simple for quick tasks and Advanced for complex projects with iterative improvement.

โœจ Key Features

๐ŸŽฏ Dual Mode Architecture

  • Simple Mode: Fast, straightforward code generation and review
  • Advanced Mode: LangChain + LangGraph with iterative improvement
  • Seamless Switching: Change modes without restarting

๐Ÿ”ง Simple Mode Features

  • โœ… Quick code generation with Gemini 2.5
  • โœ… Comprehensive code reviews
  • โœ… Session-based history
  • โœ… Fast response times
  • โœ… Perfect for quick tasks and learning

โšก Advanced Mode Features

  • โœ… 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

๐Ÿ“ Unified Project Structure

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

๐Ÿš€ Quick Start

1. Installation

# 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-core

2. Configuration

Create or edit .env file:

GEMINI_API_KEY=your_actual_api_key_here

Get your API key from: Google AI Studio

3. Run the Application

python unified_main.py

๐ŸŽฎ Usage Guide

Mode Selection

When 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

๐Ÿ“ 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

๐Ÿ“ 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 Comparison

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

๐Ÿงช Testing

Run comprehensive tests:

python test_unified.py

Expected 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!

๐Ÿ”ง Configuration Options

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
}

๐ŸŽฏ Example Usage

Simple Mode Example:

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...

Advanced Mode Example:

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

๐Ÿ› ๏ธ Troubleshooting

Common Issues:

  1. "GEMINI_API_KEY not set"

    • Solution: Add your API key to the .env file
  2. "Advanced mode import error"

    • Solution: Install advanced dependencies:
      pip install langchain langgraph langchain-google-genai
  3. "Configuration issue"

    • Solution: Check your .env file and API key validity

Getting Help:

  1. Run tests: python test_unified.py
  2. Check configuration: Verify .env file
  3. Check dependencies: Ensure all packages are installed

๐Ÿš€ Advanced Features

LangGraph Workflow Visualization:

[START] โ†’ Generate Code โ†’ Review Code โ†’ Decision Point
                                            โ†“
                                      Needs Improvement?
                                            โ†“
                              YES โ†’ Improve Code โ”€โ”€โ”
                               โ†‘                   โ”‚
                               โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                                            โ†“
                              NO โ†’ Finalize โ†’ [END]

Quality Metrics:

  • Readability: Code clarity and documentation
  • Maintainability: Ease of modification and extension
  • Performance: Efficiency and optimization
  • Security: Vulnerability assessment
  • Overall: Comprehensive quality score

State Management:

  • Persistent conversation threads
  • Memory checkpointing
  • Session management
  • History tracking

๐Ÿ“ Dependencies

Core (Required):

  • google-generativeai - Gemini API integration
  • pydantic - Data validation and schemas
  • python-dotenv - Environment variable management

Advanced (Optional):

  • langchain - LLM application framework
  • langchain-google-genai - Gemini integration for LangChain
  • langgraph - State management and workflow orchestration
  • langchain-core - Core LangChain functionality

๐ŸŽ‰ Benefits of Unified Architecture

  1. Single Entry Point: One command to rule them all
  2. Mode Flexibility: Choose the right tool for the task
  3. Seamless Switching: Change modes without restart
  4. Consistent Interface: Same commands across modes
  5. Progressive Enhancement: Start simple, upgrade when needed
  6. Comprehensive Testing: Full test coverage
  7. Clean Configuration: Centralized settings management

๐Ÿ”ฎ Future Enhancements

  • 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

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages