add
Add two numbers together to calculate their sum. This arithmetic tool performs basic addition operations for mathematical calculations.
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
- src/index.ts:16-21 (handler)Handler function for the 'add' tool that computes a + b and returns the result as text content.
async ({ a, b }) => ({ content: [{ type: "text", text: `${a} と ${b} の足し算の結果: ${a + b}` }] }) - src/index.ts:15-15 (schema)Input schema for the 'add' tool: two numbers a and b using Zod.
{ a: z.number(), b: z.number() }, - src/index.ts:13-22 (registration)Registration of the 'add' tool on the McpServer instance.
server.tool( "add", { a: z.number(), b: z.number() }, async ({ a, b }) => ({ content: [{ type: "text", text: `${a} と ${b} の足し算の結果: ${a + b}` }] }) );