CodeReviewAgent / README.md
c1r3x's picture
Review Agent: Removed the pdf export
1e22c34

A newer version of the Gradio SDK is available: 5.34.2

Upgrade
metadata
title: Code Review Agent
emoji: πŸ‘€
colorFrom: purple
colorTo: blue
sdk: gradio
sdk_version: 5.33.1
app_file: app.py
pinned: true
short_description: An AI-powered code review agent that analyzes Github Repos

Code Review Agent

agent-demo-track MCP-Server

A professional-grade code review agent that leverages AI to provide comprehensive code analysis and actionable recommendations. Built for the Gradio MCP Hackathon, this tool helps developers improve code quality through automated reviews powered by advanced AI models.

Gradio MCP Hackathon

πŸš€ Features

  • Multi-Language Support: Analyzes code in 15+ programming languages including Python, JavaScript, TypeScript, Java, C++, and more
  • Enterprise-Grade UI: Professional Gradio interface with modern design and intuitive workflow
  • Advanced Analysis: Comprehensive insights on security vulnerabilities, performance bottlenecks, and code quality issues
  • GitHub Integration: Support for both public and private GitHub repositories with secure token authentication
  • MCP Server: Functions as a Model Context Protocol (MCP) server, allowing LLMs to use this tool for code review operations
  • Professional Reporting: Detailed reports with actionable recommendations organized by priority
  • Customizable Reviews: Select specific languages to focus the review on parts of your codebase that matter most

πŸ—οΈ Architecture

The system follows a robust 4-layer architecture designed for extensibility and maintainability:

  1. Presentation Layer: Gradio-based UI with professional dashboard and intuitive controls
  2. Application Layer: Core business logic and review engine with modular components
  3. Service Layer: External integrations and analysis services with clean interfaces
  4. MCP Layer: Implements the Model Context Protocol (MCP) server functionality, allowing LLMs to use this tool for code review operations through standardized communication

πŸ“‹ Requirements

  • Python 3.8+
  • Git
  • Internet connection for AI model access
  • GitHub token (optional, for private repositories)

πŸ”§ Installation

# Clone the repository
git clone https://huggingface.co/spaces/c1r3x/code-review-agent
cd code-review-agent

# Install dependencies
pip install -r requirements.txt

# Set up environment variables (optional)
cp sample.env .env
# Edit .env with your configuration

πŸš€ Usage

python src/main.py

Then open your browser to http://localhost:7860 to access the Code Review Agent.

Analyzing a Repository

  1. Enter the GitHub repository URL in the input field
  2. Optionally enter your GitHub token for private repositories
  3. Select the programming languages to focus the review on
  4. Click "Submit" to start the analysis
  5. View the comprehensive report with actionable recommendations

🐳 Docker Deployment

# Build and run with Docker Compose
docker-compose up -d

Access the application at http://localhost:7860

πŸ”Œ MCP Server Functionality

This application functions as a Model Context Protocol (MCP) server, allowing Large Language Models (LLMs) to use it as a tool for code review operations:

  • MCP Integration: Exposes code review capabilities through standardized MCP endpoints
  • LLM Tool Usage: Can be called by LLMs like Claude, GPT-4, and others that support the MCP protocol
  • Tool Operations: Provides repository analysis, code review, and report generation as MCP operations
  • Structured Responses: Returns analysis results in structured formats compatible with LLM processing

To use this as an MCP server with your LLM:

  1. Deploy the application using the instructions above
  2. Configure your MCP client to connect to the server endpoint
  3. The LLM can then use the code review capabilities through MCP tool calls

πŸ§ͺ Testing

# Run the test suite
python -m pytest tests/

πŸ“ Project Structure

β”œβ”€β”€ .gitignore              # Git ignore file
β”œβ”€β”€ Dockerfile              # Docker configuration
β”œβ”€β”€ LICENSE                 # MIT License file
β”œβ”€β”€ README.md               # Project documentation
β”œβ”€β”€ app.py                  # Entry point for Hugging Face Spaces
β”œβ”€β”€ docker-compose.yml      # Docker Compose configuration
β”œβ”€β”€ modal_deploy.py         # Modal deployment configuration
β”œβ”€β”€ requirements.txt        # Python dependencies
β”œβ”€β”€ sample.env              # Sample environment variables
β”œβ”€β”€ setup.py                # Package setup configuration
β”œβ”€β”€ src/                    # Source code directory
β”‚   β”œβ”€β”€ __init__.py         # Package initialization
β”‚   β”œβ”€β”€ core/               # Core application logic
β”‚   β”‚   β”œβ”€β”€ __init__.py
β”‚   β”‚   β”œβ”€β”€ agent_manager.py    # Agent orchestration
β”‚   β”‚   └── language_detector.py # Language detection
β”‚   β”œβ”€β”€ main.py             # Main application entry point
β”‚   β”œβ”€β”€ mcp/                # MCP server implementation
β”‚   β”‚   β”œβ”€β”€ __init__.py
β”‚   β”‚   └── ai_review.py    # AI review integration
β”‚   β”œβ”€β”€ services/           # Service layer components
β”‚   β”‚   β”œβ”€β”€ __init__.py
β”‚   β”‚   β”œβ”€β”€ code_analyzer.py       # Code analysis
β”‚   β”‚   β”œβ”€β”€ performance_analyzer.py # Performance analysis
β”‚   β”‚   β”œβ”€β”€ report_generator.py     # Report generation
β”‚   β”‚   β”œβ”€β”€ repository_service.py   # Repository operations
β”‚   β”‚   └── security_scanner.py     # Security scanning
β”‚   └── ui/                 # User interface components
β”‚       β”œβ”€β”€ __init__.py
β”‚       β”œβ”€β”€ components/     # UI components
β”‚       β”œβ”€β”€ gradio_app.py   # Gradio application
β”‚       └── styles/         # UI styling
└── tests/                  # Test directory
    β”œβ”€β”€ test_agent_manager.py
    β”œβ”€β”€ test_ai_review.py
    β”œβ”€β”€ test_code_analyzer.py
    β”œβ”€β”€ test_language_detector.py
    β”œβ”€β”€ test_performance_analyzer.py
    β”œβ”€β”€ test_report_generator.py
    β”œβ”€β”€ test_repository_service.py
    └── test_security_scanner.py

🀝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.