Skip to main content
Glama
ssinha3

Time MCP Server

by ssinha3

get_current_time

Retrieve the current time and date for a specified IANA timezone using the Time MCP Server. Input the timezone name to get accurate local time information for global applications.

Instructions

Get current time in a specific timezones

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
timezoneYesIANA timezone name (e.g., 'America/New_York', 'Europe/London'). Use 'Etc/UTC' as local timezone if no timezone provided by the user.

Implementation Reference

  • The main handler function for the 'get_current_time' tool. It takes a timezone_name, retrieves the ZoneInfo object, gets the current datetime in that timezone, and returns a TimeResult object containing the timezone, ISO-formatted datetime string, and DST status.
    def get_current_time(self, timezone_name: str) -> TimeResult:
        """Get current time in specified timezone"""
        timezone = get_zoneinfo(timezone_name)
        current_time = datetime.now(timezone)
    
        return TimeResult(
            timezone=timezone_name,
            datetime=current_time.isoformat(timespec="seconds"),
            is_dst=bool(current_time.dst()),
        )
  • Pydantic model defining the structured output for the get_current_time tool response.
    class TimeResult(BaseModel):
        timezone: str
        datetime: str
        is_dst: bool
  • Tool registration in the MCP server's list_tools pipeline, defining the tool's name, description, and input schema which requires a 'timezone' parameter as a string.
    Tool(
        name=TimeTools.GET_CURRENT_TIME.value,
        description="Get current time in a specific timezones",
        inputSchema={
            "type": "object",
            "properties": {
                "timezone": {
                    "type": "string",
                    "description": f"IANA timezone name (e.g., 'America/New_York', 'Europe/London'). Use '{local_tz}' as local timezone if no timezone provided by the user.",
                }
            },
            "required": ["timezone"],
        },
    ),
  • Utility function to create a ZoneInfo object from a timezone name string, with error handling for invalid timezones. Called by the get_current_time handler.
    def get_zoneinfo(timezone_name: str) -> ZoneInfo:
        try:
            return ZoneInfo(timezone_name)
        except Exception as e:
            raise McpError(f"Invalid timezone: {str(e)}")
  • String enum defining the canonical names for time-related tools, used in registration and dispatch.
    class TimeTools(str, Enum):
        GET_CURRENT_TIME = "get_current_time"
        CONVERT_TIME = "convert_time"

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv1.0.0

TDQS

C2.8/5.0
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. It only states 'Get current time' without disclosing output format, time source, or any behavioral details like handling of invalid timezones.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness3/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Description is a single sentence but grammatically flawed ('timezones'). It is concise but lacks clarity and proper structure.

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?

With no output schema and no annotations, the description omits critical context such as return format, time source (server vs user), and error handling. Incomplete for a simple tool.

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 input schema already provides full description of the 'timezone' parameter with examples (100% coverage). The tool description adds no additional semantic value beyond what the schema offers.

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?

Description clearly states the tool gets current time in a specific timezone, but the grammar ('timezones') slightly reduces clarity. It distinguishes from sibling 'convert_time' by focusing on current time retrieval.

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?

No guidance on when to use this tool vs the sibling 'convert_time' or any exclusion criteria. The description does not indicate context-specific usage.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Deploy Server

Other Tools

Related Tools