subtract
Calculate the difference between two numbers by subtracting the second from the first. Use this tool to perform basic arithmetic subtraction operations.
Instructions
Subtract two numbers
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| a | Yes | First number (minuend) | |
| b | Yes | Second number (subtrahend) |
Implementation Reference
- src/tools/calculator-tools.ts:47-54 (handler)Async handler function that performs the subtraction operation (a - b) and formats the result as text content for the MCP response.async ({ a, b }) => ({ content: [ { type: "text", text: `${a} - ${b} = ${a - b}` } ] })
- src/tools/calculator-tools.ts:42-45 (schema)Zod input schema defining the two numeric parameters: 'a' (minuend) and 'b' (subtrahend).inputSchema: { a: z.number().describe("First number (minuend)"), b: z.number().describe("Second number (subtrahend)") }
- src/tools/calculator-tools.ts:37-55 (registration)Registration of the 'subtract' tool using McpServer.registerTool, specifying name, metadata (title, description, schema), and handler function.server.registerTool( "subtract", { title: "Subtraction Tool", description: "Subtract two numbers", inputSchema: { a: z.number().describe("First number (minuend)"), b: z.number().describe("Second number (subtrahend)") } }, async ({ a, b }) => ({ content: [ { type: "text", text: `${a} - ${b} = ${a - b}` } ] }) );