Skip to main content
Glama
ishayoyo

Excel MCP Server

by ishayoyo

bulk_aggregate_multi_files

Aggregate data from the same column across multiple Excel or CSV files in parallel using operations like sum, average, count, min, or max. Process multiple files simultaneously to consolidate results or view per-file breakdowns.

Instructions

Aggregate same column across multiple files in parallel

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
filePathsYesArray of file paths to process
columnYesColumn name or index (0-based) to aggregate
operationYesAggregation operation
consolidateNoWhether to return consolidated result or per-file breakdown (default: true)
sheetNoSheet name for Excel files (optional)
filtersNoOptional filters to apply before aggregation

Implementation Reference

  • Core handler function implementing bulk aggregation across multiple files (CSV/Excel). Processes files in parallel batches, applies optional filters, performs sum/average/count/min/max operations per file, optionally consolidates results.
    async aggregateMultiFiles(args: BulkAggregateArgs): Promise<BulkResult> {
      const startTime = Date.now();
      const errors: string[] = [];
      const fileResults: BulkResult['fileResults'] = [];
    
      // Process files in batches to avoid overwhelming the system
      const batches = this.createBatches(args.filePaths, this.maxConcurrency);
    
      for (const batch of batches) {
        const batchPromises = batch.map(async (filePath) => {
          try {
            const data = await this.readFileContent(filePath, args.sheet);
    
            if (data.length <= 1) {
              throw new Error('No data rows found');
            }
    
            // Apply filters if specified
            let filteredData = data;
            if (args.filters && args.filters.length > 0) {
              filteredData = this.applyFilters(data, args.filters);
            }
    
            const result = await this.performAggregation(filteredData, args.column, args.operation);
    
            return {
              filePath,
              result: result.value,
              rowsProcessed: result.rowsProcessed,
              error: undefined
            };
          } catch (error) {
            const errorMsg = `${filePath}: ${error instanceof Error ? error.message : 'Unknown error'}`;
            errors.push(errorMsg);
    
            return {
              filePath,
              result: 0,
              rowsProcessed: 0,
              error: errorMsg
            };
          }
        });
    
        const batchResults = await Promise.all(batchPromises);
        fileResults.push(...batchResults);
      }
    
      // Calculate consolidated result if requested
      let consolidatedResult: number | undefined;
      const validResults = fileResults.filter(r => !r.error);
    
      if (args.consolidate && validResults.length > 0) {
        consolidatedResult = this.consolidateResults(validResults, args.operation);
      }
    
      const totalRowsProcessed = fileResults.reduce((sum, r) => sum + r.rowsProcessed, 0);
      const processingTimeMs = Date.now() - startTime;
    
      return {
        operation: args.operation,
        column: args.column,
        consolidatedResult,
        fileResults: args.consolidate ? undefined : fileResults,
        totalFilesProcessed: validResults.length,
        totalRowsProcessed,
        processingTimeMs,
        errors
      };
    }
  • Input schema defining parameters for bulk aggregation: list of file paths, target column, operation type, optional consolidation, sheet name, and filters.
    export interface BulkAggregateArgs {
      filePaths: string[];
      column: string;
      operation: 'sum' | 'average' | 'count' | 'min' | 'max';
      consolidate?: boolean;
      sheet?: string;
      filters?: BulkFilter[];
    }
  • Output schema for bulk aggregation results, including per-file results or consolidated value, processing stats, and errors.
    export interface BulkResult {
      operation: string;
      column: string;
      consolidatedResult?: number;
      fileResults?: Array<{
        filePath: string;
        result: number;
        rowsProcessed: number;
        error?: string;
      }>;
      totalFilesProcessed: number;
      totalRowsProcessed: number;
      processingTimeMs: number;
      errors: string[];
    }
  • Schema for individual filters used in bulk operations.
    export interface BulkFilter {
      column: string;
      condition: 'equals' | 'contains' | 'greater_than' | 'less_than' | 'not_equals';
      value: string | number;
    }
  • Main class containing the bulk operations engine with parallel processing, file reading for CSV/Excel, aggregation logic, filtering, and batching utilities.
    export class BulkOperations {
      private maxConcurrency = 10; // Limit concurrent file operations
    
      async aggregateMultiFiles(args: BulkAggregateArgs): Promise<BulkResult> {
        const startTime = Date.now();
        const errors: string[] = [];
        const fileResults: BulkResult['fileResults'] = [];
    
        // Process files in batches to avoid overwhelming the system
        const batches = this.createBatches(args.filePaths, this.maxConcurrency);
    
        for (const batch of batches) {
          const batchPromises = batch.map(async (filePath) => {
            try {
              const data = await this.readFileContent(filePath, args.sheet);
    
              if (data.length <= 1) {
                throw new Error('No data rows found');
              }
    
              // Apply filters if specified
              let filteredData = data;
              if (args.filters && args.filters.length > 0) {
                filteredData = this.applyFilters(data, args.filters);
              }
    
              const result = await this.performAggregation(filteredData, args.column, args.operation);
    
              return {
                filePath,
                result: result.value,
                rowsProcessed: result.rowsProcessed,
                error: undefined
              };
            } catch (error) {
              const errorMsg = `${filePath}: ${error instanceof Error ? error.message : 'Unknown error'}`;
              errors.push(errorMsg);
    
              return {
                filePath,
                result: 0,
                rowsProcessed: 0,
                error: errorMsg
              };
            }
          });
    
          const batchResults = await Promise.all(batchPromises);
          fileResults.push(...batchResults);
        }
    
        // Calculate consolidated result if requested
        let consolidatedResult: number | undefined;
        const validResults = fileResults.filter(r => !r.error);
    
        if (args.consolidate && validResults.length > 0) {
          consolidatedResult = this.consolidateResults(validResults, args.operation);
        }
    
        const totalRowsProcessed = fileResults.reduce((sum, r) => sum + r.rowsProcessed, 0);
        const processingTimeMs = Date.now() - startTime;
    
        return {
          operation: args.operation,
          column: args.column,
          consolidatedResult,
          fileResults: args.consolidate ? undefined : fileResults,
          totalFilesProcessed: validResults.length,
          totalRowsProcessed,
          processingTimeMs,
          errors
        };
      }
Behavior2/5

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

With no annotations provided, the description carries full burden but offers minimal behavioral insight. It mentions 'parallel' processing but doesn't disclose error handling, performance characteristics, memory usage, or output format. For a tool with 6 parameters and no output schema, this leaves significant gaps in understanding how the tool behaves.

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 directly states the tool's purpose without unnecessary words. It's appropriately sized and front-loaded with the core functionality, making it easy to parse quickly.

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 tool with 6 parameters, no annotations, and no output schema, the description is inadequate. It doesn't explain what the tool returns, how errors are handled, what file formats are supported, or the implications of the 'parallel' processing. The agent would struggle to use this tool effectively without trial and error.

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%, providing good parameter documentation. The description adds minimal value beyond the schema, only implying that aggregation happens 'across multiple files' which is already clear from the 'filePaths' parameter. No additional syntax, format, or constraint details are provided beyond what's in the schema.

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 verb ('aggregate') and resource ('same column across multiple files'), specifying the parallel processing aspect. It distinguishes from sibling 'aggregate' (which likely handles single files) by emphasizing multi-file processing, though it doesn't explicitly mention this distinction.

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

Usage Guidelines3/5

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

The description implies usage for multi-file column aggregation, suggesting when to use it over single-file tools. However, it lacks explicit guidance on when to choose this over sibling 'bulk_filter_multi_files' or other aggregation tools, and doesn't mention prerequisites like file format compatibility or performance considerations.

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