Skip to main content
Glama

calculate_irr

Compute the internal rate of return for investment analysis by inputting cash flows including initial investment to evaluate profitability.

Instructions

Calculate Internal Rate of Return

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
cashFlowsYesCash flows including initial investment

Implementation Reference

  • The MCP tool handler function that delegates the IRR calculation to the Python FinancialCalculator.irr method via the Python bridge.
    handler: async (args: any): Promise<ToolResult> => { try { const result = await pythonBridge.callPythonFunction({ module: 'financial_calculations', function: 'FinancialCalculator.irr', args: [args.cashFlows] }); return result; } catch (error) { return { success: false, error: error instanceof Error ? error.message : String(error) }; }
  • Input schema for the calculate_irr tool, requiring an array of cash flows.
    inputSchema: { type: "object", properties: { cashFlows: { type: "array", items: { type: "number" }, description: "Cash flows including initial investment" } }, required: ["cashFlows"] },
  • Registration of the calculate_irr tool within the financialTools array, which is imported and spread into the main allTools list in src/index.ts.
    { name: "calculate_irr", description: "Calculate Internal Rate of Return", inputSchema: { type: "object", properties: { cashFlows: { type: "array", items: { type: "number" }, description: "Cash flows including initial investment" } }, required: ["cashFlows"] }, handler: async (args: any): Promise<ToolResult> => { try { const result = await pythonBridge.callPythonFunction({ module: 'financial_calculations', function: 'FinancialCalculator.irr', args: [args.cashFlows] }); return result; } catch (error) { return { success: false, error: error instanceof Error ? error.message : String(error) }; } } },
  • The core implementation of IRR calculation using numpy_financial.irr library function.
    @staticmethod def irr(cash_flows: List[float]) -> float: """Calculate Internal Rate of Return""" return float(npf.irr(cash_flows))

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/jeremycharlesgillespie/excel-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server