div
Perform division of two numbers using the Calculator MCP server for accurate mathematical calculations in structured workflows.
Instructions
Divide two numbers
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| a | Yes | ||
| b | Yes |
Implementation Reference
- src/tools/div.ts:12-17 (handler)The execute function (handle) for the 'div' tool, which divides input numbers a and b and returns the result as text content.handle: async (params) => { const a = params.a as number; const b = params.b as number; const result = a / b; return { content: [{ type: "text", text: `The division of ${a} and ${b} is ${result}` }] }; },
- src/tools/div.ts:7-11 (schema)The schema definition for the 'div' tool, including name, description, and Zod-based input schema for parameters a and b.schema: { name: "div", description: "Divide two numbers", inputSchema: zodToJsonSchema(z.object({ a: z.number(), b: z.number() })), },
- src/server.ts:7-9 (registration)Import of the 'div' tool (via index) and registration in the tools array used by the MCP server for listing and calling tools.import { add, div, mod, mul, sqrt, sub } from "./tools"; const tools = [add, div, mod, mul, sqrt, sub];