calculate_sum
Add two numbers efficiently using a TypeScript-based MCP server tool designed for experimentation and integration with Calude Desktop and Cursor IDE.
Instructions
Add two numbers together
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| a | Yes | ||
| b | Yes |
Implementation Reference
- src/index.ts:52-58 (handler)Handler that validates 'a' and 'b' are numbers and computes their sum as the tool result.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 defining required number properties 'a' and 'b' for the calculate_sum tool.inputSchema: { type: "object", properties: { a: { type: "number" }, b: { type: "number" } }, required: ["a", "b"] }
- src/index.ts:25-35 (registration)Tool registration in ListTools response, specifying 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"] } },