subtraction
Calculate the difference between two numbers by subtracting the second number from the first. Use this tool for quick and accurate subtraction operations.
Instructions
Subtract the second number from the first number
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| a | Yes | First number (minuend) | |
| b | Yes | Second number (subtrahend) |
Implementation Reference
- src/index.ts:44-62 (registration)Registers the 'subtraction' MCP tool with description, Zod input schema for numbers a and b, and inline async handler that computes and returns the result as text content.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}` } ] }; } );
- src/index.ts:51-61 (handler)The handler function implementing the core logic: subtracts b from a and formats the result into an MCP 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-based input schema defining parameters 'a' (minuend) and 'b' (subtrahend) as numbers.{ a: z.number().describe("First number (minuend)"), b: z.number().describe("Second number (subtrahend)") },