Skip to main content
Glama
raymondsambur

Automation Script Generator MCP Server

analyze_repository_patterns

Analyze repository patterns, formats, and validation rules to identify existing features, steps, pages, and components for test automation.

Instructions

Read and analyze repository for existing patterns, formats, and validation rules

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
repo_pathYesPath to the repository to analyze
pattern_typesNoTypes of patterns to analyze (features, steps, pages, components)

Implementation Reference

  • index.js:152-171 (registration)
    Tool registration in the toolConfigs array, including name, description, and input schema. This is returned by ListToolsRequestSchema handler.
        name: 'analyze_repository_patterns',
        description: 'Read and analyze repository for existing patterns, formats, and validation rules',
        inputSchema: {
            type: 'object',
            properties: {
                repo_path: {
                    type: 'string',
                    description: 'Path to the repository to analyze',
                },
                pattern_types: {
                    type: 'array',
                    items: { type: 'string' },
                    description: 'Types of patterns to analyze (features, steps, pages, components)',
                    default: ['features', 'steps', 'pages', 'components'],
                },
            },
            required: ['repo_path'],
            additionalProperties: false,
        },
    },
  • Input schema definition for the analyze_repository_patterns tool, used for validation.
    inputSchema: {
        type: 'object',
        properties: {
            repo_path: {
                type: 'string',
                description: 'Path to the repository to analyze',
            },
            pattern_types: {
                type: 'array',
                items: { type: 'string' },
                description: 'Types of patterns to analyze (features, steps, pages, components)',
                default: ['features', 'steps', 'pages', 'components'],
            },
        },
        required: ['repo_path'],
        additionalProperties: false,
    },
  • Main execution handler for the tool. Analyzes the repository by scanning for patterns of specified types, utilities, and naming conventions, then returns a formatted JSON analysis.
    async analyzeRepositoryPatterns(args) {
        const { repo_path, pattern_types = ['features', 'steps', 'pages', 'components'] } = args;
    
        try {
            const analysis = {
                patterns: {},
                existing_functions: {},
                conventions: {},
                utils: {}
            };
    
            for (const patternType of pattern_types) {
                const patterns = await this.scanForPatterns(repo_path, patternType);
                analysis.patterns[patternType] = patterns;
            }
    
            // Scan for existing utility functions
            analysis.utils = await this.scanForUtils(repo_path);
    
            // Extract naming conventions
            analysis.conventions = await this.extractNamingConventions(repo_path);
    
            return {
                content: [
                    {
                        type: 'text',
                        text: `Repository analysis complete:\n\n${JSON.stringify(analysis, null, 2)}`,
                    },
                ],
            };
        } catch (error) {
            throw new Error(`Failed to analyze repository patterns: ${error.message}`);
        }
    }
  • Helper method called by the handler to scan files matching the pattern type and extract patterns from their contents.
    async scanForPatterns(repo_path, patternType) {
        const patterns = [];
    
        try {
            const files = await this.findFilesByPattern(repo_path, patternType);
    
            for (const file of files) {
                try {
                    const content = await fs.readFile(file, 'utf8');
                    const extractedPatterns = this.extractPatterns(content, patternType);
    
                    if (extractedPatterns && Object.keys(extractedPatterns).length > 0) {
                        patterns.push({
                            file: path.relative(repo_path, file),
                            patterns: extractedPatterns
                        });
                    }
                } catch (fileError) {
                    console.warn(`Could not read file ${file}: ${fileError.message}`);
                }
            }
        } catch (error) {
            console.warn(`Could not scan for ${patternType} patterns: ${error.message}`);
        }
    
        return patterns;
    }
  • Helper method that extracts specific patterns from file content based on the pattern type (features, steps, etc.).
    extractPatterns(content, patternType) {
        const patterns = {};
    
        try {
            switch (patternType) {
                case 'features':
                    patterns.features = this.extractFeaturePatterns(content);
                    break;
                case 'steps':
                    patterns.stepDefinitions = this.extractStepPatterns(content);
                    break;
                case 'pages':
                    patterns.pageObjects = this.extractPagePatterns(content);
                    break;
                case 'components':
                    patterns.dataComponents = this.extractDataPatterns(content);
                    break;
                case 'utils':
                    patterns.utilities = this.extractUtilityPatterns(content);
                    break;
                default:
                    patterns.general = this.extractGeneralPatterns(content);
            }
        } catch (error) {
            console.warn(`Error extracting patterns for ${patternType}: ${error.message}`);
        }
    
        return patterns;
    }
Behavior2/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 states the tool is for reading and analyzing, implying a read-only operation, but does not specify if it modifies files, requires specific permissions, handles errors, or provides output details, leaving significant gaps in understanding its behavior.

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

Conciseness4/5

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

The description is a single, efficient sentence that directly states the tool's purpose without unnecessary words. It is front-loaded with the core action, though it could be slightly more structured by separating key points for clarity.

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

Completeness2/5

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

Given the complexity of analyzing repository patterns with no annotations and no output schema, the description is incomplete. It fails to explain what the analysis entails, what output to expect, or how it interacts with sibling tools, making it inadequate for guiding effective use.

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?

The schema description coverage is 100%, so the input schema already documents both parameters ('repo_path' and 'pattern_types') with descriptions and defaults. The description adds no additional meaning beyond the schema, such as explaining what 'pattern_types' entail or how analysis is performed, meeting the baseline for high coverage.

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

Purpose4/5

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

The description clearly states the action ('Read and analyze') and resource ('repository') with specific targets ('existing patterns, formats, and validation rules'), making the purpose evident. However, it does not explicitly differentiate from sibling tools like 'review_and_enhance_code', which might also involve repository analysis, leaving room for ambiguity.

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

Usage Guidelines2/5

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

No guidance is provided on when to use this tool versus alternatives. The description lacks context on prerequisites, such as needing a valid repository path, and does not mention sibling tools like 'review_and_enhance_code' for comparison, leaving usage unclear.

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/raymondsambur/automation-script-generator'

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