Skip to main content
Glama
isdaniel

Weather MCP Server

get_timezone_info

Get current time and UTC offset for any IANA timezone name.

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

  • The GetTimeZoneInfoToolHandler class that implements the 'get_timezone_info' tool. Contains the run_tool method (lines 108-150) which executes the logic: validates args, gets zoneinfo, computes current local time, UTC time, UTC offset, DST status, and timezone abbreviation, then returns the result as JSON.
    class GetTimeZoneInfoToolHandler(ToolHandler):
        """
        Tool handler for getting information about timezones.
        """
    
        def __init__(self):
            super().__init__("get_timezone_info")
    
        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"]
                }
            )
    
        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)}"
                    )
                ]
  • The get_tool_description method defining the input schema for 'get_timezone_info'. Takes a required 'timezone_name' string parameter (IANA timezone name).
    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"]
            }
        )
  • Registration of GetTimeZoneInfoToolHandler in the register_all_tools() function, which instantiates and adds it to the global tool_handlers registry.
    add_tool_handler(GetTimeZoneInfoToolHandler())
  • Import of GetTimeZoneInfoToolHandler from tools.tools_time module into server.py.
        GetCurrentDateTimeToolHandler,
        GetTimeZoneInfoToolHandler,
        ConvertTimeToolHandler,
    )
  • The get_zoneinfo helper function used by GetTimeZoneInfoToolHandler.run_tool to resolve an IANA timezone name string to a ZoneInfo object.
    def get_zoneinfo(timezone_name: str) -> ZoneInfo:
        try:
            return ZoneInfo(timezone_name)
        except Exception as e:
            error_data = ErrorData(code=-1, message=f"Invalid timezone: {str(e)}")
            raise McpError(error_data)
Behavior3/5

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

No annotations provided, so description carries full burden. It mentions return of current time and offset, but doesn't discuss error handling, behavior on invalid timezone names, or any other side effects. Adequate but not comprehensive.

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

Conciseness4/5

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

Single sentence, efficient, no redundant content. Could be slightly more informative without increasing length, but remains appropriately concise.

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

Completeness4/5

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

Given a single parameter and no output schema, the description fully explains purpose and return content. However, specifying output format (e.g., JSON fields) would enhance completeness. Overall, sufficient 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?

With 100% schema coverage and a single parameter already described, the description adds minimal value beyond restating 'including current time and UTC offset'. It does not elaborate on parameter format or constraints.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool gets information about a specific timezone including current time and UTC offset. It uses a specific verb 'Get' and resource 'timezone info', distinguishing it from sibling tools like convert_time or get_current_datetime.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage when timezone info is needed, but lacks explicit when-to-use, when-not-to-use, or references to alternatives. No guidance on when to prefer this over sibling tools like convert_time.

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

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