add
Calculate the sum of two numbers using a straightforward, schema-defined API. Input values 'a' and 'b' to get the result. Designed for integration with AI assistants via the Example MCP Server.
Instructions
Add two numbers together
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| a | Yes | ||
| b | Yes |
Implementation Reference
- index.js:33-38 (handler)The handler function for the 'add' tool. It takes two numbers 'a' and 'b', computes their sum, and returns it as a text content block.async ({ a, b }) => { const sum = a + b; return { content: [{ type: "text", text: String(sum) }], }; }
- index.js:32-32 (schema)The input schema for the 'add' tool, defining parameters 'a' and 'b' as numbers using Zod.{ a: z.number(), b: z.number() },
- index.js:29-39 (registration)The registration of the 'add' tool on the MCP server using server.tool(), specifying name, description, input schema, and handler function.server.tool( "add", "Add two numbers together", { a: z.number(), b: z.number() }, async ({ a, b }) => { const sum = a + b; return { content: [{ type: "text", text: String(sum) }], }; } );