Skip to main content
Glama

add

Add two numbers together using structured input. This arithmetic tool calculates the sum of provided numerical values.

Instructions

Add two numbers.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
aYesThe first number to add.
bYesThe second number to add.

Implementation Reference

  • The handler function for the 'add' tool that takes two numbers a and b, computes their sum, and returns it in both text and structured content.
    async ({ a, b }: { a: number; b: number }) => { const output = { result: a + b }; return { content: [{ type: "text", text: JSON.stringify(output) }], structuredContent: output, }; }
  • Schema definition for the 'add' tool, including title, description, input schema (a and b as numbers), and output schema (result as number).
    { title: "addition tool", description: "Add two numbers.", inputSchema: { a: z.number().describe("The first number to add."), b: z.number().describe("The second number to add."), }, outputSchema: { result: z.number() }, },
  • Registration of the 'add' tool using server.registerTool with name, schema, and handler.
    server.registerTool( "add", { title: "addition tool", description: "Add two numbers.", inputSchema: { a: z.number().describe("The first number to add."), b: z.number().describe("The second number to add."), }, outputSchema: { result: z.number() }, }, async ({ a, b }: { a: number; b: number }) => { const output = { result: a + b }; return { content: [{ type: "text", text: JSON.stringify(output) }], structuredContent: output, }; } );

Other 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/sadjad-chrono/mcp-learning'

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