Skip to main content
Glama

sub

Perform subtraction of two numbers using the Calculator MCP server. Input two numerical values to retrieve the result of the subtraction operation.

Instructions

Subtract two numbers

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
aYes
bYes

Implementation Reference

  • Full tool definition including schema and handler function for the 'sub' tool. The handler subtracts two numbers and returns a text response.
    export const sub: Tool = { schema: { name: "sub", description: "Subtract two numbers", inputSchema: zodToJsonSchema(z.object({ a: z.number(), b: z.number() })), }, handle: async (params) => { const a = params.a as number; const b = params.b as number; const result = a - b; return { content: [{ type: "text", text: `The difference of ${a} and ${b} is ${result}` }] }; }, };
  • Schema definition for the 'sub' tool, including name, description, and Zod-based input schema for two numbers.
    schema: { name: "sub", description: "Subtract two numbers", inputSchema: zodToJsonSchema(z.object({ a: z.number(), b: z.number() })), },
  • src/server.ts:7-9 (registration)
    Import of the 'sub' tool and registration in the tools array used by the MCP server for listing and calling tools.
    import { add, div, mod, mul, sqrt, sub } from "./tools"; const tools = [add, div, mod, mul, sqrt, sub];
  • src/tools/index.ts:6-6 (registration)
    Re-export of the 'sub' tool from index.ts, facilitating barrel import in server.ts.
    export * from "./sub";

Other Tools

Related Tools

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/wrtnlabs/calculator-mcp'

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