Skip to main content
Glama
isdaniel

Weather MCP Server

get_timezone_info

Retrieve current time and UTC offset for any IANA timezone to coordinate schedules and manage global time differences.

Instructions

Get information about a specific timezone including current time and UTC offset.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
timezone_nameYesIANA timezone name (e.g., 'America/New_York', 'Europe/London')

Implementation Reference

  • Implements the core execution logic for the 'get_timezone_info' tool: validates input, retrieves timezone object, computes current times, UTC offset, DST status, and abbreviation, then returns JSON-formatted info.
    async def run_tool(self, args: dict) -> Sequence[TextContent | ImageContent | EmbeddedResource]: """ Execute the timezone info tool. """ try: self.validate_required_args(args, ["timezone_name"]) timezone_name = args["timezone_name"] logger.info(f"Getting timezone info for: {timezone_name}") # Get timezone info timezone = utils.get_zoneinfo(timezone_name) current_time = datetime.now(timezone) utc_time = datetime.utcnow() # Calculate UTC offset offset = current_time.utcoffset() offset_hours = offset.total_seconds() / 3600 if offset else 0 timezone_info = { "timezone_name": timezone_name, "current_local_time": current_time.isoformat(timespec="seconds"), "current_utc_time": utc_time.isoformat(timespec="seconds"), "utc_offset_hours": offset_hours, "is_dst": current_time.dst() is not None and current_time.dst().total_seconds() > 0, "timezone_abbreviation": current_time.strftime("%Z"), } return [ TextContent( type="text", text=json.dumps(timezone_info, indent=2) ) ] except Exception as e: logger.exception(f"Error in get_timezone_info: {str(e)}") return [ TextContent( type="text", text=f"Error getting timezone info: {str(e)}" ) ]
  • Defines the tool metadata including name 'get_timezone_info', description, and input schema requiring 'timezone_name' (IANA timezone string).
    def get_tool_description(self) -> Tool: """ Return the tool description for timezone information lookup. """ return Tool( name=self.name, description="""Get information about a specific timezone including current time and UTC offset.""", inputSchema={ "type": "object", "properties": { "timezone_name": { "type": "string", "description": "IANA timezone name (e.g., 'America/New_York', 'Europe/London')" } }, "required": ["timezone_name"] } )
  • Registers the GetTimeZoneInfoToolHandler instance with the server's tool registry during initialization.
    add_tool_handler(GetTimeZoneInfoToolHandler())

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/isdaniel/mcp_weather_server'

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