Skip to main content
Glama

weather_search

Find locations by name or query to enable weather data retrieval, supporting accurate weather information access through location identification.

Instructions

Search for locations matching query

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
qYesLocation query

Implementation Reference

  • Handler logic for the weather_search tool: extracts 'q' parameter, validates it, fetches data from search.json endpoint using the fetch helper, and serializes the result to JSON.
    elif tool_name == "weather_search":
        q = arguments.get("q")
        if not q:
            raise ValueError("Location (q) is required")
        result = await fetch("search.json", {"q": q})
        content = json.dumps(result, indent=2)
  • Input schema definition for the weather_search tool, specifying the required 'q' string parameter.
    "inputSchema": {
        "type": "object",
        "properties": {
            "q": {
                "type": "string",
                "description": "Location query"
            }
        },
        "required": ["q"]
  • server.py:147-160 (registration)
    Tool registration entry for weather_search in the tools/list response, including name, description, and schema.
    {
        "name": "weather_search",
        "description": "Search for locations matching query",
        "inputSchema": {
            "type": "object",
            "properties": {
                "q": {
                    "type": "string",
                    "description": "Location query"
                }
            },
            "required": ["q"]
        }
    }
  • Shared helper function fetch() used by weather_search to make asynchronous HTTP requests to the WeatherAPI search endpoint, handling authentication, 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
Behavior2/5

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

No annotations are provided, so the description carries full burden. It doesn't disclose behavioral traits such as whether this is a read-only operation, if it requires authentication, rate limits, or what the output format might be (e.g., list of locations with IDs/names). The description is minimal and lacks essential context for safe and effective use.

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?

The description is very concise with a single sentence 'Search for locations matching query', which is front-loaded and wastes no words. However, it might be overly terse given the lack of context, but it earns points for being direct and structured efficiently.

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 no annotations, no output schema, and sibling tools present, the description is incomplete. It doesn't explain how this tool fits into the weather context (e.g., is it a prerequisite for other tools?), what the return values are, or any error conditions. For a tool with potential complexity in a weather server, more context is needed.

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, with parameter 'q' described as 'Location query'. The description adds no additional meaning beyond this, as it essentially restates the schema. With high schema coverage, the baseline is 3, and the description doesn't compensate with extra details like query format examples or constraints.

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

Purpose3/5

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

The description 'Search for locations matching query' states a clear action (search) and target (locations), but it's vague about what kind of locations (weather-related?) and doesn't distinguish from siblings like 'weather_current' or 'weather_forecast'. It provides basic purpose but lacks specificity and differentiation.

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?

No guidance on when to use this tool vs. alternatives like 'weather_current' or 'weather_forecast'. The description implies it's for searching locations, but doesn't specify if this is for finding locations to then get weather data, or if it's a standalone search. No explicit when/when-not or alternative usage is mentioned.

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