divide
Perform division operations by calculating the quotient of two numbers. Use this arithmetic tool to divide numerical values with precision.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| a | Yes | ||
| b | Yes |
Implementation Reference
- src/index.ts:52-69 (handler)Handler function for the 'divide' tool. Performs division of a by b, returns result in Japanese text format. Handles division by zero error case.async ({ a, b }) => { if (b === 0) { return { content: [{ type: "text", text: "エラー: ゼロで割ることはできません" }], isError: true }; } return { content: [{ type: "text", text: `${a} と ${b} の割り算の結果: ${a / b}` }] }; }
- src/index.ts:51-51 (schema)Input schema for 'divide' tool: two numeric parameters 'a' and 'b' validated with Zod.{ a: z.number(), b: z.number() },
- src/index.ts:49-70 (registration)Registration of the 'divide' tool using McpServer.tool method, specifying name, schema, and handler.server.tool( "divide", { a: z.number(), b: z.number() }, async ({ a, b }) => { if (b === 0) { return { content: [{ type: "text", text: "エラー: ゼロで割ることはできません" }], isError: true }; } return { content: [{ type: "text", text: `${a} と ${b} の割り算の結果: ${a / b}` }] }; } );