Skip to main content
Glama
ishayoyo

Excel MCP Server

by ishayoyo

data_cleaner

Clean and standardize Excel/CSV data by removing whitespace, fixing dates, standardizing formats, and eliminating empty rows to improve data quality.

Instructions

Batch data cleaning operations with intelligent detection of common data quality issues

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
filePathYesPath to the CSV or Excel file
operationsNoArray of cleaning operations to apply
previewNoShow preview before applying changes (default: false)
sheetNoSheet name for Excel files (optional)

Implementation Reference

  • src/index.ts:1271-1272 (registration)
    Registration of the data_cleaner tool in the main CallToolRequestHandler switch statement, dispatching to ExcelWorkflowHandler.cleanData method.
    case 'data_cleaner':
      return await this.excelWorkflowHandler.cleanData(toolArgs);
  • Input schema for the data_cleaner tool, defining required filePath and optional operations array (with enum of cleaning types), preview flag, and sheet.
      name: 'data_cleaner',
      description: 'Batch data cleaning operations with intelligent detection of common data quality issues',
      inputSchema: {
        type: 'object',
        properties: {
          filePath: {
            type: 'string',
            description: 'Path to the CSV or Excel file'
          },
          operations: {
            type: 'array',
            items: {
              type: 'string',
              enum: [
                'trim_whitespace', 'fix_dates', 'standardize_numbers',
                'remove_empty_rows', 'standardize_phone_formats', 'standardize_names',
                'remove_special_chars', 'fix_currency'
              ]
            },
            description: 'Array of cleaning operations to apply'
          },
          preview: {
            type: 'boolean',
            description: 'Show preview before applying changes (default: false)'
          },
          sheet: {
            type: 'string',
            description: 'Sheet name for Excel files (optional)'
          }
        },
        required: ['filePath']
      }
    },
  • Core handler function for data_cleaner tool. Parses args, reads file, applies specified cleaning operations using private helper methods, tracks changes, and returns JSON summary with preview option and change log.
    async cleanData(args: ToolArgs): Promise<ToolResponse> {
      try {
        const { filePath, operations = [], preview = false, sheet } = args;
    
        if (!filePath) {
          return {
            content: [{
              type: 'text',
              text: JSON.stringify({
                success: false,
                error: 'Missing required parameter: filePath'
              }, null, 2)
            }]
          };
        }
    
        // Read the file
        const data = await readFileContent(filePath, sheet);
    
        if (data.length === 0) {
          return {
            content: [{
              type: 'text',
              text: JSON.stringify({
                success: false,
                error: 'File is empty or could not be read'
              }, null, 2)
            }]
          };
        }
    
        const headers = data[0];
        let workingData = data.map(row => [...row]); // Deep copy
        const changes: any[] = [];
    
        // Apply each cleaning operation
        for (const operation of operations) {
          switch (operation) {
            case 'trim_whitespace':
              workingData = this.trimWhitespace(workingData, changes);
              break;
            case 'remove_empty_rows':
              workingData = this.removeEmptyRows(workingData, changes);
              break;
            case 'standardize_phone_formats':
              workingData = this.standardizePhoneFormats(workingData, changes);
              break;
            case 'fix_dates':
              workingData = this.fixDates(workingData, changes);
              break;
            case 'standardize_names':
              workingData = this.standardizeNames(workingData, changes);
              break;
            case 'remove_special_chars':
              workingData = this.removeSpecialChars(workingData, changes);
              break;
            case 'fix_currency':
              workingData = this.fixCurrency(workingData, changes);
              break;
          }
        }
    
        const result = {
          success: true,
          operation: 'data_cleaner',
          preview,
          summary: {
            originalRows: data.length,
            cleanedRows: workingData.length,
            operationsApplied: operations,
            changesCount: changes.length
          },
          changes: changes.slice(0, 100), // Limit to first 100 changes for readability
          data: preview ? workingData.slice(0, 10) : undefined // Show first 10 rows in preview
        };
    
        return {
          content: [{
            type: 'text',
            text: JSON.stringify(result, null, 2)
          }]
        };
    
      } catch (error) {
        return {
          content: [{
            type: 'text',
            text: JSON.stringify({
              success: false,
              error: error instanceof Error ? error.message : 'Unknown error',
              operation: 'data_cleaner'
            }, null, 2)
          }]
        };
      }
    }
  • Helper method for 'trim_whitespace' operation: trims whitespace from string cells and logs changes.
    private trimWhitespace(data: any[][], changes: any[]): any[][] {
      return data.map((row, rowIndex) =>
        row.map((cell, colIndex) => {
          if (typeof cell === 'string') {
            const trimmed = cell.trim();
            if (trimmed !== cell) {
              changes.push({
                operation: 'trim_whitespace',
                row: rowIndex,
                col: colIndex,
                before: cell,
                after: trimmed
              });
            }
            return trimmed;
          }
          return cell;
        })
      );
    }
  • Helper method for 'remove_empty_rows' operation: filters out completely empty rows (excluding header) and logs removals.
    private removeEmptyRows(data: any[][], changes: any[]): any[][] {
      const result = data.filter((row, index) => {
        const isEmpty = row.every(cell => !cell || String(cell).trim() === '');
        if (isEmpty && index > 0) { // Don't remove header
          changes.push({
            operation: 'remove_empty_rows',
            row: index,
            action: 'removed'
          });
          return false;
        }
        return true;
      });
      return result;
    }
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 'intelligent detection' but doesn't explain what this entails operationally—whether it modifies files in-place, creates backups, has performance characteristics, or requires specific permissions. For a batch processing tool with mutation implications, this is a significant gap.

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 immediately communicates the core functionality without unnecessary words. It's appropriately sized and front-loaded with the essential information.

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 data cleaning tool with 4 parameters, no annotations, and no output schema, the description is insufficient. It doesn't address critical behavioral aspects like whether changes are destructive, what formats are supported beyond CSV/Excel, error handling, or output expectations. The context signals indicate this is a moderately complex tool that needs more complete documentation.

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 already documents all four parameters thoroughly. The description adds no additional meaning about parameters beyond what's in the schema—it doesn't explain how operations interact, what 'intelligent detection' means for parameter selection, or provide usage examples.

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 'Batch data cleaning operations' with 'intelligent detection of common data quality issues', specifying both the verb (cleaning) and resource (data). However, it doesn't explicitly differentiate from siblings like 'validate_data_consistency' or 'find_duplicates' which might overlap in data quality domains.

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 siblings like 'validate_data_consistency', 'find_duplicates', and 'smart_data_analysis' that might handle similar data quality tasks, the description offers no context about appropriate use cases or exclusions.

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