divide
Perform division operations by calculating the quotient of two numbers. Use this tool to divide any number by another, with built-in error handling for cases like division by zero.
Instructions
Divide first number by second number
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| a | Yes | Dividend (number to be divided) | |
| b | Yes | Divisor (number to divide by) |
Implementation Reference
- src/index.ts:173-195 (handler)The handler for the 'divide' tool performs division of the first argument 'a' by the second 'b', handles division by zero error, and formats the response.case "divide": { const { a, b } = args as { a: number; b: number }; if (b === 0) { return { content: [ { type: "text", text: "Error: Division by zero is not allowed", }, ], isError: true, }; } const result = a / b; return { content: [ { type: "text", text: `${a} ÷ ${b} = ${result}`, }, ], }; }
- src/index.ts:74-91 (registration)Registration of the 'divide' tool in the list of available tools, including name, description, and input schema.{ name: "divide", description: "Divide first number by second number", inputSchema: { type: "object", properties: { a: { type: "number", description: "Dividend (number to be divided)", }, b: { type: "number", description: "Divisor (number to divide by)", }, }, required: ["a", "b"], }, },
- src/index.ts:77-90 (schema)Input schema definition for the 'divide' tool, specifying parameters 'a' (dividend) and 'b' (divisor).inputSchema: { type: "object", properties: { a: { type: "number", description: "Dividend (number to be divided)", }, b: { type: "number", description: "Divisor (number to divide by)", }, }, required: ["a", "b"], },