Skip to main content
Glama

calculate_percentage

Calculate what percentage one number represents of another number. Enter the part and whole values to determine the percentage relationship between them.

Instructions

Calculate what percentage one number is of another number. Args: part: The part (the number you want to find the percentage of) whole: The whole (the total or reference number) Returns: The percentage as a number (e.g., 25.0 means 25%) Raises: ValueError: If whole is zero

Input Schema

NameRequiredDescriptionDefault
partYes
wholeYes

Input Schema (JSON Schema)

{ "properties": { "part": { "title": "Part", "type": "number" }, "whole": { "title": "Whole", "type": "number" } }, "required": [ "part", "whole" ], "type": "object" }

Implementation Reference

  • server.py:147-147 (registration)
    Registers the calculate_percentage function as an MCP tool using the @mcp.tool() decorator.
    @mcp.tool()
  • The handler function that implements the calculate_percentage tool logic, computing the percentage and raising an error for division by zero.
    def calculate_percentage(part: float, whole: float) -> float: """ Calculate what percentage one number is of another number. Args: part: The part (the number you want to find the percentage of) whole: The whole (the total or reference number) Returns: The percentage as a number (e.g., 25.0 means 25%) Raises: ValueError: If whole is zero """ if whole == 0: raise ValueError("Cannot calculate percentage when whole is zero") return (part / whole) * 100

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