review_code
Analyze and improve GitHub code quality with AI and rule-based validation using CodeCompass MCP. Focus on security, performance, and maintainability to identify issues and receive actionable recommendations.
Instructions
🔍 Comprehensive code review combining AI insights with rule-based validation. Provides intelligent analysis, security scanning, and actionable recommendations.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| file_paths | No | Specific files to review (optional - reviews key files if not specified) | |
| options | No | ||
| review_focus | No | Areas to focus the review on | |
| review_mode | No | Review approach: AI-powered, rule-based, or combined | combined |
| url | Yes | GitHub repository URL |
Implementation Reference
- src/index.ts:789-861 (handler)The handleReviewCode function implements the core logic for the review_code tool. It fetches repository information and files from GitHub, prepares the code context, generates an AI-powered code review using the OpenAI service based on specified focus areas, constructs a structured result, and returns a formatted tool response.async function handleReviewCode(args: any) { try { const { url, file_paths, review_focus = ['security', 'performance', 'maintainability'], options = {} } = args; // Get repository info and code content const repoInfo = await githubService.getRepositoryInfo(url); let filesToReview: Record<string, string> = {}; if (file_paths && file_paths.length > 0) { // Get specific files for (const filePath of file_paths) { try { const content = await githubService.getFileContent(url, filePath); filesToReview[filePath] = content; } catch (error) { // Skip files that can't be fetched } } } else { // Use key files from repository filesToReview = repoInfo.keyFiles; } if (Object.keys(filesToReview).length === 0) { throw new Error('No files found to review'); } // Prepare code for AI review const codeContext = Object.entries(filesToReview) .map(([path, content]) => `--- ${path} ---\n${content}`) .join('\n\n'); const focusAreas = review_focus.join(', '); // Generate AI review with specified model const aiReviewResult = await openaiService.generateCodeReview( codeContext, repoInfo.language || 'javascript', review_focus, options.ai_model ); const result = { repository: { name: repoInfo.name, description: repoInfo.description, language: repoInfo.language, owner: repoInfo.owner, }, review: { files_reviewed: Object.keys(filesToReview), focus_areas: review_focus, ai_model_used: aiReviewResult.modelUsed, ai_model_requested: options.ai_model || 'auto', analysis: aiReviewResult.content, severity_threshold: options.severity_threshold || 'medium', timestamp: new Date().toISOString(), model_warning: aiReviewResult.warning, }, recommendations: { priority_fixes: [], suggestions: [], best_practices: [], }, }; const response = createResponse(result); return formatToolResponse(response); } catch (error) { const response = createResponse(null, error); return formatToolResponse(response); } }
- src/tools/consolidated.ts:332-400 (schema)The schema definition for the 'review_code' tool, specifying input parameters including GitHub URL, optional file paths, review mode, focus areas, and various options for customization.name: 'review_code', description: '🔍 Comprehensive code review combining AI insights with rule-based validation. Provides intelligent analysis, security scanning, and actionable recommendations.', inputSchema: { type: 'object', properties: { url: { type: 'string', description: 'GitHub repository URL', }, file_paths: { type: 'array', items: { type: 'string' }, description: 'Specific files to review (optional - reviews key files if not specified)', }, review_mode: { type: 'string', enum: ['ai', 'rules', 'combined'], description: 'Review approach: AI-powered, rule-based, or combined', default: 'combined', }, review_focus: { type: 'array', items: { type: 'string', enum: ['security', 'performance', 'maintainability', 'best-practices', 'bugs', 'accessibility'], }, description: 'Areas to focus the review on', default: ['security', 'performance', 'maintainability'], }, options: { type: 'object', properties: { ai_model: { type: 'string', description: 'AI model to use for analysis (OpenRouter models). Use "auto" for intelligent model selection', default: 'auto', }, severity_threshold: { type: 'string', enum: ['low', 'medium', 'high', 'critical'], description: 'Minimum severity level to report', default: 'medium', }, include_fixes: { type: 'boolean', description: 'Include suggested fixes', default: true, }, include_examples: { type: 'boolean', description: 'Include code examples in suggestions', default: true, }, language_specific: { type: 'boolean', description: 'Include language-specific best practices', default: true, }, framework_specific: { type: 'boolean', description: 'Include framework-specific checks', default: true, }, }, }, }, required: ['url'], }, },
- src/index.ts:273-281 (registration)The registration/dispatch logic in the main tool handling switch statement that maps the 'review_code' tool name to its handler function.// AI-Enhanced Tools (3 tools) case 'review_code': result = await handleReviewCode(args); break; case 'explain_code': result = await handleExplainCode(args); break; case 'suggest_improvements': result = await handleSuggestImprovements(args);