Skip to main content
Glama
4geru
by 4geru

add

Calculate the sum of two numbers using this arithmetic tool from the MCP LINE Server for mathematical operations.

Instructions

Add two numbers and return the result

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
aYesThe first number
bYesThe second number

Implementation Reference

  • Handler for the 'add' tool: validates arguments using Zod and returns the sum as text content.
    if (name === "add") { // zod でパラメータをバリデーション const argsSchema = z.object({ a: z.number(), b: z.number(), }); const { a, b } = argsSchema.parse(args); // 足し算を実行 const result = a + b; return { content: [ { type: "text", text: `${a} + ${b} = ${result}`, }, ], }; }
  • Input schema definition for the 'add' tool, declared in the list tools response.
    inputSchema: { type: "object", properties: { a: { type: "number", description: "The first number", }, b: { type: "number", description: "The second number", }, }, required: ["a", "b"], },
  • src/index.ts:23-46 (registration)
    Registration of the ListToolsRequestHandler which lists the 'add' tool with its schema.
    server.setRequestHandler(ListToolsRequestSchema, async () => { return { tools: [ { name: "add", description: "Add two numbers and return the result", inputSchema: { type: "object", properties: { a: { type: "number", description: "The first number", }, b: { type: "number", description: "The second number", }, }, required: ["a", "b"], }, }, ], }; });

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/4geru/mcp-handson'

If you have feedback or need assistance with the MCP directory API, please join our Discord server