square_root
Calculate the square root of a number using this mathematical tool. Input a number to get its square root value, with error handling for negative inputs.
Instructions
Calculate the square root of a number.
Args:
number: The number to find the square root of
Returns:
The square root of the number
Raises:
ValueError: If number is negative
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| number | Yes |
Implementation Reference
- server.py:106-122 (handler)The handler function for the 'square_root' tool. It calculates the square root of a given number using math.sqrt, with error handling for negative inputs. The @mcp.tool() decorator registers it as an MCP tool, and the docstring provides the schema via Args/Returns/Raises.@mcp.tool() def square_root(number: float) -> float: """ Calculate the square root of a number. Args: number: The number to find the square root of Returns: The square root of the number Raises: ValueError: If number is negative """ if number < 0: raise ValueError("Cannot calculate square root of negative number") return math.sqrt(number)