Skip to main content
Glama
zazencodes

Unit Converter MCP

by zazencodes

convert_angle

Convert angle measurements between degrees, radians, arcmin, arcsec, turns, and gons for mathematical and engineering calculations.

Instructions

Convert angle between units.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
valueYesAngle value to convert
from_unitYesSource unit
to_unitYesTarget unit

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • Core handler function that executes the angle unit conversion logic using intermediate degrees conversion.
    def convert_angle_tool(
        value: float,
        from_unit: ANGLE_UNIT,
        to_unit: ANGLE_UNIT,
    ) -> float:
        """Convert angle between units."""
    
        # Dictionary mapping units to their conversion functions to degrees
        to_degrees: dict[ANGLE_UNIT, Callable[[float], float]] = {
            "radians": _radians_to_degrees,
            "arcmin": _arcmin_to_degrees,
            "arcsec": _arcsec_to_degrees,
            "turns": _turns_to_degrees,
            "gons": _gons_to_degrees,
            "degrees": lambda x: x,
        }
    
        # Dictionary mapping units to their conversion functions from degrees
        from_degrees: dict[ANGLE_UNIT, Callable[[float], float]] = {
            "radians": _degrees_to_radians,
            "arcmin": _degrees_to_arcmin,
            "arcsec": _degrees_to_arcsec,
            "turns": _degrees_to_turns,
            "gons": _degrees_to_gons,
            "degrees": lambda x: x,
        }
    
        # Convert to degrees first
        degrees = to_degrees[from_unit](value)
    
        # Convert from degrees to target unit
        return from_degrees[to_unit](degrees)
  • MCP tool handler for 'convert_angle', defines parameters with descriptions (schema), calls core logic, and returns formatted response.
    @app.tool()
    def convert_angle(
        value: Annotated[float, Field(description="Angle value to convert")],
        from_unit: Annotated[ANGLE_UNIT, Field(description="Source unit")],
        to_unit: Annotated[ANGLE_UNIT, Field(description="Target unit")],
    ) -> dict:
        """Convert angle between units."""
        converted_value = convert_angle_tool(value, from_unit, to_unit)
        return {
            "original_value": value,
            "original_unit": from_unit,
            "converted_value": converted_value,
            "converted_unit": to_unit,
            "conversion_type": "angle",
        }
  • Type schema definition for valid angle units used in tool parameters.
    ANGLE_UNIT = Literal["degrees", "radians", "arcmin", "arcsec", "turns", "gons"]
  • Imports the convert_angle_tool and ANGLE_UNIT for use in tool registration.
    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,
        convert_pressure_tool,
        convert_speed_tool,
        convert_temperature_tool,
        convert_time_tool,
        convert_volume_tool,
    )
  • Supporting helper functions for individual unit conversions to/from degrees.
    def _radians_to_degrees(value: float) -> float:
        """Convert radians to degrees."""
        return value * 180.0 / math.pi
    
    
    def _degrees_to_radians(value: float) -> float:
        """Convert degrees to radians."""
        return value * math.pi / 180.0
    
    
    def _arcmin_to_degrees(value: float) -> float:
        """Convert arc-minutes to degrees."""
        return value / 60.0
    
    
    def _degrees_to_arcmin(value: float) -> float:
        """Convert degrees to arc-minutes."""
        return value * 60.0
    
    
    def _arcsec_to_degrees(value: float) -> float:
        """Convert arc-seconds to degrees."""
        return value / 3_600.0
    
    
    def _degrees_to_arcsec(value: float) -> float:
        """Convert degrees to arc-seconds."""
        return value * 3_600.0
    
    
    def _turns_to_degrees(value: float) -> float:
        """Convert turns to degrees."""
        return value * 360.0
    
    
    def _degrees_to_turns(value: float) -> float:
        """Convert degrees to turns."""
        return value / 360.0
    
    
    def _gons_to_degrees(value: float) -> float:
        """Convert gons to degrees."""
        return value * (9.0 / 10.0)
    
    
    def _degrees_to_gons(value: float) -> float:
        """Convert degrees to gons."""
        return value * (10.0 / 9.0)
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 what the tool does but reveals nothing about its behavior: no information about precision, error handling, rate limits, authentication needs, or what the output looks like. For a conversion tool, details like rounding behavior or supported value ranges would be valuable but are absent.

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. Every word earns its place.

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 this is a simple conversion tool with 100% schema coverage and an output schema exists (though not shown in the context), the description is minimally adequate. However, with no annotations and no behavioral details, it leaves gaps about how the tool actually behaves in practice. The existence of an output schema means the description doesn't need to explain return values, but other behavioral aspects remain uncovered.

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 three parameters and enum values for units. The description adds no additional parameter semantics beyond what's already in the schema. According to the rules, when schema coverage is high (>80%), the baseline score is 3 even without parameter 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 angles between units. It specifies the resource (angle) and the action (convert), making it immediately understandable. However, it doesn't explicitly differentiate from sibling tools like convert_area or convert_temperature, which follow the same pattern 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. While the name suggests it's for angle conversion specifically, there's no mention of sibling tools like convert_batch (which might handle multiple conversions) or list_supported_units (which could help identify available units). The agent must infer usage from the tool name alone.

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