Skip to main content
Glama

code_review

Analyze codebases to identify quality, security, performance, and maintainability issues. Receive structured feedback with actionable recommendations to improve code and address potential problems.

Instructions

Use this tool when you need a comprehensive code review with specific feedback on code quality, security issues, performance problems, and maintainability concerns. This tool performs in-depth analysis on a repository or specific files and returns structured results including issues found, their severity, recommendations for fixes, and overall strengths of the codebase. Use it when you need actionable insights to improve code quality or when evaluating a codebase for potential problems.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
detailLevelNoLevel of detail for the code review
fileTypesNoFile types to include in the review
focusAreasNoAreas to focus on during the code review
repoPathYesPath to the repository to analyze
specificFilesNoSpecific files to review

Implementation Reference

  • The MCP tool handler function that executes the 'code_review' tool logic: validates params, runs repomix on repo, invokes CodeReviewService.reviewCodeFromRepomix, and formats LLM review results.
    async (params) => { try { // Execute Repomix to get the flattened codebase const repomixOptions: RepomixOptions = { includePaths: params.specificFiles || [params.repoPath], fileTypes: params.fileTypes, outputFormat: 'plain', }; const repomixOutput = await executeRepomix(repomixOptions); // Set up review options const reviewOptions: CodeReviewOptions = { detailLevel: params.detailLevel || 'detailed', focusAreas: params.focusAreas || ['security', 'performance', 'quality', 'maintainability'], }; // Create the code review service try { const codeReviewService = createCodeReviewService(); // Perform the code review const reviewResult = await codeReviewService.reviewCodeFromRepomix(repomixOutput, reviewOptions); // Format the response return { content: [ { type: 'text', text: JSON.stringify(reviewResult, null, 2) } ] }; } catch (error) { console.error('Error initializing code review service:', error); return { content: [ { type: 'text', text: `Error initializing code review service: ${(error as Error).message}. Make sure you have set the necessary environment variables (LLM_PROVIDER and the corresponding API key).` } ], isError: true }; } } catch (error) { console.error('Error in code review:', error); return { content: [ { type: 'text', text: `Error performing code review: ${(error as Error).message}` } ], isError: true }; } }
  • Zod schema defining input parameters for the 'code_review' tool.
    const codeReviewParams = { repoPath: z.string().describe('Path to the repository to analyze'), specificFiles: z.array(z.string()).optional().describe('Specific files to review'), fileTypes: z.array(z.string()).optional().describe('File types to include in the review'), detailLevel: z.enum(['basic', 'detailed']).optional().describe('Level of detail for the code review'), focusAreas: z.array(z.enum(['security', 'performance', 'quality', 'maintainability'])).optional().describe('Areas to focus on during the code review') };
  • src/index.ts:67-129 (registration)
    Registration of the 'code_review' MCP tool using server.tool(name, description, schema, handler).
    server.tool( 'code_review', 'Use this tool when you need a comprehensive code review with specific feedback on code quality, security issues, performance problems, and maintainability concerns. This tool performs in-depth analysis on a repository or specific files and returns structured results including issues found, their severity, recommendations for fixes, and overall strengths of the codebase. Use it when you need actionable insights to improve code quality or when evaluating a codebase for potential problems.', codeReviewParams, async (params) => { try { // Execute Repomix to get the flattened codebase const repomixOptions: RepomixOptions = { includePaths: params.specificFiles || [params.repoPath], fileTypes: params.fileTypes, outputFormat: 'plain', }; const repomixOutput = await executeRepomix(repomixOptions); // Set up review options const reviewOptions: CodeReviewOptions = { detailLevel: params.detailLevel || 'detailed', focusAreas: params.focusAreas || ['security', 'performance', 'quality', 'maintainability'], }; // Create the code review service try { const codeReviewService = createCodeReviewService(); // Perform the code review const reviewResult = await codeReviewService.reviewCodeFromRepomix(repomixOutput, reviewOptions); // Format the response return { content: [ { type: 'text', text: JSON.stringify(reviewResult, null, 2) } ] }; } catch (error) { console.error('Error initializing code review service:', error); return { content: [ { type: 'text', text: `Error initializing code review service: ${(error as Error).message}. Make sure you have set the necessary environment variables (LLM_PROVIDER and the corresponding API key).` } ], isError: true }; } } catch (error) { console.error('Error in code review:', error); return { content: [ { type: 'text', text: `Error performing code review: ${(error as Error).message}` } ], isError: true }; } } );
  • Core helper method in CodeReviewService that processes repomix output and delegates to private reviewCode method which builds prompt and calls LLM.
    async reviewCodeFromRepomix(repomixOutput: string, options: CodeReviewOptions): Promise<CodeReviewResult> { console.log('Processing Repomix output...'); const processedRepo = await this.codeProcessor.processRepomixOutput(repomixOutput); console.log(`Processed Repomix output (${processedRepo.length} characters)`); return this.reviewCode(processedRepo, options); }

Other Tools

Related Tools

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/crazyrabbitLTC/mcp-code-review-server'

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