Skip to main content
Glama

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; }

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