Skip to main content
Glama

get_current_conditions

Retrieve current weather conditions for any location by providing latitude and longitude coordinates.

Instructions

Get current weather conditions for a location.

Args:
    latitude: Latitude of the location (-90 to 90)
    longitude: Longitude of the location (-180 to 180)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
latitudeYes
longitudeYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The handler function for the 'get_current_conditions' tool. It validates coordinates, fetches weather points from NWS API, retrieves the nearest observation station, gets latest observations, and formats current conditions including temperature, humidity, wind, etc.
    @mcp.tool()
    async def get_current_conditions(latitude: float, longitude: float) -> str:
        """Get current weather conditions for a location.
    
        Args:
            latitude: Latitude of the location (-90 to 90)
            longitude: Longitude of the location (-180 to 180)
        """
        if not validate_coordinates(latitude, longitude):
            return "Error: Invalid coordinates. Latitude must be between -90 and 90, longitude between -180 and 180."
    
        points_url = f"{NWS_API_BASE}/points/{latitude},{longitude}"
        points_data = await make_nws_request(points_url)
    
        if not points_data or "properties" not in points_data:
            return f"Unable to fetch weather data for coordinates ({latitude}, {longitude})."
    
        observation_url = points_data["properties"].get("observationStations")
        if not observation_url:
            return "No observation stations available for this location."
    
        # Get the nearest observation station
        stations_data = await make_nws_request(observation_url)
        if not stations_data or not stations_data.get("features"):
            return "No observation stations found for this location."
    
        station_id = stations_data["features"][0]["properties"]["stationIdentifier"]
        observations_url = f"{NWS_API_BASE}/stations/{station_id}/observations/latest"
        observations_data = await make_nws_request(observations_url)
    
        if not observations_data or "properties" not in observations_data:
            return "Unable to fetch current observations."
    
        props = observations_data["properties"]
        location_info = points_data["properties"].get("relativeLocation", {})
        location_str = f"{location_info.get('properties', {}).get('city', 'Unknown')}, {location_info.get('properties', {}).get('state', 'Unknown')}"
    
        temp = props.get("temperature", {}).get("value")
        temp_unit = "°C"
        if temp is not None:
            temp_f = (temp * 9/5) + 32
            temp_unit = f"°F ({temp:.1f}°C)"
    
        dewpoint = props.get("dewpoint", {}).get("value")
        humidity = props.get("relativeHumidity", {}).get("value")
        wind_speed = props.get("windSpeed", {}).get("value")
        wind_direction = props.get("windDirection", {}).get("value")
        pressure = props.get("barometricPressure", {}).get("value")
        visibility = props.get("visibility", {}).get("value")
        text_description = props.get("textDescription", "N/A")
    
        result = f"Current Conditions for {location_str}:\n\n"
        result += f"Temperature: {temp_f:.1f}{temp_unit}\n" if temp is not None else "Temperature: N/A\n"
        result += f"Conditions: {text_description}\n"
        result += f"Humidity: {humidity:.1f}%\n" if humidity is not None else ""
        result += f"Dewpoint: {dewpoint * 9/5 + 32:.1f}°F\n" if dewpoint is not None else ""
        result += f"Wind: {wind_speed * 2.237:.1f} mph from {wind_direction}°\n" if wind_speed is not None and wind_direction is not None else ""
        result += f"Pressure: {pressure / 100:.2f} hPa\n" if pressure is not None else ""
        result += f"Visibility: {visibility / 1609.34:.2f} miles\n" if visibility is not None else ""
    
        return result
  • weather.py:230-230 (registration)
    The @mcp.tool() decorator registers the get_current_conditions function as an MCP tool.
    @mcp.tool()
  • Helper function to validate input coordinates used by get_current_conditions.
    def validate_coordinates(latitude: float, longitude: float) -> bool:
        """Validate that coordinates are within valid ranges."""
        return -90 <= latitude <= 90 and -180 <= longitude <= 180
  • Helper function to make HTTP requests to NWS API endpoints, used multiple times in get_current_conditions.
    async def make_nws_request(url: str) -> dict[str, Any] | None:
        """Make a request to the NWS API with proper error handling."""
        headers = {
            "User-Agent": USER_AGENT,
            "Accept": "application/geo+json"
        }
        async with httpx.AsyncClient() as client:
            try:
                response = await client.get(url, headers=headers, timeout=30.0)
                response.raise_for_status()
                return response.json()
            except httpx.HTTPStatusError as e:
                if e.response.status_code == 404:
                    return None
                return None
            except (httpx.RequestError, httpx.TimeoutException):
                return None
            except Exception:
                return None
  • Docstring providing input schema description for the tool parameters.
    """Get current weather conditions for a location.
    
    Args:
        latitude: Latitude of the location (-90 to 90)
        longitude: Longitude of the location (-180 to 180)
    """
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. It states the tool 'Get[s] current weather conditions' but doesn't mention behavioral traits such as rate limits, authentication needs, error handling, or what the output contains. This leaves significant gaps for a tool that likely interacts with an external API.

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 appropriately sized and front-loaded, with the purpose stated clearly in the first sentence and parameter details following. It avoids unnecessary fluff, though the formatting with 'Args:' could be slightly more polished for readability.

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

Completeness3/5

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

Given the tool's moderate complexity (2 required parameters, no annotations, but with an output schema), the description is minimally adequate. It covers the purpose and parameter ranges but lacks behavioral context and usage guidelines. The presence of an output schema means return values don't need explanation, but other gaps remain.

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

Parameters4/5

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

The description adds meaningful context beyond the input schema by specifying valid ranges for latitude (-90 to 90) and longitude (-180 to 180), which aren't covered in the schema (0% description coverage). This compensates well for the schema's lack of detail, though it doesn't explain parameter interactions or units.

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 conditions for a location'), making it easy to understand what it does. However, it doesn't explicitly differentiate from sibling tools like 'get_forecast' or 'get_forecast_by_city', which prevents a perfect score.

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 'get_forecast' or 'get_forecast_by_city'. It lacks context about use cases, prerequisites, or exclusions, leaving the agent to infer usage from 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/zayedansari2/MCP_WeatherServer'

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