divide
Perform floating-point division calculations by entering a dividend and non-zero divisor to compute accurate quotients for mathematical problems.
Instructions
执行浮点数除法运算 Args: b: 除数(必须非零)
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| a | Yes | ||
| b | Yes |
Implementation Reference
- calculator.py:22-30 (handler)The handler function for the 'divide' tool, decorated with @mcp.tool() for registration. It performs floating-point division with a check for division by zero.@mcp.tool() def divide(a: float, b: float) -> float: """执行浮点数除法运算 Args: b: 除数(必须非零) """ if b == 0: raise ValueError("除数不能为零") return a / b
- calculator.py:22-22 (registration)Registration of the divide tool using the @mcp.tool() decorator.@mcp.tool()
- calculator.py:23-27 (schema)Input schema defined by type hints (a: float, b: float) and output float, with docstring describing parameters.def divide(a: float, b: float) -> float: """执行浮点数除法运算 Args: b: 除数(必须非零) """