Skip to main content
Glama
asaficontact

Time MCP Server

by asaficontact

get_current_time

Retrieve the current time in any IANA timezone. Specify a timezone like 'America/New_York' or 'Europe/London' to get accurate local time information.

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 handler function that executes the logic for the 'get_current_time' tool, fetching the current time in the given timezone using zoneinfo and returning a structured TimeResult.
    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"), day_of_week=current_time.strftime("%A"), is_dst=bool(current_time.dst()), )
  • Pydantic BaseModel defining the output schema for the 'get_current_time' tool response.
    class TimeResult(BaseModel): timezone: str datetime: str day_of_week: str is_dst: bool
  • Registration of the 'get_current_time' tool in the MCP server's list_tools handler, including name, description, and input schema.
    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"], }, ),
  • Dispatch logic in the MCP server's call_tool handler that invokes the get_current_time tool handler upon matching the tool name.
    case TimeTools.GET_CURRENT_TIME.value: timezone = arguments.get("timezone") if not timezone: raise ValueError("Missing required argument: timezone") result = time_server.get_current_time(timezone)
  • Enum defining tool names, including the constant for 'get_current_time' used in registration and dispatching.
    class TimeTools(str, Enum): GET_CURRENT_TIME = "get_current_time" CONVERT_TIME = "convert_time"

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

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