Skip to main content
Glama
TheAlchemist6

CodeCompass MCP

review_code

Analyze GitHub repositories for security vulnerabilities, performance issues, and maintainability problems using AI insights and rule-based validation. Provides actionable recommendations with suggested fixes.

Instructions

🔍 Comprehensive code review combining AI insights with rule-based validation. Provides intelligent analysis, security scanning, and actionable recommendations.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
urlYesGitHub repository URL
file_pathsNoSpecific files to review (optional - reviews key files if not specified)
review_modeNoReview approach: AI-powered, rule-based, or combinedcombined
review_focusNoAreas to focus the review on
optionsNo

Implementation Reference

  • Main handler function that implements the review_code tool. Fetches repository files, prepares context, calls OpenAI service for code review, and formats the 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);
      }
    }
  • Tool schema definition including input validation schema for the review_code tool.
    {
      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:274-275 (registration)
    Registration of the review_code handler in the main tool dispatch switch statement.
    case 'review_code':
      result = await handleReviewCode(args);

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/TheAlchemist6/codecompass-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server