Skip to main content
Glama

get_weather

Get current weather conditions for any specified city. Provide a city name to receive temperature, humidity, and forecast details for trip planning and daily activities.

Instructions

Get the weather for the given location

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
cityYes

Implementation Reference

  • server.py:28-32 (handler)
    The MCP tool handler for 'get_weather'. Decorated with @mcp.tool(), it accepts a city name, creates a GetWeather instance, and returns the weather string.
    @mcp.tool()
    def get_weather(city: str) -> str:
        """Get the weather for the given location"""
        weather = GetWeather(city)
        return str(weather)
  • Helper class that queries the WeatherAPI.com API. Uses WEATHER_API_KEY env variable, fetches current weather data for a city, and formats the result with temperature, condition, humidity, and wind info.
    class GetWeather:
        def __init__(self, city: str):
            self.city = city
            self.api_key = os.getenv("WEATHER_API_KEY")
            self.base_url = "http://api.weatherapi.com/v1/current.json"
    
        def get_weather(self):
            if not self.api_key:
                return "Error: WEATHER_API_KEY not found in environment variables"
            
            try:
                params = {
                    "key": self.api_key,
                    "q": self.city,
                    "aqi": "no"
                }
                response = requests.get(self.base_url, params=params)
                response.raise_for_status()
                data = response.json()
                
                location = data['location']
                current = data['current']
                
                weather_info = f"""Weather in {location['name']}, {location['region']}:
    Temperature: {current['temp_f']}°F (feels like {current['feelslike_f']}°F)
    Condition: {current['condition']['text']}
    Humidity: {current['humidity']}%
    Wind: {current['wind_mph']} mph {current['wind_dir']}
    """
                return weather_info
            except requests.exceptions.RequestException as e:
                return f"Error fetching weather data: {str(e)}"
    
        def __str__(self):
            return self.get_weather()
  • server.py:28-32 (registration)
    The @mcp.tool() decorator registers 'get_weather' as an MCP tool on the FastMCP server instance.
    @mcp.tool()
    def get_weather(city: str) -> str:
        """Get the weather for the given location"""
        weather = GetWeather(city)
        return str(weather)
Behavior1/5

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

With no annotations, the description must carry the behavioral burden, but it only says 'Get the weather' without disclosing the data source, return format, units, caching, or any constraints. This is insufficient for the agent to anticipate tool behavior.

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

Conciseness3/5

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

The description is a single sentence, concise and front-loaded, but it is too minimal; it earns its place by specifying the input role but lacks detail that would justify its brevity.

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 output schema, the description should hint at what is returned (e.g., temperature, conditions). It does not, leaving the agent uncertain about the tool's output. For a simple tool, this is inadequate.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters2/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The one parameter 'city' has no description in the input schema (0% coverage), and the description merely says 'given location' which adds little meaning. It does not specify format, examples, or constraints on what constitutes a valid city.

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 verb 'Get' and resource 'weather' for a given location, distinguishing it from siblings 'roll_dice' and 'web_search' which serve different purposes.

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 is given on when to use this tool versus alternatives. The description only states what the tool does, without any context on appropriate usage or exclusions.

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/keertanachandar/AIE8-MCP'

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