add
Calculate the sum of two numbers by providing both values as inputs to perform basic addition operations.
Instructions
Add two numbers together
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| a | Yes | First number | |
| b | Yes | Second number |
Implementation Reference
- src/index.ts:81-92 (handler)Executes the 'add' tool: extracts numbers a and b from arguments, computes their sum, and formats a response message with the 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:45-58 (schema)Defines the input schema for the 'add' tool, requiring two number properties: a and b.inputSchema: { type: 'object', properties: { a: { type: 'number', description: 'First number', }, b: { type: 'number', description: 'Second number', }, }, required: ['a', 'b'], },
- src/index.ts:42-59 (registration)Registers the 'add' tool in the ListTools response with its name, description, and input schema.{ name: 'add', description: 'Add two numbers together', inputSchema: { type: 'object', properties: { a: { type: 'number', description: 'First number', }, b: { type: 'number', description: 'Second number', }, }, required: ['a', 'b'], }, },
- src/app/tools.ts:24-34 (handler)Alternative or supporting implementation of the 'add' tool handler in the createTools factory function.add(args: { a: number; b: number }) { const result = args.a + args.b; return { content: [ { type: 'text', text: `${args.a} + ${args.b} = ${result}`, }, ], }; },
- src/app/tools.ts:5-6 (schema)TypeScript interface definition specifying the input and output types for the 'add' tool.add(args: { a: number; b: number }): { content: Array<{ type: 'text'; text: string }>;