Skip to main content
Glama

sum

Add multiple numbers together with precision using Math-MCP's sum function. Ideal for quick and accurate numerical calculations in any workflow.

Instructions

Adds any number of numbers together

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
numbersYesArray of numbers to sum

Implementation Reference

  • Handler function for the "sum" tool. It takes an array of numbers, calls Arithmetic.sum to compute the sum, and returns the result as MCP text content.
    }, async ({ numbers }) => {
        const value = Arithmetic.sum(numbers)
        return {
            content: [{
                type: "text",
                text: `${value}`
            }]
        }
    })
  • Input schema for the "sum" tool using Zod: requires an array of at least one number.
    numbers: z.array(z.number()).min(1).describe("Array of numbers to sum")
  • src/index.ts:98-108 (registration)
    Registration of the "sum" tool on the MCP server, including description, schema, and handler.
    mathServer.tool("sum", "Adds any number of numbers together", {
        numbers: z.array(z.number()).min(1).describe("Array of numbers to sum")
    }, async ({ numbers }) => {
        const value = Arithmetic.sum(numbers)
        return {
            content: [{
                type: "text",
                text: `${value}`
            }]
        }
    })
  • Arithmetic.sum static method: computes the sum of an array of numbers using Array.reduce.
    static sum(numbers: number[]) {
        // Use reduce to accumulate the sum, starting with 0
        const sum = numbers.reduce((accumulator, currentValue) => accumulator + currentValue, 0);
        return sum
    }
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries full burden but only states the basic operation. It doesn't disclose behavioral traits like error handling (e.g., for non-numeric inputs), performance characteristics, or output format details, leaving significant gaps.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence with zero waste—it directly states the tool's purpose without unnecessary words. It's appropriately sized for a simple mathematical operation.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a simple tool with high schema coverage and no output schema, the description is minimally adequate but lacks context on usage scenarios or behavioral details. It meets basic needs but doesn't fully compensate for the absence of annotations.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema already fully documents the 'numbers' parameter. The description adds no additional meaning beyond implying the array can have 'any number' of elements, which aligns with but doesn't enhance the schema's documentation.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the specific action ('adds') and resource ('any number of numbers'), distinguishing it from siblings like 'multiply' or 'subtract'. It precisely defines the mathematical operation without ambiguity.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance is provided on when to use this tool versus alternatives like 'add' (which might handle only two numbers) or 'mean' (which calculates average). The description doesn't mention prerequisites, limitations, or comparative use cases.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Related Tools

  • @wrtnlabs/calculator-mcp
  • @zhangzhefang-github/mcp-add-server
  • @KrishnaPapana/mcpserverexample
  • @EthanHenrickson/math-mcp
  • @YuheiNakasaka/arithmetic-mcp-server
  • @hongsw/hello-mcp

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/EthanHenrickson/math-mcp'

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