Skip to main content
Glama
ishayoyo

Excel MCP Server

by ishayoyo

statistical_analysis

Perform statistical analysis on a column in Excel or CSV files to calculate descriptive statistics and identify patterns in your data.

Instructions

Perform comprehensive statistical analysis on a column

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
filePathYesPath to the CSV or Excel file
columnYesColumn name or index (0-based)
sheetNoSheet name for Excel files (optional)

Implementation Reference

  • Core handler function that reads file data, extracts numeric values from specified column, computes comprehensive statistics (mean, median, mode, std dev, quartiles, skewness, etc.), and returns formatted JSON response.
    async statisticalAnalysis(args: ToolArgs): Promise<ToolResponse> {
      const { filePath, column, sheet } = args;
      const data = await readFileContent(filePath, sheet);
    
      if (data.length <= 1) {
        throw new Error('File has no data rows');
      }
    
      const colIndex = isNaN(Number(column))
        ? data[0].indexOf(column)
        : Number(column);
    
      if (colIndex === -1 || colIndex >= (data[0]?.length || 0)) {
        throw new Error(`Column "${column}" not found`);
      }
    
      const values = [];
      for (let i = 1; i < data.length; i++) {
        const val = Number(data[i][colIndex]);
        if (!isNaN(val)) {
          values.push(val);
        }
      }
    
      if (values.length === 0) {
        throw new Error('No numeric values found in column');
      }
    
      // Calculate statistics
      const n = values.length;
      const sum = values.reduce((a, b) => a + b, 0);
      const mean = sum / n;
    
      // Sort for median and quartiles
      const sorted = [...values].sort((a, b) => a - b);
      const median = n % 2 === 0
        ? (sorted[n / 2 - 1] + sorted[n / 2]) / 2
        : sorted[Math.floor(n / 2)];
    
      // Mode calculation
      const frequency: Record<number, number> = {};
      values.forEach(val => frequency[val] = (frequency[val] || 0) + 1);
      const maxFreq = Math.max(...Object.values(frequency));
      const modes = Object.keys(frequency).filter(val => frequency[+val] === maxFreq).map(Number);
    
      // Variance and standard deviation
      const variance = values.reduce((acc, val) => acc + Math.pow(val - mean, 2), 0) / (n - 1);
      const stdDev = Math.sqrt(variance);
    
      // Quartiles
      const q1 = sorted[Math.floor(n * 0.25)];
      const q3 = sorted[Math.floor(n * 0.75)];
      const iqr = q3 - q1;
    
      // Skewness (simplified Pearson's method)
      const skewness = 3 * (mean - median) / stdDev;
    
      return {
        content: [
          {
            type: 'text',
            text: JSON.stringify({
              success: true,
              column: data[0][colIndex],
              statistics: {
                count: n,
                sum,
                mean: Math.round(mean * 10000) / 10000,
                median,
                mode: modes.length === 1 ? modes[0] : modes,
                min: Math.min(...values),
                max: Math.max(...values),
                range: Math.max(...values) - Math.min(...values),
                variance: Math.round(variance * 10000) / 10000,
                standardDeviation: Math.round(stdDev * 10000) / 10000,
                quartiles: {
                  q1,
                  q2: median,
                  q3,
                  iqr
                },
                skewness: Math.round(skewness * 10000) / 10000,
                coefficientOfVariation: Math.round((stdDev / mean) * 100 * 100) / 100
              }
            }, null, 2),
          },
        ],
      };
    }
  • Input schema definition for the statistical_analysis tool, specifying parameters filePath (required), column (required), and optional sheet.
    name: 'statistical_analysis',
    description: 'Perform comprehensive statistical analysis on a column',
    inputSchema: {
      type: 'object',
      properties: {
        filePath: {
          type: 'string',
          description: 'Path to the CSV or Excel file',
        },
        column: {
          type: 'string',
          description: 'Column name or index (0-based)',
        },
        sheet: {
          type: 'string',
          description: 'Sheet name for Excel files (optional)',
        },
      },
      required: ['filePath', 'column'],
    },
  • src/index.ts:1221-1228 (registration)
    Dispatch/registration in the main tool call handler switch statement, mapping 'statistical_analysis' tool calls to the analyticsHandler.statisticalAnalysis method.
    case 'statistical_analysis':
      return await this.analyticsHandler.statisticalAnalysis(toolArgs);
    case 'correlation_analysis':
      return await this.analyticsHandler.correlationAnalysis(toolArgs);
    case 'data_profile':
      return await this.analyticsHandler.dataProfile(toolArgs);
    case 'pivot_table':
      return await this.analyticsHandler.pivotTable(toolArgs);
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. It mentions 'comprehensive statistical analysis' but doesn't specify what analyses are performed, output format, error handling, or performance considerations. This leaves critical behavioral traits undefined for a tool with potential complexity.

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 function without unnecessary words. It's appropriately sized for its purpose, though it could be more front-loaded with key details given the lack of other guidance.

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 tool's potential complexity (statistical analysis), no annotations, no output schema, and many sibling tools, the description is incomplete. It fails to explain what 'comprehensive' means, output expectations, or how it differs from other analysis tools, leaving significant gaps for 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?

Schema description coverage is 100%, so the schema fully documents the three parameters (filePath, column, sheet). The description adds no additional meaning beyond the schema, such as examples or constraints, but the high coverage justifies a baseline score of 3.

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

Purpose3/5

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

The description states the tool 'perform[s] comprehensive statistical analysis on a column,' which provides a clear verb ('perform') and resource ('column'), but it's vague about what 'comprehensive statistical analysis' entails. It doesn't differentiate from siblings like 'data_profile,' 'correlation_analysis,' or 'trend_analysis,' leaving ambiguity in its specific purpose.

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. With many sibling tools for data analysis (e.g., 'correlation_analysis,' 'trend_analysis,' 'data_profile'), the description lacks context on its unique application, prerequisites, or exclusions, offering no help in tool selection.

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