|
--- |
|
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 |
|
|
|
[](https://huggingface.co/Agents-MCP-Hackathon) |
|
[](https://www.gradio.app/guides/building-mcp-server-with-gradio) |
|
|
|
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. |
|
|
|
 |
|
|
|
## π 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 |
|
|
|
```bash |
|
# 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 |
|
|
|
```bash |
|
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 |
|
|
|
```bash |
|
# 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 |
|
|
|
```bash |
|
# 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](LICENSE) file for details. |