Skip to main content
Glama

weather_current

Get current weather conditions and air quality data for any location using city names, coordinates, or postal codes.

Instructions

Get current weather for a location

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
qYesLocation query (city name, lat/lon, postal code, etc)
aqiNoInclude air quality data ('yes' or 'no')no

Implementation Reference

  • Handler logic for the 'weather_current' tool: parses arguments, validates location query, fetches current weather data using the shared 'fetch' helper, and formats the JSON response.
    if tool_name == "weather_current":
        q = arguments.get("q")
        aqi = arguments.get("aqi", "no")
        if not q:
            raise ValueError("Location (q) is required")
        result = await fetch("current.json", {"q": q, "aqi": aqi})
        content = json.dumps(result, indent=2)
  • Input schema defining the parameters for the 'weather_current' tool: required 'q' for location and optional 'aqi'.
    "inputSchema": {
        "type": "object",
        "properties": {
            "q": {
                "type": "string",
                "description": "Location query (city name, lat/lon, postal code, etc)"
            },
            "aqi": {
                "type": "string",
                "description": "Include air quality data ('yes' or 'no')",
                "default": "no"
            }
        },
        "required": ["q"]
    }
  • server.py:109-127 (registration)
    Registration of the 'weather_current' tool in the tools/list response, including name, description, and schema.
    {
        "name": "weather_current",
        "description": "Get current weather for a location",
        "inputSchema": {
            "type": "object",
            "properties": {
                "q": {
                    "type": "string",
                    "description": "Location query (city name, lat/lon, postal code, etc)"
                },
                "aqi": {
                    "type": "string",
                    "description": "Include air quality data ('yes' or 'no')",
                    "default": "no"
                }
            },
            "required": ["q"]
        }
    },
  • Shared 'fetch' utility function that performs HTTP requests to the WeatherAPI for all tools, including 'weather_current', handling API key, errors, and JSON parsing.
    async def fetch(endpoint: str, params: dict) -> dict:
        """Perform async GET to WeatherAPI and return JSON."""
        logger.debug(f"fetch() called with endpoint: {endpoint}, params: {params}")
        
        if not WEATHER_API_KEY:
            logger.error("Weather API key not set.")
            raise Exception("Weather API key not set.")
    
        params["key"] = WEATHER_API_KEY
        url = f"https://api.weatherapi.com/v1/{endpoint}"
        logger.info(f"Requesting {url}")
        
        async with httpx.AsyncClient() as client:
            logger.debug("HTTPx client created")
            try:
                resp = await client.get(url, params=params)
                logger.debug(f"HTTP response received: status={resp.status_code}")
                
                if resp.status_code != 200:
                    try:
                        error_data = resp.json()
                        detail = error_data.get("error", {}).get("message", resp.text)
                    except:
                        detail = resp.text
                    logger.error(f"WeatherAPI error {resp.status_code}: {detail}")
                    raise Exception(f"WeatherAPI error {resp.status_code}: {detail}")
                    
                data = resp.json()
                logger.debug(f"JSON parsing successful")
                logger.info(f"WeatherAPI success: {url}")
                return data
                
            except httpx.RequestError as e:
                logger.error(f"HTTPX request error: {e}")
                raise Exception(f"Request error: {e}")
            except Exception as e:
                logger.error(f"Unexpected error: {e}")
                raise Exception(f"Unexpected error: {e}")
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's function but does not cover important aspects such as rate limits, authentication needs, error handling, or response format. This leaves significant gaps in understanding how the tool behaves beyond its basic purpose.

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 extremely concise and front-loaded, consisting of a single sentence that directly states the tool's purpose. There is no wasted language, making it efficient and easy to parse for an AI agent.

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?

Given the lack of annotations and output schema, the description is incomplete. It does not address behavioral traits, response format, or usage context, which are crucial for a tool with parameters and no structured output information. This leaves the agent with insufficient information to fully understand the tool's operation.

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 has 100% description coverage, clearly documenting both parameters ('q' for location query and 'aqi' for air quality data). The description does not add any additional meaning beyond what the schema provides, so it meets the baseline score of 3 for adequate but not enhanced parameter semantics.

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 a specific verb ('Get') and resource ('current weather for a location'), making it easy to understand what it does. However, it does not explicitly differentiate itself from sibling tools like 'weather_forecast' or 'weather_search', which might offer similar weather-related functionality.

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 'weather_forecast' or 'weather_search'. It lacks context about use cases, exclusions, or prerequisites, leaving the agent to infer usage based on the tool name alone.

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/first-it-consulting/weather-mcp-server'

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