calculate_sum
Add two numbers together to compute their total 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": "calculate_sum"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| a | Yes | ||
| b | Yes |
Implementation Reference
- src/index.ts:52-58 (handler)The handler logic for the 'calculate_sum' tool within the CallToolRequestSchema handler. It validates input arguments 'a' and 'b' as numbers and returns their sum as toolResult.
if (request.params.name === "calculate_sum") { const args = request.params.arguments as { a: number; b: number }; if (typeof args?.a !== 'number' || typeof args?.b !== 'number') { throw new McpError(ErrorCode.InvalidRequest, "Arguments 'a' and 'b' must be numbers"); } return { toolResult: args.a + args.b} ; } - src/index.ts:27-34 (schema)Input schema definition for the 'calculate_sum' tool, specifying an object with required number properties 'a' and 'b'.
inputSchema: { type: "object", properties: { a: { type: "number" }, b: { type: "number" } }, required: ["a", "b"] } - src/index.ts:25-35 (registration)Registration of the 'calculate_sum' tool in the ListToolsRequestSchema handler, including name, description, and input schema.
name: "calculate_sum", description: "Add two numbers together", inputSchema: { type: "object", properties: { a: { type: "number" }, b: { type: "number" } }, required: ["a", "b"] } },