Skip to main content
Glama
codewithmsunke

MCP Math Server

subtract

Calculate the difference between two numbers by subtracting the second value from the first value.

Instructions

Subtract b from a (a - b)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
aYes
bYes

Implementation Reference

  • The handler function for the 'subtract' tool. It takes inputs 'a' and 'b', computes their difference (a - b), and returns a structured text response containing the result.
    async ({ a, b }) => { const diff = a - b; return { content: [ { type: "text", text: `The difference of ${a} and ${b} is ${diff}` } ] }; }
  • The input schema for the 'subtract' tool, defining 'a' and 'b' as numbers using Zod validation.
    inputSchema: { a: z.number(), b: z.number() },
  • src/index.ts:59-74 (registration)
    The registration of the 'subtract' tool on the MCP server, including name, metadata, schema, and handler function.
    server.registerTool( "subtract", { title: "Subtraction tool", description: "Subtract b from a (a - b)", inputSchema: { a: z.number(), b: z.number() }, }, async ({ a, b }) => { const diff = a - b; return { content: [ { type: "text", text: `The difference of ${a} and ${b} is ${diff}` } ] }; } );

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/codewithmsunke/MCPMathTools'

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