Skip to main content
Glama
avanishd-3

Math MCP Server

by avanishd-3

multiply

Multiply numbers in a list with 64-bit floating point precision. Provide numbers as a list like [1, 2, 3] or [1/2, 1/3, 1/4] to get the product.

Instructions

Multiplies 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 core implementation of the 'multiply' tool handler. It validates input, computes the product using NumPy's np.prod with float64 dtype, rounds to the precision of 64-bit floats, logs the operation, and returns the result.
    def multiply(
        numbers: list[int | float],
    ) -> float:
        """Multiplies 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 multiplication.")
            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 multiplication
        result = np.round(np.prod(numbers, dtype=np.float64), decimals=SIXTY_FOUR_BIT_FLOAT_DECIMAL_PLACES)
        logging.info(f"Multiplying numbers: {numbers} -> Result: {result}")
        return result
  • The FastMCP decorator that registers the multiply function as a tool named 'multiply'.
    @math_mcp.tool
  • Type annotations defining the input as a list of int or float, output as float, and docstring describing usage and behavior for schema generation.
        numbers: list[int | float],
    ) -> float:
        """Multiplies 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].
        """
Behavior3/5

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

No annotations are provided, so the description carries the full burden. It discloses key behavioral traits: it handles positive/negative numbers, uses 64-bit floating point precision, returns a 64-bit float, and accepts fractions. However, it lacks details on error handling (e.g., empty lists, non-numeric inputs) or performance aspects, which could be useful for an agent.

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 appropriately sized and front-loaded: the first sentence states the core functionality, followed by practical usage details. Every sentence earns its place by adding value—no redundant or vague information. It's efficient and well-structured for quick comprehension.

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, one parameter, and an output schema (which handles return values), the description is mostly complete. It covers purpose, usage, and parameter semantics adequately. However, it could benefit from mentioning edge cases or linking to sibling tools for more advanced operations, slightly reducing completeness.

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 input schema has 0% description coverage, so the description must compensate. It adds significant meaning beyond the schema: it explains that the parameter 'numbers' should be a list, provides format examples (e.g., [1, 2, 3]), and clarifies that fractions are allowed. This effectively documents the single parameter, though it could specify constraints like minimum list length.

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: multiplying a list of numbers with 64-bit floating point precision and returning a 64-bit float. It specifies the verb ('multiplies'), resource ('list of positive and/or negative numbers'), and distinguishes from siblings like 'add', 'divide', 'matrix_multiplication', and 'subtract' by focusing exclusively on multiplication.

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 multiplying numbers in a list format. It implies usage by specifying the input format and examples, but does not explicitly state when not to use it or name alternatives like 'matrix_multiplication' for matrix operations, leaving some room for improvement in sibling differentiation.

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