Skip to main content
Glama

compare

Analyze and compare data schemas between producers and consumers to identify mismatches, generating detailed reports for validation.

Instructions

Full analysis pipeline: extract producer schemas, trace consumer usage, and compare them to find mismatches. Returns a detailed report.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
producerDirYesPath to MCP server source directory
consumerDirYesPath to consumer/client source directory
formatNoOutput format
strictNoStrict mode for comparison
directionNoData flow direction (default: producer_to_consumer)

Implementation Reference

  • src/index.ts:178-192 (registration)
    MCP tool registration for 'compare', defining name, description, and input schema in the ListTools response.
    {
      name: 'compare',
      description: 'Full analysis pipeline: extract producer schemas, trace consumer usage, and compare them to find mismatches. Returns a detailed report.',
      inputSchema: {
        type: 'object',
        properties: {
          producerDir: { type: 'string', description: 'Path to MCP server source directory' },
          consumerDir: { type: 'string', description: 'Path to consumer/client source directory' },
          format: { type: 'string', enum: ['json', 'markdown', 'summary'], description: 'Output format' },
          strict: { type: 'boolean', description: 'Strict mode for comparison' },
          direction: { type: 'string', enum: ['producer_to_consumer', 'consumer_to_producer', 'bidirectional'], description: 'Data flow direction (default: producer_to_consumer)' },
        },
        required: ['producerDir', 'consumerDir'],
      },
    },
  • Zod schema (CompareInput) used for input validation in the 'compare' tool handler.
    const CompareInput = z.object({
      producerDir: z.string().describe('Path to MCP server source directory'),
      consumerDir: z.string().describe('Path to consumer/client source directory'),
      format: z.enum(['json', 'markdown', 'summary']).optional().describe('Output format (default: json)'),
      strict: z.boolean().optional().describe('Strict mode: treat missing optional properties as warnings'),
      direction: z.enum(['producer_to_consumer', 'consumer_to_producer', 'bidirectional']).optional().describe('Data flow direction for compatibility checking (default: producer_to_consumer)'),
    });
  • Handler for the 'compare' MCP tool: parses input, invokes compareDirectories, formats result, and returns MCP content response.
    case 'compare': {
      const input = CompareInput.parse(args);
      log(`Comparing: ${input.producerDir} vs ${input.consumerDir}`);
    
      const result = await compareDirectories(
        input.producerDir,
        input.consumerDir,
        {
          strict: input.strict,
          direction: input.direction
        }
      );
    
      const format = (input.format || 'json') as OutputFormat;
      const output = formatResult(result, format);
    
      log(`Analysis complete: ${result.summary.matchCount} matches, ${result.summary.mismatchCount} mismatches`);
    
      return {
        content: [
          {
            type: 'text',
            text: output,
          },
        ],
      };
    }
  • Core helper function compareDirectories: orchestrates schema extraction, usage tracing, and schema comparison.
    export async function compareDirectories(
      backendDir: string,
      frontendDir: string,
      options: CompareOptions = {}
    ): Promise<TraceResult> {
      // Import dynamically to avoid circular deps
      const { extractProducerSchemas } = await import('../extract/index.js');
      const { traceConsumerUsage } = await import('../trace/index.js');
      
      console.log(`\n[Compare] Backend: ${backendDir}`);
      console.log(`[Compare] Frontend: ${frontendDir}\n`);
      
      const producers = await extractProducerSchemas({ rootDir: backendDir });
      const consumers = await traceConsumerUsage({ rootDir: frontendDir });
      
      return compareSchemas(producers, consumers, options);
    }
Behavior2/5

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

With no annotations provided, the description carries full burden for behavioral disclosure. It mentions the tool 'returns a detailed report' but doesn't specify format details, performance characteristics, side effects, or error conditions. For a complex analysis tool with 5 parameters, this leaves significant gaps in understanding how it behaves beyond basic functionality.

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 efficiently structured in a single sentence that front-loads the core functionality. Every phrase ('full analysis pipeline', 'extract producer schemas', etc.) contributes to understanding the tool's purpose. However, it could be slightly more concise by removing 'full' or combining clauses more tightly.

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?

For a complex analysis tool with 5 parameters, no annotations, and no output schema, the description is insufficient. It doesn't explain what 'mismatches' means, what the 'detailed report' contains, or how the analysis pipeline works. The agent lacks critical context about output format, error handling, and behavioral constraints needed for effective tool 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?

Schema description coverage is 100%, so all parameters are documented in the schema. The description adds no additional parameter semantics beyond implying the comparison involves 'producer schemas' and 'consumer usage' (matching 'producerDir' and 'consumerDir'). It doesn't explain relationships between parameters or provide usage examples, meeting the baseline for high schema 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 tool performs a 'full analysis pipeline' with specific verbs (extract, trace, compare) and resources (producer schemas, consumer usage). It distinguishes itself from siblings like 'extract_schemas' or 'trace_usage' by combining these operations into a comparison workflow. However, it doesn't explicitly name the resource being compared (e.g., 'API contracts' or 'data schemas'), leaving some 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?

The description provides no guidance on when to use this tool versus alternatives like 'comment_contract' or 'trace_file'. It mentions the overall pipeline but doesn't specify prerequisites (e.g., requires initialized project), appropriate contexts, or exclusions. The agent must infer usage from the tool name and parameters alone.

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/Mnehmos/mnehmos.trace.mcp'

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