addition
Calculate the sum of two numerical values by providing inputs a and b. Input values are validated against a defined schema for accurate results.
Instructions
Add two numbers
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| a | Yes | ||
| b | Yes |
Implementation Reference
- operations/example-operation.ts:5-7 (handler)Core handler function that performs the addition of two numbers a and b.export function exampleAddition(params: z.infer<typeof AdditionSchema>) { return params.a + params.b; }
- common/types.ts:4-7 (schema)Zod schema defining the input parameters for the addition tool: two numbers a and b.export const AdditionSchema = z.object({ a: z.number(), b: z.number(), });
- index.ts:39-43 (registration)Tool registration in the ListTools response, specifying name, description, and input schema.{ name: "addition", description: "Add two numbers", inputSchema: zodToJsonSchema(AdditionSchema), }
- index.ts:62-68 (handler)Dispatch handler in CallToolRequestHandler that parses arguments, calls the exampleAddition function, and formats the response.case "addition": { const args = AdditionSchema.parse(request.params.arguments); const result = operation.exampleAddition(args); return { content: [{ type: "text", text: result.toString() }], }; }