Skip to main content
Glama

add

Perform precise addition of positive and negative numbers, including fractions, with 64-bit floating point accuracy using a list-based input format. Ideal for mathematical computations in AI systems.

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

Implementation Reference

  • The handler function for the 'add' tool, decorated with @math_mcp.tool for registration. It validates input, sums the list of numbers using numpy with 64-bit float precision, rounds to the precision limit, logs the operation, and returns the result.
    @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

Other Tools

Related Tools

  • @kelseyee/mcp_calculator
  • @avanishd-3/math-mcp
  • @GonTwVn/GonMCPtool
  • @parameshwaran1/mcpserverexample
  • @avanishd-3/math-mcp
  • @bahfahh/mcptest

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