Skip to main content
Glama

get_current_time

Retrieve the current time for any specified timezone, defaulting to system time. Supports IANA timezone names like 'America/New_York' or 'UTC' for accurate timezone management.

Instructions

Get current time (defaults to system time, supports any timezone)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
timezoneYesTimezone to display. Use 'system' or 'local' for user's local time (Etc/UTC). Use IANA names like 'America/New_York', 'Europe/London', or 'UTC' for other timezones. System time is the default and most practical choice.

Implementation Reference

  • The core handler function in the TimeServer class that computes and returns the current time in the specified timezone as a TimeResult object. Handles system/local time and IANA timezones.
    def get_current_time(self, timezone_name: str) -> TimeResult:
        """Get current time in specified timezone (defaults to system time)"""
        # Get local system time first (this is the primary time)
        local_time = datetime.now()
        local_tz_name = str(get_local_tz())
        
        # If no specific timezone requested or if requesting system timezone, use local time
        if timezone_name.lower() in ["system", "local", local_tz_name.lower()]:
            current_time = local_time
            display_timezone = f"System ({local_tz_name})"
            actual_timezone = local_tz_name
        else:
            # Use requested timezone
            timezone = get_zoneinfo(timezone_name)
            current_time = datetime.now(timezone)
            display_timezone = timezone_name
            actual_timezone = timezone_name
    
        # Create formatted timezone display
        formatted_timezone = current_time.strftime("%B %d, %Y at %I:%M:%S %p")
        if timezone_name.lower() == "utc":
            formatted_timezone += " UTC"
        elif timezone_name.lower() in ["system", "local"]:
            formatted_timezone += f" (System Time - {local_tz_name})"
        else:
            formatted_timezone += f" ({timezone_name})"
    
        result = TimeResult(
            timezone=actual_timezone,
            datetime=current_time.isoformat(timespec="seconds"),
            formatted_timezone=formatted_timezone,
            day_of_week=current_time.strftime("%A"),
            is_dst=bool(current_time.dst()),
        )
        
        return result
  • Pydantic model defining the structured output schema for the get_current_time tool response.
    class TimeResult(BaseModel):
        timezone: str
        datetime: str
        formatted_timezone: str
        day_of_week: str
        is_dst: bool
  • Tool registration in the list_tools() handler, defining name, description, and input schema for MCP client discovery.
        name=TimeTools.GET_CURRENT_TIME.value,
        description="Get current time (defaults to system time, supports any timezone)",
        inputSchema={
            "type": "object",
            "properties": {
                "timezone": {
                    "type": "string", 
                    "description": f"Timezone to display. Use 'system' or 'local' for user's local time ({local_tz}). Use IANA names like 'America/New_York', 'Europe/London', or 'UTC' for other timezones. System time is the default and most practical choice.",
                }
            },
            "required": ["timezone"],
        },
    ),
  • Dispatch logic in _execute_tool where the tool name is matched via pattern matching and the handler is invoked with validated arguments.
    case TimeTools.GET_CURRENT_TIME.value:
        timezone = arguments.get("timezone")
        if not timezone:
            raise ValueError("Missing required argument: timezone")
    
        # Validate timezone with helpful error messages
        validated_timezone = validate_timezone(timezone)
        result = time_server.get_current_time(validated_timezone)
  • Enum defining the tool names as constants, used for registration and dispatch.
    class TimeTools(str, Enum):
        GET_CURRENT_TIME = "get_current_time"
        CONVERT_TIME = "convert_time"
        START_ACTIVITY_LOG = "start_activity_log"
        END_ACTIVITY_LOG = "end_activity_log"
        GET_ELAPSED_TIME = "get_elapsed_time"
        GET_ACTIVITY_LOGS = "get_activity_logs"
        UPDATE_ACTIVITY_LOG = "update_activity_log"
        CREATE_TIME_REMINDER = "create_time_reminder"
        CHECK_TIME_REMINDERS = "check_time_reminders"
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 'gets' current time with defaults and timezone support, implying a read-only operation, but doesn't address potential side effects, error handling, or output format. This is inadequate for a tool with no annotation coverage.

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 front-loads the core purpose ('Get current time') and adds essential qualifiers without waste. Every word earns its place, making it appropriately sized and well-structured.

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 low complexity (1 parameter, no output schema, no annotations), the description covers the basic purpose and parameter context adequately. However, it lacks details on output format and behavioral traits, which are needed for full completeness, especially without annotations.

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 input schema fully documents the 'timezone' parameter. The description adds marginal value by mentioning 'defaults to system time' and 'supports any timezone', but doesn't provide syntax or format details beyond what the schema already specifies, aligning with the baseline for high coverage.

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 with the verb 'Get' and resource 'current time', specifying it defaults to system time and supports timezones. However, it doesn't explicitly differentiate from sibling tools like 'convert_time' or 'get_elapsed_time', which prevents a perfect score.

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 like 'convert_time' or 'check_time_reminders'. It mentions defaults and timezone support but lacks explicit when/when-not instructions or sibling comparisons, leaving usage context unclear.

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/n0zer0d4y/chronos-protocol'

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