Skip to main content
Glama
xiaoyuchenhot

MCP Multi-Tool Server

calculate_percentage

Calculate what percentage one number is of another number. Enter the part and whole values to compute the percentage result.

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

TableJSON Schema
NameRequiredDescriptionDefault
partYes
wholeYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The handler function for the 'calculate_percentage' tool, which calculates the percentage that 'part' is of 'whole'. It includes input validation to prevent division by zero. Registered via the @mcp.tool() decorator.
    @mcp.tool()
    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
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries full burden and does well by disclosing key behavioral traits: it explains the return format ('percentage as a number'), provides an example ('e.g., 25.0 means 25%'), and documents error behavior ('Raises: ValueError: If whole is zero'). It doesn't mention performance characteristics like rate limits, but covers core functionality adequately.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is perfectly structured and concise: a clear purpose statement followed by well-organized sections for Args, Returns, and Raises. Every sentence earns its place, with no redundant information. The information is front-loaded with the core purpose first.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's simplicity, 2 parameters, no annotations, but with output schema (implied by 'Returns' section), the description is complete enough. It explains purpose, parameters, return values, and error conditions. The output schema existence means the description doesn't need to explain return format in detail, but it still provides helpful context.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters5/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The description adds significant meaning beyond the input schema, which has 0% description coverage. It clearly explains what 'part' and 'whole' represent ('The part (the number you want to find the percentage of)' and 'The whole (the total or reference number)'), which is essential for correct usage. This fully compensates for the schema's lack of descriptions.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose with specific verb ('calculate') and resource ('percentage'), distinguishing it from sibling arithmetic tools like add, subtract, multiply, and divide. It precisely defines what percentage calculation means: 'what percentage one number is of another number.'

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage through the parameter explanations ('part' and 'whole'), but doesn't explicitly state when to use this tool versus alternatives like 'divide' or other mathematical operations. No explicit guidance on when-not-to-use or named alternatives is provided.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

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