Skip to main content
Glama
Sukruthr

Weather MCP Server

by Sukruthr

fetch_weather

Retrieve current weather conditions and temperature data for any specified location worldwide using real-time weather information.

Instructions

Get weather information for a given location

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
locationYes

Implementation Reference

  • main.py:7-13 (handler)
    The handler function for the 'fetch_weather' tool, registered via @mcp.tool() decorator. It takes a location string and returns the weather by delegating to the get_weather helper.
    @mcp.tool() async def fetch_weather(location: str) -> str: """ Get weather information for a given location """ return get_weather(location)
  • Helper function containing the core logic to fetch weather data from wttr.in API using urllib, with error handling.
    def get_weather(location:str) -> str: """ fetches the weather for a given location, example: "London, new-york, San-francisco, etc." Args: location(str): the city or location name to fetch the weather for. Returns: str: a string containing the weather for the location """ try: url = f"https://wttr.in/{location}?format=3" with urllib.request.urlopen(url) as response: result = response.read().decode('utf-8').strip() return result except Exception as e: return f"Error fetching weather: {e}"

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/Sukruthr/weather-mcp'

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