Skip to main content
Glama

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
NameRequiredDescriptionDefault
aYesFirst number (minuend)
bYesSecond number (subtrahend)

Implementation Reference

  • 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}` } ] })
  • 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)") }
  • 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}` } ] }) );

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/kylekanouse/Test-MCP---DEMO-MCP-Dev-1'

If you have feedback or need assistance with the MCP directory API, please join our Discord server