Skip to main content
Glama
ishayoyo

Excel MCP Server

by ishayoyo

ratio_analysis

Calculate financial ratios from Excel/CSV data and compare them against industry benchmarks for performance evaluation.

Instructions

Perform comprehensive financial ratio analysis with industry benchmarks

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
filePathYesPath to the CSV or Excel file with financial statement data
sheetNoSheet name for Excel files (optional)

Implementation Reference

  • The core handler function for the 'ratio_analysis' tool. Reads financial data from a specified spreadsheet file and sheet, extracts key financial metrics, computes liquidity, leverage, profitability ratios, compares against industry benchmarks, generates interpretation, and returns structured JSON response.
    async ratioAnalysis(args: ToolArgs): Promise<ToolResponse> {
      const { filePath, sheet } = args;
    
      try {
        const data = await readFileContent(filePath, sheet);
    
        if (data.length < 2) {
          throw new Error('Insufficient data for ratio analysis');
        }
    
        // Extract financial data (assuming standard financial statement format)
        const headers = data[0];
        const values = data[1]; // Assuming single period
    
        const financials = {
          currentAssets: this.findValue(headers, values, ['current assets', 'currentAssets']),
          currentLiabilities: this.findValue(headers, values, ['current liabilities', 'currentLiabilities']),
          inventory: this.findValue(headers, values, ['inventory']),
          totalDebt: this.findValue(headers, values, ['total debt', 'totalDebt']),
          totalEquity: this.findValue(headers, values, ['total equity', 'totalEquity']),
          netIncome: this.findValue(headers, values, ['net income', 'netIncome']),
          totalAssets: this.findValue(headers, values, ['total assets', 'totalAssets']),
          grossProfit: this.findValue(headers, values, ['gross profit', 'grossProfit']),
          revenue: this.findValue(headers, values, ['revenue', 'sales']),
          operatingIncome: this.findValue(headers, values, ['operating income', 'operatingIncome'])
        };
    
        // Calculate ratios
        const ratios = {
          currentRatio: financials.currentAssets / financials.currentLiabilities,
          quickRatio: (financials.currentAssets - financials.inventory) / financials.currentLiabilities,
          debtToEquity: financials.totalDebt / financials.totalEquity,
          returnOnEquity: financials.netIncome / financials.totalEquity,
          returnOnAssets: financials.netIncome / financials.totalAssets,
          grossMargin: financials.grossProfit / financials.revenue,
          operatingMargin: financials.operatingIncome / financials.revenue
        };
    
        // Industry benchmarks
        const benchmarks = {
          currentRatio: { range: '1.2 - 2.0', status: this.evaluateBenchmark(ratios.currentRatio, 1.2, 2.0) },
          quickRatio: { range: '0.8 - 1.5', status: this.evaluateBenchmark(ratios.quickRatio, 0.8, 1.5) },
          debtToEquity: { range: '0.3 - 1.5', status: this.evaluateBenchmark(ratios.debtToEquity, 0.3, 1.5) }
        };
    
        return {
          content: [{
            type: 'text',
            text: JSON.stringify({
              success: true,
              analysis: 'Financial Ratio Analysis',
              ratios: Object.fromEntries(
                Object.entries(ratios).map(([key, value]) => [key, Math.round(value * 100) / 100])
              ),
              benchmarks,
              interpretation: this.generateRatioInterpretation(ratios, benchmarks)
            }, null, 2)
          }]
        };
    
      } catch (error) {
        return {
          content: [{
            type: 'text',
            text: JSON.stringify({
              success: false,
              error: error instanceof Error ? error.message : 'Unknown error',
              operation: 'ratio_analysis'
            }, null, 2)
          }]
        };
      }
    }
  • Helper method to locate and extract numeric values for financial metrics from spreadsheet headers using flexible name matching.
    private findValue(headers: string[], values: any[], possibleNames: string[]): number {
      for (const name of possibleNames) {
        const index = headers.findIndex(h => h.toLowerCase().includes(name.toLowerCase()));
        if (index !== -1) {
          return Number(values[index]) || 0;
        }
      }
      return 0;
    }
  • Helper method to assess whether a calculated ratio falls within, above, or below industry benchmark ranges.
    private evaluateBenchmark(value: number, min: number, max: number): string {
      if (value < min) return 'Below Industry Average';
      if (value > max) return 'Above Industry Average';
      return 'Within Industry Range';
    }
  • Helper method to generate a textual interpretation of the financial ratios and benchmarks, highlighting strengths and concerns.
    private generateRatioInterpretation(ratios: any, benchmarks: any): string {
      const concerns = [];
      const strengths = [];
    
      if (ratios.currentRatio < 1.2) concerns.push('Liquidity may be tight');
      if (ratios.debtToEquity > 1.5) concerns.push('High leverage');
      if (ratios.returnOnEquity > 0.15) strengths.push('Strong profitability');
    
      return `Analysis: ${strengths.concat(concerns).join(', ')}`;
    }
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' analysis and 'industry benchmarks', but doesn't specify what ratios are calculated, how benchmarks are applied, output format, or any limitations (e.g., data requirements, processing time). This is inadequate for a tool that likely performs complex financial computations.

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 with no wasted words. It front-loads the core purpose ('Perform comprehensive financial ratio analysis') and adds valuable context ('with industry benchmarks'), 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?

Given the complexity of financial ratio analysis, no annotations, and no output schema, the description is insufficient. It doesn't explain what ratios are computed, how benchmarks are sourced, or the return format, leaving significant gaps for an AI agent to use the tool effectively.

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 both parameters ('filePath' and 'sheet'). The description adds no additional parameter semantics beyond implying financial data is needed, which is already suggested by the tool's purpose. This meets the baseline for high schema coverage.

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 'Perform comprehensive financial ratio analysis with industry benchmarks', which includes a specific verb ('perform') and resource ('financial ratio analysis'). It distinguishes from many siblings like 'statistical_analysis' or 'trend_analysis' by specifying financial ratios, though it doesn't explicitly differentiate from 'dcf_analysis' or 'budget_variance_analysis' which are also financial tools.

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., financial data format), exclusions, or comparisons to siblings like 'dcf_analysis' or 'budget_variance_analysis', leaving the agent to infer usage context solely from the tool name and description.

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