divide
Calculate division results by inputting dividend and divisor values to perform mathematical operations.
Instructions
Divide two numbers
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| a | Yes | Dividend | |
| b | Yes | Divisor |
Implementation Reference
- src/tools/calculator-tools.ts:89-110 (handler)Handler function for the 'divide' tool that performs division of two numbers and handles division by zero error.async ({ a, b }) => { if (b === 0) { return { content: [ { type: "text", text: "Error: Division by zero is not allowed" } ], isError: true }; } return { content: [ { type: "text", text: `${a} ÷ ${b} = ${a / b}` } ] }; }
- src/tools/calculator-tools.ts:84-87 (schema)Input schema for the 'divide' tool defining 'a' as dividend and 'b' as divisor using Zod.inputSchema: { a: z.number().describe("Dividend"), b: z.number().describe("Divisor") }
- src/tools/calculator-tools.ts:80-111 (registration)Registration of the 'divide' tool on the MCP server, including title, description, schema, and handler."divide", { title: "Division Tool", description: "Divide two numbers", inputSchema: { a: z.number().describe("Dividend"), b: z.number().describe("Divisor") } }, async ({ a, b }) => { if (b === 0) { return { content: [ { type: "text", text: "Error: Division by zero is not allowed" } ], isError: true }; } return { content: [ { type: "text", text: `${a} ÷ ${b} = ${a / b}` } ] }; } );