add
Calculate the sum of two numbers using this basic mathematical operation tool. Input two numerical values to get their total.
Instructions
计算两个数字的和
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| a | Yes | 第一个数字 | |
| b | Yes | 第二个数字 |
Implementation Reference
- src/index.ts:123-134 (handler)The handler for the "add" tool that extracts arguments a and b, computes their sum, and returns a text response with the calculation result.case "add": { const { a, b } = args as { a: number; b: number }; const result = a + b; return { content: [ { type: "text", text: `${a} + ${b} = ${result}`, }, ], }; }
- src/index.ts:21-34 (schema)Defines the input schema for the "add" tool, specifying an object with required number properties 'a' and 'b'.inputSchema: { type: "object", properties: { a: { type: "number", description: "第一个数字", }, b: { type: "number", description: "第二个数字", }, }, required: ["a", "b"], },
- src/index.ts:18-35 (registration)Registers the "add" tool in the tools array, including name, description, and input schema, which is returned in response to ListTools requests.{ name: "add", description: "计算两个数字的和", inputSchema: { type: "object", properties: { a: { type: "number", description: "第一个数字", }, b: { type: "number", description: "第二个数字", }, }, required: ["a", "b"], }, },