add
Add two numbers together to calculate their sum. Use this tool to perform basic arithmetic addition operations.
Instructions
Add two numbers together
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| a | Yes | ||
| b | Yes |
Implementation Reference
- index.js:33-38 (handler)Handler function for the 'add' tool. It takes two numbers 'a' and 'b', computes their sum, and returns it as a text content block.async ({ a, b }) => { const sum = a + b; return { content: [{ type: "text", text: String(sum) }], }; }
- index.js:32-32 (schema)Input schema for the 'add' tool, defining parameters 'a' and 'b' as numbers using Zod.{ a: z.number(), b: z.number() },
- index.js:29-39 (registration)Registration of the 'add' tool using McpServer.tool(), including name, description, input schema, and handler function.server.tool( "add", "Add two numbers together", { a: z.number(), b: z.number() }, async ({ a, b }) => { const sum = a + b; return { content: [{ type: "text", text: String(sum) }], }; } );