Python Code Review MCP Agent
Provides code review and security analysis specifically tailored for Django applications, including models, views, and Django-specific security best practices
Offers specialized code quality assessment for FastAPI applications, focusing on async patterns, data validation, and API security practices
Delivers comprehensive security auditing and code review for Flask applications, including route handlers, authentication patterns, and Flask-specific vulnerabilities
Provides comprehensive Python code analysis including PEP 8 compliance checking, security vulnerability detection, performance optimization suggestions, and code quality assessment
Performs security analysis and code quality review for SQLAlchemy code, focusing on query security, ORM patterns, and SQL injection prevention
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@Python Code Review MCP Agent review this Flask route for security issues and suggest improvements"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
Python Code Review MCP Agent ๐๐
A comprehensive Model Context Protocol (MCP) server designed specifically for backend developers working with Python. This agent provides detailed code quality and security analysis with consistent, actionable reporting.
๐ฏ Key Features
๐ Security-First Analysis
SQL Injection Detection - String formatting, concatenation, f-strings
Command Injection Prevention - os.system(), subprocess with shell=True
Code Injection Scanning - eval(), exec() usage detection
Secrets Detection - Hardcoded passwords, API keys, tokens
Crypto Security - Weak random number generation, SSL issues
๐ Code Quality Assessment
PEP 8 Compliance - Naming conventions, style guidelines
Exception Handling - Bare except, broad exceptions
Performance Patterns - Inefficient loops, list operations
Import Management - Wildcard imports, multiple imports
Code Complexity - Function length, maintainability
๐ Detailed Reporting
Executive Summaries - Risk assessment, deployment readiness
Quality Scorecards - 0-100 scoring for quality and security
Severity Levels - Critical, High, Medium, Low prioritization
Actionable Suggestions - Specific fix recommendations
Comparison Reports - Before/after improvement tracking
Related MCP server: MCP Vulnerability Checker Server
๐ ๏ธ Available MCP Tools
1. review_python_code
Comprehensive analysis with detailed, summary, or security-focused reports.
{
"code": "your_python_code_here",
"filename": "optional_filename.py",
"reportType": "detailed" // "detailed", "summary", or "security"
}2. security_audit
Focused security vulnerability scanning with threat analysis.
{
"code": "your_python_code_here",
"filename": "optional_filename.py"
}3. analyze_code_quality
Deep code quality analysis with configurable focus areas.
{
"code": "your_python_code_here",
"filename": "optional_filename.py",
"includeStyle": true,
"includeMaintainability": true
}4. compare_code_versions
Compare original vs. revised code to track improvements.
{
"originalCode": "original_version_here",
"revisedCode": "improved_version_here",
"filename": "optional_filename.py"
}5. get_improvement_suggestions
Get targeted suggestions for specific areas of concern.
{
"code": "your_python_code_here",
"filename": "optional_filename.py",
"focusArea": "security" // "security", "quality", "performance", "style", "all"
}๐ Quick Start
Installation
npm install
npm run buildRunning Tests
npm testStarting the MCP Server
npm startRunning Demo
node dist/demo.jsโ๏ธ MCP Client Configuration
Add to your MCP client configuration:
{
"mcpServers": {
"python-code-review": {
"command": "node",
"args": ["/path/to/python_code_review_mcp/dist/index.js"]
}
}
}๐ Usage Examples
Security Analysis
"Audit this Python Flask endpoint for security vulnerabilities"
@app.route('/user/<user_id>')
def get_user(user_id):
query = f"SELECT * FROM users WHERE id = {user_id}"
cursor.execute(query)
return cursor.fetchone()Result: Detects SQL injection vulnerability, provides secure parameterized query solution.
Code Quality Review
"Review this data processing function for quality issues"
def process_data(items):
result = []
for i in range(len(items)):
result += [items[i].upper()]
return resultResult: Identifies performance issues, suggests enumerate() and list comprehensions.
Improvement Tracking
"Compare my original code with the improved version"
Result: Shows quality score improvements, security enhancements, and resolved issues.
๐ฏ Perfect for Backend Developers
๐๏ธ Framework Support
Django - Models, views, security best practices
Flask - Route handlers, authentication, security
FastAPI - Async patterns, data validation
SQLAlchemy - Query security, ORM patterns
๐ง Development Workflow
Pre-commit Analysis - Catch issues before they reach production
Code Review Assistant - Comprehensive analysis for pull requests
Security Auditing - Regular vulnerability assessments
Refactoring Guide - Systematic improvement tracking
๐ Quality Metrics
Security Score (0-100) - Vulnerability risk assessment
Quality Score (0-100) - Code quality measurement
Issue Density - Problems per 100 lines of code
Risk Level - Overall deployment readiness
๐งช Comprehensive Testing
40/40 Tests Passing - 100% test coverage
Security Detection - All major vulnerability types
Quality Analysis - PEP 8, best practices, performance
Report Generation - Multiple formats and detail levels
Edge Cases - Empty code, comments, mixed indentation
Real-World Examples - Flask apps, Django models, data processing
๐ Detection Capabilities
๐จ Critical Security Issues
SQL injection vulnerabilities
Command injection risks
Code injection through eval/exec
Hardcoded secrets and credentials
โ ๏ธ High Priority Issues
SSL verification disabled
Subprocess with shell=True
Broad exception handling
๐ Quality Improvements
PEP 8 naming conventions
Performance anti-patterns
Import organization
Documentation completeness
๐ Scoring System
Security Score Calculation
100: No security vulnerabilities detected
70-99: Minor security concerns
30-69: Moderate security risks
0-29: Critical security vulnerabilities
Quality Score Calculation
90-100: Excellent code quality
80-89: Good code quality
70-79: Fair code quality
60-69: Poor code quality
0-59: Critical quality issues
๐ Production Ready
โ Zero Dependencies - No external APIs required
โ Fast Analysis - Local pattern matching
โ Consistent Reports - Standardized output format
โ TypeScript - Full type safety and IntelliSense
โ Error Handling - Graceful failure and recovery
โ MCP Standards - Compatible with all MCP clients
Transform your Python code review process with intelligent, automated analysis focused on the specific needs of backend developers! ๐โจ
Available Tools
5 toolsanalyze_code_qualityC
Deep code quality analysis including style, maintainability, performance, and best practices compliance.
Inputs: code (required), filename, includeStyle, includeMaintainability.
compare_code_versionsC
Compare two versions of Python code to identify improvements or regressions in quality and security.
Inputs: originalCode (required), revisedCode (required), filename.
get_improvement_suggestionsC
Get specific, actionable suggestions for improving Python code quality, security, and maintainability.
Inputs: code (required), filename, focusArea.
review_python_codeC
Comprehensive Python code analysis focusing on quality and security. Provides detailed reports with actionable recommendations.
Inputs: code (required), filename, reportType.
security_auditC
Focused security vulnerability analysis for Python code. Identifies SQL injection, command injection, and other security risks.
Inputs: code (required), filename.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelogโฆ
TDQS
Scored across 5 tools
Multiple tools have unclear boundaries and overlapping purposes. 'analyze_code_quality' and 'review_python_code' both describe comprehensive code analysis with quality and security focus, making them highly ambiguous. 'get_improvement_suggestions' also overlaps with these by providing actionable recommendations, while 'security_audit' is a subset of their security aspects. This will likely cause agent misselection.
The naming follows a consistent verb_noun pattern with snake_case throughout, such as 'analyze_code_quality' and 'compare_code_versions'. All tools start with a verb and describe their function clearly, with no mixing of conventions. The consistency aids in readability and predictability.
With 5 tools, the count is reasonable for a Python code review domain, allowing focused operations without being overwhelming. It aligns well with typical MCP server scopes of 3-15 tools, though the overlap in functionality might suggest some tools could be consolidated for better efficiency.
The tool set covers core aspects of code review like quality analysis, security, and suggestions, but there are notable gaps. For example, there is no tool for generating summaries, integrating with version control, or handling specific Python frameworks, which could limit agent workflows. The coverage is functional but not fully comprehensive for a code review agent.
Related MCP Connectors
Security + bug + perf + refactor audit for Python. Returns 0-10 score + MD report.
Security scanner for AI-written code: SAST, secrets, dependencies, IaC, containers and DAST.
Deep security scans of repos you own from your editor: dependency CVEs, SAST, git-history secrets.
Scan, monitor and fix a live web app from your editor: graded security reports with fix prompts.
Related MCP Servers
- AlicenseNot gradedqualityFmaintenanceProvides Trivy security scanning capabilities through a standardized interface, allowing users to scan projects for vulnerabilities and automatically fix them by updating dependencies.10MIT
- AlicenseAqualityDmaintenanceA Model Context Protocol server providing security vulnerability intelligence tools including CVE lookup, EPSS scoring, CVSS calculation, exploit detection, and Python package vulnerability checking.89MIT
- AlicenseBqualityDmaintenanceA multi-language code analysis server that helps LLMs or humans automatically lint, type-check, and improve code with minimal installation friction, currently supporting Python with plans for other languages.12MIT
- FlicenseNot gradedqualityDmaintenanceA continuous integration server that automates Python code analysis, providing linting and static type checking tools for quality assurance.-