add
Calculate the sum of two numbers using this arithmetic tool from the MCP LINE Server for mathematical operations.
Instructions
Add two numbers and return the result
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| a | Yes | The first number | |
| b | Yes | The second number |
Implementation Reference
- src/index.ts:52-72 (handler)Handler for the 'add' tool: validates arguments using Zod and returns the sum as text content.if (name === "add") { // zod でパラメータをバリデーション const argsSchema = z.object({ a: z.number(), b: z.number(), }); const { a, b } = argsSchema.parse(args); // 足し算を実行 const result = a + b; return { content: [ { type: "text", text: `${a} + ${b} = ${result}`, }, ], }; }
- src/index.ts:29-42 (schema)Input schema definition for the 'add' tool, declared in the list tools response.inputSchema: { type: "object", properties: { a: { type: "number", description: "The first number", }, b: { type: "number", description: "The second number", }, }, required: ["a", "b"], },
- src/index.ts:23-46 (registration)Registration of the ListToolsRequestHandler which lists the 'add' tool with its schema.server.setRequestHandler(ListToolsRequestSchema, async () => { return { tools: [ { name: "add", description: "Add two numbers and return the result", inputSchema: { type: "object", properties: { a: { type: "number", description: "The first number", }, b: { type: "number", description: "The second number", }, }, required: ["a", "b"], }, }, ], }; });