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

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