Skip to main content
Glama
avanishd-3

Math MCP Server

by avanishd-3

add

Adds a list of numbers with 64-bit floating point precision. Provide numbers as a list like [1, 2, 3] to calculate their sum.

Instructions

Adds a list of positive and/or negative numbers with 64 bit floating point precision and returns a 64 bit float. You need to provide them in the format of a list. For example, [1, 2, 3] would return 6.0. You can also use fractions if you want to, like [1/2, 1/3, 1/4].

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
numbersYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The handler function for the 'add' MCP tool. It sums the provided list of numbers using NumPy's sum with 64-bit float precision, rounds to the precision limit, logs the operation, and returns the result. Raises ValueError for empty lists.
    @math_mcp.tool
    def add(
        numbers: list[int | float],
    ) -> float:
        """Adds a list of positive and/or negative numbers with 64 bit floating point precision and returns a 64 bit float.
           You need to provide them in the format of a list. For example, [1, 2, 3] would return 6.0.
           You can also use fractions if you want to, like [1/2, 1/3, 1/4].
        """
    
        # This is technically allowed by Fast MCP, but it is an error here
        if not numbers:
            logging.error("Received an empty list for addition.")
            raise ValueError("""The list of numbers cannot be empty. Try wrapping the numbers in brackets, like [1, 2, 3], if this is not the case.
            """)
    
        # Use numpy for fast addition
        result = np.round(np.sum(numbers, dtype=np.float64), decimals=SIXTY_FOUR_BIT_FLOAT_DECIMAL_PLACES)
        logging.info(f"Adding numbers: {numbers} -> Result: {result}")
        return result
  • Schema definition via type annotations (input: list[int | float], output: float) and docstring describing usage and examples for the 'add' tool.
    def add(
        numbers: list[int | float],
    ) -> float:
        """Adds a list of positive and/or negative numbers with 64 bit floating point precision and returns a 64 bit float.
           You need to provide them in the format of a list. For example, [1, 2, 3] would return 6.0.
           You can also use fractions if you want to, like [1/2, 1/3, 1/4].
        """
  • Registration of the 'add' tool to the FastMCP server instance 'math_mcp' using the @tool decorator.
    @math_mcp.tool
Behavior3/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It does disclose key behavioral traits: the tool accepts both positive and negative numbers, uses 64-bit floating point precision, returns a 64-bit float, and accepts fractions. However, it doesn't mention error handling (e.g., what happens with non-numeric inputs), performance characteristics, or any limitations beyond the precision specification. The description doesn't contradict any annotations since none exist.

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 perfectly sized and front-loaded: the first sentence states the core functionality, and subsequent sentences provide essential examples and clarifications. Every sentence earns its place by adding value—none are redundant or unnecessary. The structure flows logically from general operation to specific examples.

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

Completeness4/5

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

Given the tool's low complexity (single parameter, no nested objects) and the presence of an output schema (which handles return value documentation), the description is mostly complete. It covers the purpose, usage, parameter semantics, and behavioral aspects adequately. However, it could be more complete by mentioning error cases or edge behaviors, which would be helpful despite the output schema's existence.

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

Parameters4/5

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

The schema description coverage is 0%, so the description must compensate. It adds substantial meaning beyond the bare schema: it explains that the 'numbers' parameter should be 'a list of positive and/or negative numbers,' provides format examples ('[1, 2, 3]'), mentions support for fractions, and clarifies the 64-bit floating point precision. While it doesn't explicitly document every aspect of the parameter (like the 'anyOf' schema detail), it provides enough practical guidance for effective use.

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 tool's purpose: 'Adds a list of positive and/or negative numbers with 64 bit floating point precision and returns a 64 bit float.' This specifies the exact verb ('adds'), resource ('list of numbers'), and distinguishes it from sibling tools like 'subtract' or 'multiply' by focusing on addition. The description goes beyond just restating the name by explaining the operation and data types involved.

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

Usage Guidelines4/5

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

The description provides clear context for when to use this tool: for adding numbers in a list format with 64-bit floating point precision. It gives examples like '[1, 2, 3]' and '[1/2, 1/3, 1/4]' to illustrate proper usage. However, it doesn't explicitly state when NOT to use it or mention alternatives (like using 'subtract' for subtraction operations), which prevents a perfect score.

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

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

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