divide
Perform floating-point division calculations by entering a dividend and non-zero divisor to compute accurate quotients for mathematical problems.
Instructions
执行浮点数除法运算 Args: b: 除数(必须非零)
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"a": "<a>",
"b": "<b>"
},
"name": "divide"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| a | Yes | ||
| b | Yes |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | 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: 除数(必须非零) """