add
Calculate the sum of two numbers using the tool from HelloWorld MCP Server. Input two numerical values (a and b) to receive their total.
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)Handler for the 'add' tool: destructures arguments a and b, computes their sum, and returns a textual response with the calculation.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:42-59 (registration)Tool registration in ListToolsRequestHandler, defining name, description, and input schema for 'add' tool.{ 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:5-7 (schema)TypeScript interface definition for the 'add' tool input and output (unused in current implementation).add(args: { a: number; b: number }): { content: Array<{ type: 'text'; text: string }>; };
- src/app/tools.ts:24-34 (handler)Alternative handler implementation for 'add' tool in createTools function (appears unused).add(args: { a: number; b: number }) { const result = args.a + args.b; return { content: [ { type: 'text', text: `${args.a} + ${args.b} = ${result}`, }, ], }; },