square_root
Calculate the square root of any positive number to find the value that, when multiplied by itself, equals the original number.
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
| Name | Required | Description | Default |
|---|---|---|---|
| number | Yes |
Input Schema (JSON Schema)
{
"properties": {
"number": {
"title": "Number",
"type": "number"
}
},
"required": [
"number"
],
"type": "object"
}
Implementation Reference
- server.py:106-122 (handler)The handler function for the 'square_root' tool, decorated with @mcp.tool() for automatic registration. It computes the square root using math.sqrt, with input validation for negative numbers.@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)