Skip to main content
Glama

get_forecast

Retrieve detailed weather forecasts for a specific location by providing latitude and longitude coordinates using the MCP Weather Server.

Instructions

Get weather forecast for a location. Args: latitude: Latitude of the location longitude: Longitude of the location

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
latitudeYes
longitudeYes

Implementation Reference

  • The handler function for the 'get_forecast' tool. It takes latitude and longitude, returns a formatted string of hardcoded weather forecasts.
    @mcp.tool() def get_forecast(latitude: float, longitude: float) -> str: """Get weather forecast for a location. Args: latitude: Latitude of the location longitude: Longitude of the location """ forecasts = [ { "name": "This Afternoon", "temperature": "68°F", "wind": "18 mph WSW", "forecast": "Sunny. High near 68, with temperatures falling to around 66 in the afternoon. West southwest wind around 18 mph, with gusts as high as 23 mph." }, { "name": "Tonight", "temperature": "55°F", "wind": "8 to 17 mph WSW", "forecast": "Mostly clear, with a low around 55. West southwest wind 8 to 17 mph, with gusts as high as 22 mph." }, ] # Hardcode replace it with you api , you can call https://api.weather.gov ... return format_forecast(forecasts)
  • Helper function used by get_forecast to format the forecast data into a readable string.
    def format_forecast(forecasts: List[Dict]) -> str: """ Format a list of forecast dictionaries into a readable string. """ return "\n---\n".join( f"{f['name']}:\nTemperature: {f['temperature']}\nWind: {f['wind']}\nForecast: {f['forecast']}" for f in forecasts )
  • The @mcp.tool() decorator registers the get_forecast function as an MCP tool.
    @mcp.tool()
  • Type hints defining the input schema (latitude: float, longitude: float) and output (str).
    def get_forecast(latitude: float, longitude: float) -> str:

Other Tools

Related 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/jeannassereldine/mcp-server'

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