add
Input two numbers to calculate their sum using this tool on MCP-Claude, simplifying mathematical operations with direct integration.
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-303 (handler)The handler function for the 'add' tool. It takes two numbers a and b, computes their sum, and returns a text response with the result.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)Input schema for the 'add' tool using Zod, 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)Registration of the 'add' tool with server.tool(), specifying name, description, input schema, and handler function.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}`, }, ], }; } );