add_integers
Calculate the sum of two integers by providing both numbers as input to get their total value.
Instructions
Adds two integers together
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| a | Yes | First integer | |
| b | Yes | Second integer |
Implementation Reference
- tools/addIntegers.ts:30-70 (handler)The handler function that implements the core logic of the add_integers tool: validates input arguments, adds two numbers, and returns the result or error.export async function handleAddIntegers( args: unknown ): Promise<CallToolResult> { if (!args || typeof args !== "object") { return { content: [ { type: "text", text: "Error: Arguments must be an object", }, ], isError: true, }; } const { a, b } = args as { a?: unknown; b?: unknown }; if (typeof a !== "number" || typeof b !== "number") { return { content: [ { type: "text", text: "Error: Both a and b must be numbers", }, ], isError: true, }; } const result = a + b; return { content: [ { type: "text", text: `Result: ${result}`, }, ], isError: false, }; }
- tools/addIntegers.ts:6-23 (schema)The tool definition object specifying the name, description, and input schema (parameters a and b as numbers).export const addIntegersToolDefinition: Tool = { name: "add_integers", description: "Adds two integers together", inputSchema: { type: "object", properties: { a: { type: "number", description: "First integer", }, b: { type: "number", description: "Second integer", }, }, required: ["a", "b"], }, };
- tools/index.ts:68-72 (registration)The registration of the add_integers tool in the central toolRegistry Map, linking its definition and handler."add_integers", { definition: addIntegersToolDefinition, handler: handleAddIntegers, },