Skip to main content
Glama
ishayoyo

Excel MCP Server

by ishayoyo

parse_natural_language

Convert natural language queries into Excel formulas or commands to analyze spreadsheet data without manual formula writing.

Instructions

Convert natural language to Excel formula or command

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYesNatural language query (e.g., "sum all sales", "find duplicates", "average by category")
filePathNoPath to file for context (optional)
providerNoPreferred AI provider: anthropic, openai, deepseek, gemini, or local (optional)

Implementation Reference

  • The primary handler function for the 'parse_natural_language' tool. Processes input arguments, loads optional file context, invokes NLPProcessor for command parsing and formula building, and returns a structured ToolResponse with results.
    async parseNaturalLanguage(args: ToolArgs): Promise<ToolResponse> {
      const { query, filePath, provider } = args;
    
      try {
        // Get file context if provided
        let context = undefined;
        if (filePath) {
          try {
            const data = await readFileContent(filePath);
            context = {
              headers: data[0],
              rowCount: data.length,
              columnCount: data[0]?.length || 0,
              dataTypes: detectDataTypes(data),
              activeCell: 'A1',
              selectedRange: 'A1:A1'
            };
          } catch (error) {
            // File context is optional, continue without it
          }
        }
    
        // Parse the natural language query
        const result = await this.nlpProcessor.parseCommand(query, context, provider);
    
        // If it's a formula, also try to build the actual formula
        let formulaResult = undefined;
        if (result.type === 'formula') {
          try {
            formulaResult = await this.nlpProcessor.buildFormula(query, context, provider);
          } catch (formulaError) {
            // Formula building failed, continue with just the command
          }
        }
    
        return {
          content: [
            {
              type: 'text',
              text: JSON.stringify({
                query,
                result: result, // Keep the command result in 'result' field for consistency
                formula: formulaResult,
                success: true,
                provider: this.nlpProcessor.getActiveProvider()?.name || 'Local'
              }, null, 2),
            },
          ],
        };
      } catch (error) {
        return {
          content: [
            {
              type: 'text',
              text: JSON.stringify({
                query,
                error: error instanceof Error ? error.message : 'Unknown error',
                success: false
              }, null, 2),
            },
          ],
        };
      }
    }
  • Defines the tool schema including name, description, and inputSchema with properties query (required), filePath, and provider for the ListToolsRequest response.
      name: 'parse_natural_language',
      description: 'Convert natural language to Excel formula or command',
      inputSchema: {
        type: 'object',
        properties: {
          query: {
            type: 'string',
            description: 'Natural language query (e.g., "sum all sales", "find duplicates", "average by category")',
          },
          filePath: {
            type: 'string',
            description: 'Path to file for context (optional)',
          },
          provider: {
            type: 'string',
            description: 'Preferred AI provider: anthropic, openai, deepseek, gemini, or local (optional)',
            enum: ['anthropic', 'openai', 'deepseek', 'gemini', 'local'],
          },
        },
        required: ['query'],
      },
    },
  • src/index.ts:1260-1261 (registration)
    Registers the tool in the CallToolRequest handler by mapping the tool name to the AIOperationsHandler.parseNaturalLanguage method.
      return await this.aiOpsHandler.parseNaturalLanguage(toolArgs);
    case 'explain_formula':
  • Core helper method in NLPProcessor that parses natural language into structured NLPCommand using AI completion with context-aware prompts and fallback parsing.
    async parseCommand(text: string, context?: WorksheetContext, preferredProvider?: ProviderType): Promise<NLPCommand> {
      const prompt = this.buildCommandPrompt(text, context);
    
      try {
        const response = await this.aiManager.createCompletion([
          { role: 'user', content: prompt }
        ], {
          systemPrompt: this.getSystemPrompt(),
          maxTokens: 1000,
          temperature: 0,
          preferredProvider
        });
    
        return this.parseCommandResponse(response.content);
      } catch (error) {
        return this.fallbackParser(text);
      }
    }
Behavior2/5

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

No annotations are provided, so the description carries full burden for behavioral disclosure. While 'convert' implies a transformation operation, it doesn't specify whether this requires external API calls (given the provider parameter), what happens with the optional filePath context, rate limits, error conditions, or what the output format looks like (formula string, command object, etc.).

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.

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 complexity of natural language to formula conversion, no annotations, and no output schema, the description is inadequate. It doesn't explain what kind of output to expect (Excel formula syntax, command objects, error handling), nor does it address the implications of the provider parameter for AI service usage.

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 documentation for all three parameters. The description adds no additional parameter semantics beyond what's already in the schema, so it meets the baseline of 3 where the schema does the heavy lifting.

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 function as converting natural language to Excel formulas or commands, which is a specific verb+resource combination. However, it doesn't distinguish itself from sibling tools like 'evaluate_formula' or 'explain_formula' that also work with formulas, leaving some ambiguity about its unique role.

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. With many sibling tools for Excel operations (evaluate_formula, explain_formula, data_cleaner, etc.), there's no indication of whether this is for initial formula generation, debugging, or other specific contexts.

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