add
Add two numbers together to calculate their sum. Use this tool to perform basic arithmetic addition operations.
Instructions
Add two numbers together
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"a": "<a>",
"b": "<b>"
},
"name": "add"
}
}Input 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) }], }; } );