Addition Tool
addCalculate the sum of two numbers by providing both values as input parameters.
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 | First number | |
| b | Yes | Second number |
Implementation Reference
- src/tools/calculator-tools.ts:26-33 (handler)The handler function for the 'add' tool that adds two input numbers and returns the result as text content.
async ({ a, b }) => ({ content: [ { type: "text", text: `${a} + ${b} = ${a + b}` } ] }) - src/tools/calculator-tools.ts:18-25 (schema)Input schema, title, and description for the 'add' tool using Zod validation.
{ title: "Addition Tool", description: "Add two numbers together", inputSchema: { a: z.number().describe("First number"), b: z.number().describe("Second number") } }, - src/tools/calculator-tools.ts:16-34 (registration)Registration of the 'add' tool on the MCP server, including schema and inline handler function.
server.registerTool( "add", { title: "Addition Tool", description: "Add two numbers together", inputSchema: { a: z.number().describe("First number"), b: z.number().describe("Second number") } }, async ({ a, b }) => ({ content: [ { type: "text", text: `${a} + ${b} = ${a + b}` } ] }) );