factorial
Calculate the factorial of a number for mathematical operations within the Zerodha Trading Bot's automated trading system.
Instructions
This tool calculates the factorial of a number
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| a | Yes |
Implementation Reference
- index.js:40-46 (handler)The handler function computes the factorial of input 'a' using a simple loop multiplication.async ({ a }) => { let ans = 1; for (let i = 2; i <= a; i++) ans *= i; return { content: [{ type: "text", text: `${ans}` }], }; }
- index.js:39-39 (schema)Zod schema defining the input parameter 'a' as a number.{ a: z.number() },
- index.js:36-47 (registration)Registers the 'factorial' tool using McpServer.tool() with name, description, schema, and handler.server.tool( "factorial", "This tool calculates the factorial of a number", { a: z.number() }, async ({ a }) => { let ans = 1; for (let i = 2; i <= a; i++) ans *= i; return { content: [{ type: "text", text: `${ans}` }], }; } );