Skip to main content
Glama

npv

Calculate Net Present Value of cash flows using a specified discount rate to evaluate investment profitability.

Instructions

Calculate Net Present Value of cash flows

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
cashFlowsYes
rateYes

Implementation Reference

  • index.js:238-252 (registration)
    Registration of the 'npv' tool using ai.defineTool, including schema and inline handler.
    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); } );
  • Handler function computes Net Present Value by reducing cash flows discounted by the given rate using the time index as the period.
    async ({ cashFlows, rate }) => { return cashFlows.reduce((npv, cf, t) => npv + cf / Math.pow(1 + rate, t), 0); }
  • Schema definition for 'npv' tool: input requires array of cashFlows and discount rate; output is a 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(), },

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