multiply
Calculate the product of two numbers using this mathematical operation tool from the MCP Math Server for arithmetic computations.
Instructions
Multiply two numbers a * b
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| a | Yes | ||
| b | Yes |
Implementation Reference
- src/index.ts:102-109 (handler)Handler function that multiplies two numbers 'a' and 'b', computes the product, and returns a text response with the result.async ({ a, b }) => { const product = a * b; return { content: [ { type: "text", text: `The product of ${a} and ${b} is ${product}` } ] }; }
- src/index.ts:97-101 (schema)Input schema definition using Zod for parameters 'a' and 'b' as numbers, along with title and description.{ title: "Multiplication tool", description: "Multiply two numbers a * b", inputSchema: { a: z.number(), b: z.number() }, },
- src/index.ts:95-110 (registration)Registration of the 'multiply' tool with the MCP server, including schema and inline handler.server.registerTool( "multiply", { title: "Multiplication tool", description: "Multiply two numbers a * b", inputSchema: { a: z.number(), b: z.number() }, }, async ({ a, b }) => { const product = a * b; return { content: [ { type: "text", text: `The product of ${a} and ${b} is ${product}` } ] }; } );