add
Calculate the sum of two numbers by providing both values as input parameters.
Instructions
Add two numbers together
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| a | Yes | First number | |
| b | Yes | Second number |
Implementation Reference
- src/tools/calculator-tools.ts:26-33 (handler)The handler function for the 'add' tool that adds two input numbers and returns the result as text content.async ({ a, b }) => ({ content: [ { type: "text", text: `${a} + ${b} = ${a + b}` } ] })
- src/tools/calculator-tools.ts:18-25 (schema)Input schema, title, and description for the 'add' tool using Zod validation.{ title: "Addition Tool", description: "Add two numbers together", inputSchema: { a: z.number().describe("First number"), b: z.number().describe("Second number") } },
- src/tools/calculator-tools.ts:16-34 (registration)Registration of the 'add' tool on the MCP server, including schema and inline handler function.server.registerTool( "add", { title: "Addition Tool", description: "Add two numbers together", inputSchema: { a: z.number().describe("First number"), b: z.number().describe("Second number") } }, async ({ a, b }) => ({ content: [ { type: "text", text: `${a} + ${b} = ${a + b}` } ] }) );