Skip to main content
Glama

npv

Calculate Net Present Value (NPV) of cash flows by inputting cash flow values and discount rate to assess investment profitability.

Instructions

Calculate Net Present Value of cash flows

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
cashFlowsYes
rateYes

Implementation Reference

  • The inline handler function for the 'npv' tool that computes Net Present Value by reducing over cash flows, discounting each by (1 + rate)^t.
    async ({ cashFlows, rate }) => { return cashFlows.reduce((npv, cf, t) => npv + cf / Math.pow(1 + rate, t), 0); }
  • Tool configuration object defining the name, description, input schema (cashFlows: array of numbers, rate: number), and output schema (number).
    { name: 'npv', description: 'Calculate Net Present Value of cash flows', inputSchema: z.object({ cashFlows: z.array(z.number()), rate: z.number() // discount rate as decimal }), outputSchema: z.number(), },
  • index.js:238-252 (registration)
    Full registration of the 'npv' tool via ai.defineTool, including schema and inline handler implementation.
    ai.defineTool( { name: 'npv', description: 'Calculate Net Present Value of cash flows', inputSchema: z.object({ cashFlows: z.array(z.number()), rate: z.number() // discount rate as decimal }), outputSchema: z.number(), }, async ({ cashFlows, rate }) => { return cashFlows.reduce((npv, cf, t) => npv + cf / Math.pow(1 + rate, t), 0); } );

Other Tools

Related 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/nbiish/mcp-calc-tools'

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