square
Calculate the square of any number to determine its value multiplied by itself, useful for mathematical computations and problem-solving.
Instructions
Calculate the square of a number
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| a | Yes |
Implementation Reference
- src/index.ts:84-91 (handler)The handler function for the 'square' tool that computes the square of the input number 'a' and returns a text response with the result.async ({ a }) => { const result = a * a; return { content: [ { type: "text", text: `The square of ${a} is ${result}` } ] }; }
- src/index.ts:82-82 (schema)Input schema for the 'square' tool, defining the parameter 'a' as a number using Zod validation.inputSchema: { a: z.number() },
- src/index.ts:77-92 (registration)Registration of the 'square' tool on the MCP server, including schema and handler function.server.registerTool( "square", { title: "Square tool", description: "Calculate the square of a number", inputSchema: { a: z.number() }, }, async ({ a }) => { const result = a * a; return { content: [ { type: "text", text: `The square of ${a} is ${result}` } ] }; } );