divide
Compute the quotient of two numbers a and b. Returns a divided by b.
Instructions
Divide a by 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_server/server.py:196-201 (handler)The divide function is registered as an MCP tool via the @mcp.tool() decorator. It takes two floats a and b, raises ValueError if b is zero (to prevent division by zero), and returns a divided by b.
@mcp.tool() def divide(a: float, b: float) -> float: """Divide a by b""" if b == 0: raise ValueError("Cannot divide by zero") return a / b - calculator_server/server.py:196-196 (registration)The @mcp.tool() decorator registers the divide function as an MCP tool on the FastMCP instance.
@mcp.tool()