Skip to main content
Glama
dumyCq

Time MCP Server

by dumyCq

convert_time

Convert time between different timezones using IANA timezone names. Enter source timezone, time in 24-hour format, and target timezone to get the converted time.

Instructions

Convert time between timezones

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
source_timezoneYesSource IANA timezone name (e.g., 'America/New_York', 'Europe/London'). Use 'Etc/UTC' as local timezone if no source timezone provided by the user.
timeYesTime to convert in 24-hour format (HH:MM)
target_timezoneYesTarget IANA timezone name (e.g., 'Asia/Tokyo', 'America/San_Francisco'). Use 'Etc/UTC' as local timezone if no target timezone provided by the user.

Implementation Reference

  • Core implementation of the convert_time tool: parses HH:MM time string, constructs full datetime in source timezone for today, converts to target timezone, computes offset difference, and returns structured TimeConversionResult.
    def convert_time(
        self, source_tz: str, time_str: str, target_tz: str
    ) -> TimeConversionResult:
        """Convert time between timezones"""
        source_timezone = get_zoneinfo(source_tz)
        target_timezone = get_zoneinfo(target_tz)
    
        try:
            parsed_time = datetime.strptime(time_str, "%H:%M").time()
        except ValueError:
            raise ValueError("Invalid time format. Expected HH:MM [24-hour format]")
    
        now = datetime.now(source_timezone)
        source_time = datetime(
            now.year,
            now.month,
            now.day,
            parsed_time.hour,
            parsed_time.minute,
            tzinfo=source_timezone,
        )
    
        target_time = source_time.astimezone(target_timezone)
        source_offset = source_time.utcoffset() or timedelta()
        target_offset = target_time.utcoffset() or timedelta()
        hours_difference = (target_offset - source_offset).total_seconds() / 3600
    
        if hours_difference.is_integer():
            time_diff_str = f"{hours_difference:+.1f}h"
        else:
            # For fractional hours like Nepal's UTC+5:45
            time_diff_str = f"{hours_difference:+.2f}".rstrip("0").rstrip(".") + "h"
    
        return TimeConversionResult(
            source=TimeResult(
                timezone=source_tz,
                datetime=source_time.isoformat(timespec="seconds"),
                is_dst=bool(source_time.dst()),
            ),
            target=TimeResult(
                timezone=target_tz,
                datetime=target_time.isoformat(timespec="seconds"),
                is_dst=bool(target_time.dst()),
            ),
            time_difference=time_diff_str,
        )
  • Registration of the 'convert_time' tool via @server.list_tools(), specifying name, description, and JSON schema for inputs: source_timezone, time (HH:MM), target_timezone.
    Tool(
        name=TimeTools.CONVERT_TIME.value,
        description="Convert time between timezones",
        inputSchema={
            "type": "object",
            "properties": {
                "source_timezone": {
                    "type": "string",
                    "description": f"Source IANA timezone name (e.g., 'America/New_York', 'Europe/London'). Use '{local_tz}' as local timezone if no source timezone provided by the user.",
                },
                "time": {
                    "type": "string",
                    "description": "Time to convert in 24-hour format (HH:MM)",
                },
                "target_timezone": {
                    "type": "string",
                    "description": f"Target IANA timezone name (e.g., 'Asia/Tokyo', 'America/San_Francisco'). Use '{local_tz}' as local timezone if no target timezone provided by the user.",
                },
            },
            "required": ["source_timezone", "time", "target_timezone"],
        },
    ),
  • Pydantic schemas for output structures: TimeResult (per-timezone info) and TimeConversionResult (source/target times and difference). Used by the handler to validate/structure response.
    class TimeResult(BaseModel):
        timezone: str
        datetime: str
        is_dst: bool
    
    
    class TimeConversionResult(BaseModel):
        source: TimeResult
        target: TimeResult
        time_difference: str
  • Enum defining tool names, including CONVERT_TIME used in registration and dispatch.
    class TimeTools(str, Enum):
        GET_CURRENT_TIME = "get_current_time"
        CONVERT_TIME = "convert_time"
  • Dispatch logic in @server.call_tool() that validates arguments and invokes the convert_time handler.
    case TimeTools.CONVERT_TIME.value:
        if not all(
            k in arguments
            for k in ["source_timezone", "time", "target_timezone"]
        ):
            raise ValueError("Missing required arguments")
    
        result = time_server.convert_time(
            arguments["source_timezone"],
            arguments["time"],
            arguments["target_timezone"],
        )
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. The description only states the basic function without mentioning any behavioral traits like error handling (e.g., invalid timezone names), default behaviors (e.g., using 'Etc/UTC' as default per the schema), or output format. For a tool with 3 required parameters and no annotations, this leaves significant gaps in understanding how it behaves in edge cases.

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: 'Convert time between timezones.' It's front-loaded with the core purpose and contains no unnecessary words. Every part of the sentence earns its place by clearly stating the tool's function.

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

Completeness2/5

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

Given the tool's complexity (3 required parameters, no annotations, no output schema), the description is incomplete. It doesn't explain the return values, error conditions, or behavioral nuances like the default 'Etc/UTC' timezone mentioned in the schema. For a conversion tool with no output schema, the description should at least hint at what the output looks like (e.g., converted time in HH:MM format).

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%, with detailed descriptions for all parameters (source_timezone, time, target_timezone) including format examples and default behaviors. 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 is 3 even with no param info in the description, which applies here.

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 timezones' clearly states the verb ('convert') and resource ('time'), specifying the operation as timezone conversion. It distinguishes from the sibling tool 'get_current_time' by focusing on conversion rather than retrieval. However, it doesn't explicitly mention the specific format (24-hour) or IANA timezone requirement, which would make it a 5.

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 the sibling tool 'get_current_time' or any other potential tools for time-related operations. There's no context about prerequisites, such as needing IANA timezone names, or when this tool is preferred over other time conversion methods.

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/dumyCq/time-mcp'

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