sqrt
Calculate the square root of a number. Input a numeric value to get its square root.
Instructions
Square root of a number
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| a | Yes |
Implementation Reference
- src/tools/sqrt.ts:12-16 (handler)The handler function that executes the sqrt tool logic: extracts 'a' from params, computes Math.sqrt(a), and returns a text result.
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:6-10 (schema)Input/output schema for the sqrt tool, defining a single 'a' number parameter.
export const sqrt: Tool = { 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 from './tools' (which re-exports from './sqrt') and added to the tools array in server.ts, making it available via ListToolsRequestSchema and CallToolRequestSchema handlers.
import { add, div, mod, mul, sqrt, sub } from "./tools"; const tools = [add, div, mod, mul, sqrt, sub];