code-reviewer-fixer-agent
by: gokborayilmaz
This AI agent analyzes code repositories, detects potential security vulnerabilities, reviews code quality, and suggests fixes based on Sentry error logs using Sentry and GitHub MCP servers!
📌Overview
Purpose: This framework aims to automate code review processes by identifying potential security vulnerabilities and code quality issues, and suggesting fixes based on error logs.
Overview: The AI Code Review & Issue Fixer is designed to analyze code repositories, leveraging tools such as Sentry and GitHub to enhance software quality and security. It fetches recent commits, evaluates code, and provides actionable insights for improvement.
Key Features:
-
Security Vulnerability Detection: Analyzes code to identify potential security risks, ensuring safer software deployments.
-
Code Quality Analysis: Reviews the overall quality of the code, highlighting areas for improvement to maintain high coding standards.
-
Error Log Integration: Utilizes Sentry error logs to suggest targeted fixes for issues, enhancing reliability and user experience.
-
Interactive API Documentation: Offers easy access to API functionalities through Swagger UI and ReDoc, facilitating developer integration.
21-Day Agent Series: Day 11
AGENT: AI Code Review & Issue Fixer
This AI agent analyzes code repositories, detects potential security vulnerabilities, reviews code quality, and suggests fixes based on Sentry error logs using Sentry and GitHub MCP servers.
Installation
Prerequisites
- Python 3.9 or higher
- Git
- Virtual environment (recommended)
- Node.js (required for MCP)
Steps
-
Clone the repository:
git clone <repository-url> cd <repository-folder>
-
Install dependencies:
pip install -r requirements.txt
-
Create a
.env
file in the root directory and configure it:AZURE_OPENAI_ENDPOINT="your_azure_openai_endpoint" AZURE_OPENAI_API_VERSION="your_azure_openai_api_version" AZURE_OPENAI_API_KEY="your_azure_openai_api_key" GITHUB_PERSONAL_ACCESS_TOKEN="YOUR_GITHUB_TOKEN" SENTRY_AUTH_TOKEN="YOUR_SENTRY_TOKEN"
Running the Application
Start the FastAPI server:
uvicorn upsonicai:app --reload
Open the UI in your browser at:
http://127.0.0.1:8000/
MCP Configuration
Modify your MCP configuration to include GitHub and Sentry servers:
"mcpServers": {
"github": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-github"],
"env": {
"GITHUB_PERSONAL_ACCESS_TOKEN": "YOUR_GITHUB_TOKEN"
}
},
"sentry": {
"command": "python",
"args": ["-m", "mcp_server_sentry", "--auth-token", "YOUR_SENTRY_TOKEN"]
}
}
How It Works
- Fetches recent commits from GitHub/GitLab repositories
- Analyzes code quality and detects security vulnerabilities
- Retrieves error logs from Sentry
- Provides actionable insights and fixes for detected issues
API Documentation
Interactive API docs are available at:
- Swagger UI: http://127.0.0.1:8000/docs
- ReDoc: http://127.0.0.1:8000/redoc