sum
Add two numbers together to calculate their total. Input two numeric values to perform basic addition.
Instructions
Add two numbers together
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| a | Yes | First number | |
| b | Yes | Second number |
Implementation Reference
- src/index.ts:30-40 (handler)The handler function for the 'sum' tool that adds two numbers and returns a text response.async ({ a, b }: { a: number; b: number }) => { const result = a + b; return { content: [ { type: "text", text: `The sum of ${a} and ${b} is: ${result}` } ] }; }
- src/index.ts:27-29 (schema)Zod schema defining input parameters 'a' and 'b' as numbers for the 'sum' tool.a: z.number().describe("First number"), b: z.number().describe("Second number") },
- src/index.ts:23-41 (registration)Registration of the 'sum' tool on the MCP server with name, description, input schema, and handler function.server.tool( "sum", "Add two numbers together", { a: z.number().describe("First number"), b: z.number().describe("Second number") }, async ({ a, b }: { a: number; b: number }) => { const result = a + b; return { content: [ { type: "text", text: `The sum of ${a} and ${b} is: ${result}` } ] }; } );