Skip to main content
Glama

add

Calculate the sum of two numbers by inputting the values for 'a' and 'b'.

Instructions

Add two numbers together

Input Schema

NameRequiredDescriptionDefault
aYesFirst number to add
bYesSecond number to add

Input Schema (JSON Schema)

{ "properties": { "a": { "description": "First number to add", "type": "number" }, "b": { "description": "Second number to add", "type": "number" } }, "required": [ "a", "b" ], "type": "object" }

Implementation Reference

  • demo.ts:94-105 (handler)
    Handler logic for the 'add' tool: extracts arguments a and b, computes their sum, and returns a text response with the result.
    if (name === "add") { const { a, b } = args as { a: number; b: number }; const result = a + b; return { content: [ { type: "text", text: `The sum of ${a} and ${b} is ${result}`, }, ], }; }
  • demo.ts:25-42 (schema)
    Schema definition for the 'add' tool, including name, description, and input schema with required number parameters a and b. This is part of the tools list returned in response to list tools request.
    { name: "add", description: "Add two numbers together", inputSchema: { type: "object", properties: { a: { type: "number", description: "First number to add", }, b: { type: "number", description: "Second number to add", }, }, required: ["a", "b"], }, },
  • demo.ts:22-87 (registration)
    Registration of the list tools handler which includes the 'add' tool in the tools list.
    server.setRequestHandler(ListToolsRequestSchema, async () => { return { tools: [ { name: "add", description: "Add two numbers together", inputSchema: { type: "object", properties: { a: { type: "number", description: "First number to add", }, b: { type: "number", description: "Second number to add", }, }, required: ["a", "b"], }, }, { name: "greet", description: "Generate a personalized greeting", inputSchema: { type: "object", properties: { name: { type: "string", description: "Name of the person to greet", }, language: { type: "string", description: "Language for the greeting", enum: ["en", "zh", "es", "fr"], }, }, required: ["name"], }, }, { name: "calculate", description: "Perform basic mathematical operations", inputSchema: { type: "object", properties: { operation: { type: "string", description: "Mathematical operation to perform", enum: ["add", "subtract", "multiply", "divide"], }, x: { type: "number", description: "First operand", }, y: { type: "number", description: "Second operand", }, }, required: ["operation", "x", "y"], }, }, ], }; });

Other Tools

Related Tools

  • @minimind-org/mcp-server-typescript-template
  • @riteshbangal/BuildMcpServer
  • @liaotaodcx8/toolkittest
  • @Mtar786/mcpServer
  • @Joseph19820124/joseph_mcp_server
  • @bahfahh/mcptest

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/joeguo911/mcp-demo'

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