Skip to main content
Glama

compound_interest

Calculate compound interest by inputting principal, interest rate, time, and compounding frequency. Use this tool to determine investment growth or loan repayment amounts accurately.

Instructions

Calculate compound interest

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
compoundsNo
principalYes
rateYes
timeYes

Implementation Reference

  • The asynchronous handler function that calculates the compound interest based on principal, rate, time, and optional compounding frequency using the formula P*(1 + r/n)^(n*t).
    async ({ principal, rate, time, compounds = 12 }) => { return principal * Math.pow(1 + rate/compounds, compounds * time); }
  • Zod schemas defining the tool's input parameters (principal: number, rate: number as decimal, time: number in years, compounds: optional number) and output as a number.
    inputSchema: z.object({ principal: z.number(), rate: z.number(), // annual interest rate as decimal time: z.number(), // years compounds: z.number().optional() // times per year }), outputSchema: z.number(),
  • index.js:205-220 (registration)
    The tool registration via ai.defineTool method, specifying name, description, input/output schemas, and inline handler implementation.
    ai.defineTool( { name: 'compound_interest', description: 'Calculate compound interest', inputSchema: z.object({ principal: z.number(), rate: z.number(), // annual interest rate as decimal time: z.number(), // years compounds: z.number().optional() // times per year }), outputSchema: z.number(), }, async ({ principal, rate, time, compounds = 12 }) => { return principal * Math.pow(1 + rate/compounds, compounds * time); } );

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