Skip to main content
Glama

add

Perform addition of two numbers using this tool, designed for basic mathematical operations within the Calculator MCP server. Input two numerical values to get the sum instantly.

Instructions

Add two numbers

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
aYes
bYes

Implementation Reference

  • The handler function that executes the 'add' tool logic: extracts numbers a and b from params, computes their sum, and returns a formatted text response.
    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 sum of ${a} and ${b} is ${result}` }] }; }, };
  • Defines the tool schema including name, description, and input schema (requiring numbers a and b) converted to JSON schema via Zod.
    schema: { name: "add", description: "Add two numbers", inputSchema: zodToJsonSchema(z.object({ a: z.number(), b: z.number() })), },
  • src/server.ts:7-9 (registration)
    Imports the 'add' tool (along with others) from './tools' and registers it in the 'tools' array, which is used by the MCP server's listTools and callTool handlers.
    import { add, div, mod, mul, sqrt, sub } from "./tools"; const tools = [add, div, mod, mul, sqrt, sub];

Other Tools

Related Tools

  • @kylekanouse/Test-MCP---DEMO-MCP-Dev-1
  • @githubpradeep/calc-mcp72
  • @zhangzhefang-github/mcp-add-server
  • @YuheiNakasaka/arithmetic-mcp-server
  • @mikefey/mcp-server
  • @wudongjie/example-mcp-server

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