Skip to main content
Glama
ishayoyo

Excel MCP Server

by ishayoyo

validate_data_consistency

Cross-validate data integrity across related Excel/CSV files by checking referential integrity, data completeness, and value ranges to ensure consistency.

Instructions

Cross-validate data integrity across related files

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
primaryFileYesPath to the primary data file to validate
referenceFilesYesArray of reference file paths for validation
validationRulesNoSpecific validation rules to apply (optional, defaults to all)
keyColumnsNoSpecific columns to validate for referential integrity (optional)
autoDetectRelationshipsNoAutomatically detect column relationships (default: true)
toleranceNoTolerance for numeric validations (default: 0.01)
sheetNoSheet name for Excel files (optional)
reportFormatNoFormat of validation report (default: detailed)

Implementation Reference

  • Core handler function implementing data consistency validation using referential integrity, data completeness, and value range rules. Orchestrates context building, indexing, rule execution, reporting, and recommendations.
    async validateDataConsistency(
      primaryFilePath: string,
      referenceFilePaths: string[],
      options: {
        validationRules?: string[];
        keyColumns?: string[];
        sheet?: string;
        autoDetectRelationships?: boolean;
        tolerance?: number;
      } = {}
    ): Promise<ValidationResult> {
      const startTime = Date.now();
    
      try {
        // Build validation context
        const context = await this.contextBuilder.buildContext(
          primaryFilePath,
          referenceFilePaths,
          options.sheet
        );
    
        // Build performance indexes
        const indexes = await this.indexer.buildIndexes(context);
        context.indexes = indexes;
    
        // Determine which rules to run
        const rulesToRun = options.validationRules || this.config.rules || [
          'referential_integrity',
          'data_completeness',
          'value_ranges'
        ];
    
        // Configure rules based on options
        if (options.keyColumns) {
          const refIntegrityRule = this.rules.get('referential_integrity') as ReferentialIntegrityRule;
          if (refIntegrityRule) {
            // Update rule configuration
            (refIntegrityRule as any).config.keyColumns = options.keyColumns;
            (refIntegrityRule as any).config.autoDetect = false;
          }
        }
    
        // Run validation rules
        const allIssues: ValidationIssue[] = [];
        const validationPromises: Promise<ValidationIssue[]>[] = [];
    
        for (const ruleName of rulesToRun) {
          const rule = this.rules.get(ruleName);
          if (rule) {
            validationPromises.push(rule.validate(context, indexes));
          }
        }
    
        // Execute validations (potentially in parallel)
        const results = await Promise.all(validationPromises);
        results.forEach(issues => allIssues.push(...issues));
    
        // Calculate summary
        const summary = this.calculateSummary(context, allIssues, startTime);
    
        // Generate recommendations
        const recommendations = this.generateRecommendations(allIssues, context);
    
        // Create final result
        const result: ValidationResult = {
          success: allIssues.filter(i => i.severity === 'critical').length === 0,
          summary,
          issues: allIssues,
          recommendations
        };
    
        // Generate report if requested
        if (this.config.reportFormat === 'detailed') {
          result.detailedReport = this.reporter.generateDetailedReport(result);
        } else {
          result.detailedReport = this.reporter.generateSummaryReport(result);
        }
    
        return result;
    
      } catch (error) {
        // Handle validation errors gracefully
        const summary: ValidationSummary = {
          totalFiles: referenceFilePaths.length + 1,
          totalRows: 0,
          totalIssues: 1,
          criticalIssues: 1,
          warningIssues: 0,
          infoIssues: 0,
          filesWithIssues: [primaryFilePath],
          validationTimeMs: Date.now() - startTime
        };
    
        return {
          success: false,
          summary,
          issues: [{
            rule: 'validation_engine',
            severity: 'critical',
            message: `Validation failed: ${error instanceof Error ? error.message : 'Unknown error'}`,
            location: { file: primaryFilePath, row: 1, column: 'N/A' },
            suggestion: 'Check file paths and formats. Ensure all files are accessible and valid.',
            affectedRows: [],
            metadata: { error: error instanceof Error ? error.message : String(error) }
          }],
          recommendations: [
            'Verify all file paths are correct and files exist',
            'Check file formats are supported (.csv, .xlsx, .xls)',
            'Ensure files are not corrupted or locked'
          ]
        };
      }
    }
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 but offers minimal information. It mentions 'cross-validate' which implies a read-only analysis operation, but doesn't specify whether this modifies files, requires specific permissions, has performance characteristics, or produces what kind of output. For a tool with 8 parameters and no output schema, this leaves significant behavioral gaps.

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 a single, efficient sentence that states the core purpose without unnecessary words. It's appropriately sized for a tool with comprehensive schema documentation and gets straight to the point. Every word earns its place in conveying the essential function.

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 validation tool with 8 parameters, no annotations, and no output schema, the description is insufficient. It doesn't explain what 'data integrity' means in practice, what formats the validation report takes, whether this is a read-only operation, or what happens when validation fails. The agent must rely entirely on the input schema for operational details.

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 parameter-specific information beyond what the schema provides. It doesn't explain relationships between parameters (e.g., how 'keyColumns' interacts with 'autoDetectRelationships') or provide examples. The baseline of 3 is appropriate when the schema does all the parameter documentation work.

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's purpose as 'cross-validate data integrity across related files' which specifies the verb (cross-validate) and resource (data integrity across files). It distinguishes itself from siblings like 'find_duplicates' or 'data_profile' by focusing on cross-file validation rather than single-file operations. However, it doesn't explicitly differentiate from tools like 'correlation_analysis' or 'statistical_analysis' which might also involve multi-file comparisons.

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. It doesn't mention prerequisites (e.g., file formats supported), when-not-to-use scenarios, or comparisons to sibling tools like 'data_cleaner' or 'find_duplicates' that might handle related data quality tasks. The agent must infer usage from the purpose statement 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/ishayoyo/excel-mcp'

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