Skip to main content
Glama

add

Perform numerical addition by inputting two numbers to calculate their sum using this calculation tool from the Demo MCP Server.

Instructions

Add two numbers together

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
aYesFirst number
bYesSecond number

Implementation Reference

  • The handler function that takes two numbers a and b, computes their sum, and returns a text response with the result.
    async ({ a, b }) => ({ content: [ { type: "text", text: `${a} + ${b} = ${a + b}` } ] })
  • Input schema using Zod for validating two numeric parameters: a and b.
    inputSchema: { a: z.number().describe("First number"), b: z.number().describe("Second number") }
  • Registration of the 'add' tool using server.registerTool, specifying name, title, description, input schema, and handler function.
    server.registerTool( "add", { title: "Addition Tool", description: "Add two numbers together", inputSchema: { a: z.number().describe("First number"), b: z.number().describe("Second number") } }, 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