Skip to main content
Glama
codewithmsunke

MCP Math Server

Addition tool

add

Calculate the sum of two numbers by providing values for a and b to perform basic addition operations.

Instructions

Add two numbers a + b

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
aYes
bYes

Implementation Reference

  • The handler function for the 'add' tool that adds two input numbers 'a' and 'b' and returns a text message with the result.
    async ({ a, b }) => {
      const sum = a + b;
      return {
        content: [
          { type: "text", text: `The sum of ${a} and ${b} is ${sum}` }
        ]
      };
    }
  • The tool configuration including input schema (using Zod for numbers a and b), title, and description.
    {
      title: "Addition tool",
      description: "Add two numbers a + b",
      inputSchema: { a: z.number(), b: z.number() },
    },
  • src/index.ts:14-29 (registration)
    Registers the 'add' tool on the MCP server with name, configuration (schema), and handler function.
    server.registerTool(
      "add",
      {
        title: "Addition tool",
        description: "Add two numbers a + b",
        inputSchema: { a: z.number(), b: z.number() },
      },
      async ({ a, b }) => {
        const sum = a + b;
        return {
          content: [
            { type: "text", text: `The sum of ${a} and ${b} is ${sum}` }
          ]
        };
      }
    );

Tool Definition Quality

Score is being calculated. Check back soon.

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/codewithmsunke/MCPMathTools'

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