sum
Add two numbers to calculate their sum. Input two numerical values, and this tool will return the total result.
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:23-41 (registration)Registers the 'sum' tool with MCP server, including description, input schema using Zod, and inline 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}` } ] }; } );
- src/index.ts:26-29 (schema)Input schema for 'sum' tool: two numbers a and b.{ a: z.number().describe("First number"), b: z.number().describe("Second number") },
- src/index.ts:30-40 (handler)Handler function computes sum of a and b, returns text content with the result.async ({ a, b }: { a: number; b: number }) => { const result = a + b; return { content: [ { type: "text", text: `The sum of ${a} and ${b} is: ${result}` } ] }; }