Skip to main content
Glama
xiaoyuchenhot

MCP Multi-Tool Server

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
NameRequiredDescriptionDefault
numberYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • 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)

Tool Definition Quality

Score is being calculated. Check back soon.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/xiaoyuchenhot/MCP-example'

If you have feedback or need assistance with the MCP directory API, please join our Discord server