Skip to main content
Glama

divide

Perform precise division of two numbers or fractions with 64-bit floating point accuracy using this arithmetic tool from the Math MCP Server. Input numbers to receive a calculated result.

Instructions

Divides two numbers with 64 bit floating point precision and returns a 64 bit float. For example, dividing 10 by 2 would return 5.0. You can also use fractions if you want to, like 1/2 for number_1 and 1/3 for number_2.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
number_1Yes
number_2Yes

Implementation Reference

  • The handler function for the 'divide' tool, registered via @math_mcp.tool decorator. It takes two numbers, checks for division by zero, computes the division using NumPy float64 precision, rounds the result, logs it, and returns the float result.
    @math_mcp.tool def divide( number_1: int | float, number_2: int | float, ) -> float: """Divides two numbers with 64 bit floating point precision and returns a 64 bit float. For example, dividing 10 by 2 would return 5.0. You can also use fractions if you want to, like 1/2 for number_1 and 1/3 for number_2. """ if number_2 == 0: logging.error("Division by zero error.") raise ValueError("Division by zero is not allowed.") result = np.round(np.float64(number_1) / np.float64(number_2), decimals=SIXTY_FOUR_BIT_FLOAT_DECIMAL_PLACES) logging.info(f"Doing division: {number_1} / {number_2} -> Result: {result}") return result
  • Input schema defined by function parameters (number_1 and number_2 as int|float) and return type float, along with descriptive docstring explaining usage and precision.
    def divide( number_1: int | float, number_2: int | float, ) -> float: """Divides two numbers with 64 bit floating point precision and returns a 64 bit float. For example, dividing 10 by 2 would return 5.0. You can also use fractions if you want to, like 1/2 for number_1 and 1/3 for number_2.
  • The @math_mcp.tool decorator registers the divide function as an MCP tool named 'divide' on the math_mcp FastMCP server instance.
    @math_mcp.tool

Other Tools

Related Tools

  • @githubpradeep/calc-mcp72
  • @wrtnlabs/calculator-mcp
  • @YuheiNakasaka/arithmetic-mcp-server
  • @githubpradeep/calc-mcp71
  • @riteshbangal/BuildMcpServer
  • @Joseph19820124/joseph_mcp_server

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