Skip to main content
Glama
zazencodes

Unit Converter MCP

by zazencodes

convert_speed

Convert speed measurements between 22 units including km/h, mph, knots, meters per second, and speed of light. Enter value, source unit, and target unit for accurate conversion.

Instructions

Convert speed between units.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
valueYesSpeed value to convert
from_unitYesSource unit
to_unitYesTarget unit

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The MCP tool handler for 'convert_speed', decorated with @app.tool(). It validates inputs using SPEED_UNIT, calls convert_speed_tool for conversion, and returns a formatted response dictionary.
    @app.tool()
    def convert_speed(
        value: Annotated[float, Field(description="Speed value to convert")],
        from_unit: Annotated[SPEED_UNIT, Field(description="Source unit")],
        to_unit: Annotated[SPEED_UNIT, Field(description="Target unit")],
    ) -> dict:
        """Convert speed between units."""
        converted_value = convert_speed_tool(value, from_unit, to_unit)
        return {
            "original_value": value,
            "original_unit": from_unit,
            "converted_value": converted_value,
            "converted_unit": to_unit,
            "conversion_type": "speed",
        }
  • Pydantic Literal type defining all supported speed units for input validation in the convert_speed tool.
    SPEED_UNIT = Literal[
        "centimeters per minute",
        "centimeters per second",
        "feet per hour",
        "feet per minute",
        "feet per second",
        "inches per minute",
        "inches per second",
        "kilometers per hour",
        "kilometers per second",
        "knots",
        "Mach (ISA sea level)",
        "speed of sound",
        "meters per hour",
        "meters per minute",
        "meters per second",
        "miles per hour",
        "miles per minute",
        "miles per second",
        "yards per hour",
        "yards per minute",
        "yards per second",
        "speed of light",
    ]
  • Core helper function implementing the speed unit conversion logic by normalizing to meters per second and back.
    def convert_speed_tool(
        value: float,
        from_unit: SPEED_UNIT,
        to_unit: SPEED_UNIT,
    ) -> float:
        """Convert speed between units."""
    
        # Convert to meters per second first
        to_meters_per_second = {
            "centimeters per minute": 0.000166666667,
            "centimeters per second": 0.01,
            "feet per hour": 8.4666836e-05,
            "feet per minute": 0.00508,
            "feet per second": 0.3048,
            "inches per minute": 0.00042333418,
            "inches per second": 0.0254,
            "kilometers per hour": 0.277777777778,
            "kilometers per second": 1000.0,
            "knots": 0.514444444444,
            "Mach (ISA sea level)": 340.2933,  # 15 °C, 101.3 kPa
            "speed of sound": 343.0,  # dry air, ~1 atm, room temp
            "meters per hour": 0.000277777778,
            "meters per minute": 0.016666666667,
            "meters per second": 1.0,
            "miles per hour": 0.44704,
            "miles per minute": 26.8224,
            "miles per second": 1609.344,
            "yards per hour": 0.000254000508,
            "yards per minute": 0.01524,
            "yards per second": 0.9144,
            "speed of light": 299_792_458.0,  # exact physical constant
        }
    
        meters_per_second = value * to_meters_per_second[from_unit]
        return meters_per_second / to_meters_per_second[to_unit]
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It states the tool performs a conversion but doesn't mention error handling (e.g., invalid units), precision, rounding behavior, or whether it's a pure function. For a tool with 3 parameters and no annotation coverage, this is a significant gap in transparency.

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 directly states the tool's function without any unnecessary words. It's appropriately sized and front-loaded, with every word earning its place. No structural issues or redundancy are present.

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

Completeness4/5

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

Given the tool's straightforward nature (unit conversion), high schema coverage (100%), and the presence of an output schema (which handles return values), the description is reasonably complete. However, it lacks context about error cases or behavioral nuances that would be helpful for an AI agent, especially with no annotations provided.

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?

The schema description coverage is 100%, with clear descriptions for all parameters and comprehensive enum values for units. The description adds no additional parameter semantics beyond what's already in the schema. According to guidelines, when schema coverage is high (>80%), the baseline score is 3 even with no param info in the description.

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: converting speed between units. It specifies the verb ('convert') and resource ('speed'), making it immediately understandable. However, it doesn't differentiate from sibling tools like convert_length or convert_temperature, which follow the same pattern but for different measurement types.

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 sibling tools like convert_batch (for batch conversions) or list_supported_units (for discovering available units), nor does it specify any prerequisites or constraints for usage.

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