sqrt
Calculate the square root of a number using the sqrt tool in Calculator MCP, designed to perform precise mathematical operations for LLMs.
Instructions
Square root of a number
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| a | Yes |
Implementation Reference
- src/tools/sqrt.ts:6-17 (handler)Full implementation of the 'sqrt' tool, including schema definition and the handler function that computes Math.sqrt(a).export const sqrt: Tool = { schema: { name: "sqrt", description: "Square root of a number", inputSchema: zodToJsonSchema(z.object({ a: z.number() })), }, handle: async (params) => { const a = params.a as number; const result = Math.sqrt(a); return { content: [{ type: "text", text: `The square root of ${a} is ${result}` }] }; }, };
- src/tools/sqrt.ts:7-11 (schema)Input schema for the sqrt tool using Zod for validation (expects object with 'a' number).schema: { name: "sqrt", description: "Square root of a number", inputSchema: zodToJsonSchema(z.object({ a: z.number() })), },
- src/server.ts:7-9 (registration)The 'sqrt' tool is imported and registered in the main tools array used by the MCP server.import { add, div, mod, mul, sqrt, sub } from "./tools"; const tools = [add, div, mod, mul, sqrt, sub];
- src/tools/index.ts:5-5 (registration)Re-export of the sqrt tool from the tools index module.export * from "./sqrt";