Skip to main content
Glama
zazencodes

Unit Converter MCP

by zazencodes

convert_power

Convert power measurements between units like watts, horsepower, and kilowatts for engineering, physics, and energy calculations.

Instructions

Convert power between units.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
valueYesPower value to convert
from_unitYesSource unit
to_unitYesTarget unit

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • MCP tool handler for 'convert_power'. Registers the tool with FastMCP and wraps the core convert_power_tool function, formatting the response with original and converted values.
    @app.tool()
    def convert_power(
        value: Annotated[float, Field(description="Power value to convert")],
        from_unit: Annotated[POWER_UNIT, Field(description="Source unit")],
        to_unit: Annotated[POWER_UNIT, Field(description="Target unit")],
    ) -> dict:
        """Convert power between units."""
        converted_value = convert_power_tool(value, from_unit, to_unit)
        return {
            "original_value": value,
            "original_unit": from_unit,
            "converted_value": converted_value,
            "converted_unit": to_unit,
            "conversion_type": "power",
        }
  • Core implementation of power unit conversion. Converts any power unit to watts then to target unit using predefined conversion factors.
    def convert_power_tool(
        value: float,
        from_unit: POWER_UNIT,
        to_unit: POWER_UNIT,
    ) -> float:
        """Convert power between units."""
    
        # Convert to watts first
        to_watts = {
            # Anglo‑American & HVAC
            "Btu per hour": 0.2930711,
            "foot pound‑force per second": 1.35582,
            "ton of refrigeration": 3_516.853,
            # Nutrition / chemistry
            "calorie per hour": 0.001162222222,
            "kilocalorie per hour": 1.162222222222,
            # Mechanical power
            "horsepower": 745.69987158227,  # international / mechanical
            "horsepower (metric)": 735.4988,
            "kilogram‑force meter per second": 9.80665,
            # SI and metric multiples
            "watt": 1.0,
            "kilowatt": 1_000.0,
            "megawatt": 1_000_000.0,
            "gigawatt": 1_000_000_000.0,
            "terawatt": 1_000_000_000_000.0,
            "petawatt": 1_000_000_000_000_000.0,
        }
    
        watts = value * to_watts[from_unit]
        return watts / to_watts[to_unit]
  • Type definition (Literal) for all supported power units, used in tool signatures for input validation.
    POWER_UNIT = Literal[
        "Btu per hour",
        "foot pound‑force per second",
        "ton of refrigeration",
        "calorie per hour",
        "kilocalorie per hour",
        "horsepower",
        "horsepower (metric)",
        "kilogram‑force meter per second",
        "watt",
        "kilowatt",
        "megawatt",
        "gigawatt",
        "terawatt",
        "petawatt",
    ]
  • Import of convert_power_tool from tools package into server for use in MCP tool handlers.
    from .tools import (
        ANGLE_UNIT,
        AREA_UNIT,
        COMPUTER_DATA_UNIT,
        DENSITY_UNIT,
        ENERGY_UNIT,
        FORCE_UNIT,
        LENGTH_UNIT,
        MASS_UNIT,
        POWER_UNIT,
        PRESSURE_UNIT,
        SPEED_UNIT,
        TEMPERATURE_UNIT,
        TIME_UNIT,
        VOLUME_UNIT,
        convert_angle_tool,
        convert_area_tool,
        convert_batch_tool,
        convert_computer_data_tool,
        convert_density_tool,
        convert_energy_tool,
        convert_force_tool,
        convert_length_tool,
        convert_mass_tool,
        convert_power_tool,
  • Registration of convert_power_tool in the batch conversion tool's dispatcher dictionary.
    "power": convert_power_tool,
Behavior2/5

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

No annotations are provided, so the description carries full burden. 'Convert power between units' implies a read-only calculation, but it doesn't disclose whether this requires authentication, has rate limits, what precision to expect, or how errors are handled. For a tool with no annotation coverage, this is insufficient behavioral disclosure.

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 a single, efficient sentence that states the core functionality without any wasted words. It's appropriately sized for a straightforward conversion tool and gets directly to the point.

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

Completeness3/5

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

Given that there's an output schema (though not shown here), the description doesn't need to explain return values. However, for a conversion tool with no annotations, the description should ideally mention something about precision, error handling, or unit compatibility to provide more complete context for the agent.

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

Parameters3/5

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

Schema description coverage is 100%, so the schema already fully documents all three parameters with clear descriptions and comprehensive enum values. The description adds no additional parameter information beyond what's in the schema, which meets the baseline expectation when schema coverage is complete.

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

Purpose4/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 as converting power between units, which is a specific verb+resource combination. However, it doesn't distinguish this from sibling tools like convert_energy or convert_force, which might handle related but different physical quantities.

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

Usage Guidelines2/5

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

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention when power conversion is needed versus other conversion tools, nor does it provide any context about prerequisites or limitations.

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/zazencodes/unit-converter-mcp'

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