Skip to main content
Glama
crazyrabbitLTC

Code Review MCP Server

analyze_repo

Analyze repository structure to understand code organization and file contents before detailed review, providing a high-level overview of the codebase.

Instructions

Use this tool when you need to analyze a code repository structure without performing a detailed review. This tool flattens the repository into a textual representation and is ideal for getting a high-level overview of code organization, directory structure, and file contents. Use it before code_review when you need to understand the codebase structure first, or when a full code review is not needed.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
repoPathYesPath to the repository to analyze
specificFilesNoSpecific files to analyze
fileTypesNoFile types to include in the analysis

Implementation Reference

  • The inline handler function for the 'analyze_repo' MCP tool. It constructs RepomixOptions from the input parameters (ignoring repoPath), calls executeRepomix to perform the repository flattening/analysis, and returns a text content response with the result.
    async (params) => {
      const options: RepomixOptions = {
        includePaths: params.specificFiles,
        fileTypes: params.fileTypes,
        outputFormat: 'plain'
      };
      
      const result = await executeRepomix(options);
      return { content: [{ type: 'text', text: `Analyzing repository: ${result}` }] };
  • Zod schema defining the input parameters for the 'analyze_repo' tool registration.
    const analyzeRepoParams = {
      repoPath: z.string().describe('Path to the repository to analyze'),
      specificFiles: z.array(z.string()).optional().describe('Specific files to analyze'),
      fileTypes: z.array(z.string()).optional().describe('File types to include in the analysis')
    };
  • src/index.ts:42-55 (registration)
    Registration of the 'analyze_repo' tool using McpServer.tool(), including description, input schema reference, and inline handler.
      'analyze_repo',
      'Use this tool when you need to analyze a code repository structure without performing a detailed review. This tool flattens the repository into a textual representation and is ideal for getting a high-level overview of code organization, directory structure, and file contents. Use it before code_review when you need to understand the codebase structure first, or when a full code review is not needed.',
      analyzeRepoParams,
      async (params) => {
        const options: RepomixOptions = {
          includePaths: params.specificFiles,
          fileTypes: params.fileTypes,
          outputFormat: 'plain'
        };
        
        const result = await executeRepomix(options);
        return { content: [{ type: 'text', text: `Analyzing repository: ${result}` }] };
      }
    );
  • Core helper function executeRepomix that runs the Repomix CLI command to flatten/analyze the repository structure into text output. Used by the analyze_repo handler. Includes test mocks and error handling.
    export async function executeRepomix(options: RepomixOptions = {}): Promise<string> {
      console.log('Analyzing repository at', options, 'with Repomix...');
      
      // In test environment or Bun test, return mock result
      if (process.env.NODE_ENV === 'test' || process.env.BUN_ENV === 'test') {
        console.log('Running in test mode, returning mock result');
        return 'Repomix analysis completed';
      }
      
      // The real implementation would call the Repomix CLI
      try {
        const execPromise = util.promisify(exec);
        const outputPath = path.join(process.cwd(), 'repomix-output.txt');
        
        let command = 'repomix';
        
        // Add style flag
        command += ' --style plain';
        
        // Add include paths
        if (options.includePaths && options.includePaths.length > 0) {
          const paths = options.includePaths.join(' ');
          command += ` ${paths}`;
        } else {
          command += ' .';
        }
        
        // Add output redirection
        command += ` && cat repomix-output.txt`;
        
        // Mock return in case running tests
        if (process.argv.includes('test')) {
          return 'Repomix analysis completed';
        }
        
        const { stdout } = await execPromise(command);
        return stdout || outputPath;
      } catch (error) {
        console.error('Error executing Repomix:', error);
        
        // Mock return in case of error during tests
        if (process.argv.includes('test')) {
          return 'Repomix analysis completed';
        }
        
        throw new Error(`Failed to execute Repomix: ${error}`);
      }
    }
  • TypeScript interface defining options for Repomix execution, used in the handler and helper.
    export interface RepomixOptions {
      includePaths?: string[];
      excludePaths?: string[];
      fileTypes?: string[];
      specificFiles?: string[];  // New option to specify exact files to process
      recentOnly?: boolean;
      outputFormat?: 'plain' | 'json';
      maxFiles?: number;
    }
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It explains the tool's behavior ('flattens the repository into a textual representation') and output format ('high-level overview'), which is helpful. However, it doesn't mention potential limitations like file size constraints, processing time, error conditions, or authentication requirements that would be important for a tool analyzing code repositories.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is efficiently structured with three sentences that each serve a distinct purpose: stating the tool's purpose, explaining its behavior, and providing usage guidelines. There's no redundant information, and the most important guidance (when to use the tool) is front-loaded. Every sentence earns its place by adding value.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's moderate complexity (3 parameters, no output schema, no annotations), the description provides good contextual coverage. It explains the tool's purpose, behavior, and relationship to the sibling tool. However, without annotations or output schema, it could benefit from more detail about what the 'textual representation' output actually contains and any limitations or requirements for using the tool effectively.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema already documents all three parameters thoroughly. The description doesn't add any parameter-specific information beyond what's in the schema. It mentions analyzing 'specific files' and 'file types' generally but provides no additional syntax, format, or usage guidance for these parameters. The baseline score of 3 is appropriate when the schema does the heavy lifting.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose: 'analyze a code repository structure without performing a detailed review' and 'flattens the repository into a textual representation'. It specifies the verb ('analyze'), resource ('code repository'), and scope ('high-level overview of code organization, directory structure, and file contents'), distinguishing it from the sibling tool 'code_review' which implies more detailed analysis.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides explicit guidance on when to use this tool: 'Use this tool when you need to analyze a code repository structure without performing a detailed review' and 'Use it before code_review when you need to understand the codebase structure first, or when a full code review is not needed'. It clearly differentiates from the alternative sibling tool 'code_review' and specifies both appropriate and inappropriate contexts.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other 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