subtraction
Calculate the difference between two numbers by subtracting the second from the first. Use this tool to perform basic subtraction operations in mathematical calculations.
Instructions
Subtract the second number from the first number
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"a": "<a>",
"b": "<b>"
},
"name": "subtraction"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| a | Yes | First number (minuend) | |
| b | Yes | Second number (subtrahend) |
Implementation Reference
- src/index.ts:51-62 (handler)The handler function performs subtraction (a - b) and returns a formatted text response.
async ({ a, b }: { a: number; b: number }) => { const result = a - b; return { content: [ { type: "text", text: `The subtraction of ${b} from ${a} is: ${result}` } ] }; } ); - src/index.ts:47-50 (schema)Zod schema defining input parameters 'a' (minuend) and 'b' (subtrahend) as numbers.
{ a: z.number().describe("First number (minuend)"), b: z.number().describe("Second number (subtrahend)") }, - src/index.ts:44-62 (registration)Registration of the 'subtraction' tool with server.tool(), including name, description, input schema, and handler function.
server.tool( "subtraction", "Subtract the second number from the first number", { a: z.number().describe("First number (minuend)"), b: z.number().describe("Second number (subtrahend)") }, async ({ a, b }: { a: number; b: number }) => { const result = a - b; return { content: [ { type: "text", text: `The subtraction of ${b} from ${a} is: ${result}` } ] }; } );