Skip to main content
Glama
fongfai

Minimum Viable MCP Project

by fongfai

sum_numbers

Add two numbers to calculate their sum. This tool takes two numeric inputs and returns the total as structured output.

Instructions

Add two numbers and return structured output.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
aYesFirst number
bYesSecond number

Implementation Reference

  • The sum_numbers tool handler implementation. Takes two numbers (a and b), calculates (a + b) * 100, and returns structured output with the result and expression string.
    server.registerTool(
      "sum_numbers",
      {
        description: "Add two numbers and return structured output.",
        inputSchema: {
          a: z.number().describe("First number"),
          b: z.number().describe("Second number"),
        },
        outputSchema: {
          result: z.number(),
          expression: z.string(),
        },
      },
      async ({ a, b }) => {
        const result = (a + b ) * 100;
        const structuredContent = {
          result,
          expression: `${a} + ${b} = ${result}`,
        };
    
        return {
          content: [
            {
              type: "text",
              text: structuredContent.expression,
            },
          ],
          structuredContent,
        };
      }
    );
  • Input and output schema definition for sum_numbers tool. Input requires two numbers (a, b). Output defines result as number and expression as string.
    server.registerTool(
      "sum_numbers",
      {
        description: "Add two numbers and return structured output.",
        inputSchema: {
          a: z.number().describe("First number"),
          b: z.number().describe("Second number"),
        },
        outputSchema: {
          result: z.number(),
          expression: z.string(),
        },
      },
  • src/server.ts:40-70 (registration)
    Registration of sum_numbers tool with the MCP server using server.registerTool, including name, description, schemas, and handler function.
    server.registerTool(
      "sum_numbers",
      {
        description: "Add two numbers and return structured output.",
        inputSchema: {
          a: z.number().describe("First number"),
          b: z.number().describe("Second number"),
        },
        outputSchema: {
          result: z.number(),
          expression: z.string(),
        },
      },
      async ({ a, b }) => {
        const result = (a + b ) * 100;
        const structuredContent = {
          result,
          expression: `${a} + ${b} = ${result}`,
        };
    
        return {
          content: [
            {
              type: "text",
              text: structuredContent.expression,
            },
          ],
          structuredContent,
        };
      }
    );
Install Server

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/fongfai/mcp'

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