add
Add two numbers together to calculate their sum. This tool performs basic arithmetic addition for numerical values.
Instructions
Add two numbers
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| a | Yes | First number | |
| b | Yes | Second number |
Implementation Reference
- src/index.ts:292-302 (handler)The handler function for the 'add' tool that computes the sum of two numbers and returns it as text content.async ({ a, b }) => { const sum = a + b; return { content: [ { type: "text", text: `The sum of ${a} and ${b} is ${sum}`, }, ], }; }
- src/index.ts:288-291 (schema)The input schema for the 'add' tool defining parameters 'a' and 'b' as numbers.{ a: z.number().describe("First number"), b: z.number().describe("Second number"), },
- src/index.ts:285-303 (registration)The registration of the 'add' tool using server.tool, including name, description, schema, and handler.server.tool( "add", "Add two numbers", { a: z.number().describe("First number"), b: z.number().describe("Second number"), }, async ({ a, b }) => { const sum = a + b; return { content: [ { type: "text", text: `The sum of ${a} and ${b} is ${sum}`, }, ], }; } );