Skip to main content
Glama

add

Calculate the sum of two numbers using structured input parameters for precise arithmetic operations.

Instructions

Add two numbers.

Input Schema

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

Implementation Reference

  • Handler function for the 'add' tool that computes the sum of two numbers and returns it in both text and structured format.
    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, specifying title, description, input parameters 'a' and 'b' as numbers, and output '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 on the MCP server, including schema and handler function.
    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