Skip to main content
Glama
zazencodes

Unit Converter MCP

by zazencodes

convert_time

Convert time values between units like seconds, minutes, hours, days, and years using the Unit Converter MCP server. Enter a value with source and target units for precise conversion.

Instructions

Convert time between units.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
valueYesTime value to convert
from_unitYesSource unit
to_unitYesTarget unit

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • MCP tool handler named 'convert_time' that executes the tool logic by calling the core convert_time_tool and formatting the response.
    @app.tool()
    def convert_time(
        value: Annotated[float, Field(description="Time value to convert")],
        from_unit: Annotated[TIME_UNIT, Field(description="Source unit")],
        to_unit: Annotated[TIME_UNIT, Field(description="Target unit")],
    ) -> dict:
        """Convert time between units."""
        converted_value = convert_time_tool(value, from_unit, to_unit)
        return {
            "original_value": value,
            "original_unit": from_unit,
            "converted_value": converted_value,
            "converted_unit": to_unit,
            "conversion_type": "time",
        }
  • Core helper function implementing the time conversion logic by normalizing to seconds.
    def convert_time_tool(
        value: float,
        from_unit: TIME_UNIT,
        to_unit: TIME_UNIT,
    ) -> float:
        """Convert time between units."""
    
        # Convert to seconds first
        to_seconds = {
            # sub‑second
            "picoseconds": 1e-12,
            "femtoseconds": 1e-15,
            "nanoseconds": 1e-09,
            "microseconds": 1e-06,
            "milliseconds": 0.001,
            # second and above
            "seconds": 1.0,
            "minutes": 60.0,
            "hours": 3_600.0,
            "days": 86_400.0,
            "weeks": 604_800.0,
            "fortnights": 1_209_600.0,
            # calendar averages
            "months": 2_628_000.0,  # 1/12 of avg Gregorian year
            "quarters": 7_884_000.0,  # 3 × avg month
            # optional lunar unit (keep or drop as you wish)
            "synodic months": 2_551_442.8896,  # mean lunation
            # years & multiples — now ONE canonical value
            "years": 31_556_952.0,  # average Gregorian (365.2425 d)
            "decades": 315_569_520.0,  # 10 × year
            "centuries": 3_155_695_200.0,  # 100 × year
            "millennia": 31_556_952_000.0,  # 1 000 × year
        }
    
        seconds = value * to_seconds[from_unit]
        return seconds / to_seconds[to_unit]
  • Pydantic/Literal type schema defining valid time units for input validation in the convert_time tool.
    TIME_UNIT = Literal[
        "picoseconds",
        "femtoseconds",
        "nanoseconds",
        "microseconds",
        "milliseconds",
        "seconds",
        "minutes",
        "hours",
        "days",
        "weeks",
        "fortnights",
        "months",
        "quarters",
        "synodic months",
        "years",
        "decades",
        "centuries",
        "millennia",
    ]
Behavior2/5

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

With no annotations provided, the description carries full burden for behavioral disclosure but offers minimal information. It doesn't mention precision, rounding behavior, error handling for invalid conversions, or whether the conversion uses standard definitions. The agent must infer behavior from the schema alone.

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 purpose without any unnecessary words. It's perfectly front-loaded with the essential information, making it easy for an agent to parse quickly.

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 the tool's simple conversion function, 100% schema coverage, and presence of an output schema, the description is minimally adequate. However, for a tool with no annotations, it should ideally provide more behavioral context about conversion precision, supported unit relationships, or error conditions to help the agent use it correctly.

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 fully documents all three parameters with clear descriptions and comprehensive enum values. The description adds no additional parameter semantics beyond what's already in the structured schema, meeting 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 'Convert time between units' clearly states the verb ('convert') and resource ('time'), making the purpose immediately understandable. It distinguishes this tool from siblings like convert_angle or convert_length by specifying the time domain, though it doesn't explicitly contrast with convert_batch which might handle multiple conversions.

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 to choose convert_time over convert_batch for batch operations, or how it relates to list_supported_units for discovering available units. Usage context is entirely implied rather than stated.

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