weather-mcp

salman-aziz-4425/weather-mcp

3.2

If you are the rightful owner of weather-mcp and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to dayong@mcphub.com.

An MCP server providing weather data tools and resources using the National Weather Service API.

Tools
3
Resources
0
Prompts
0

MCP Weather Project

An MCP (Model Context Protocol) server that provides weather data tools and resources using the National Weather Service API. The server includes weather alerts, forecasts, and a RAG-based search system for historical weather data.

Features

  • Weather Alerts: Get active weather alerts for any US state
  • Weather Forecasts: Retrieve detailed forecasts for any location using latitude and longitude
  • Historical Search: Search stored weather data using RAG (Retrieval Augmented Generation)
  • Data Storage: Automatically stores all fetched weather data for future reference
  • MCP Resources: Access stored alerts, forecasts, and recent weather data through MCP resources

Installation

  1. Ensure you have Python 3.13+ installed
  2. Install dependencies using uv:
uv sync

Usage

Running the Server

Start the MCP server:

uv run python main.py

Available Tools

get_alerts(state: str)

Retrieves active weather alerts for a US state. Provide a two-letter state code (e.g., "CA", "NY", "TX").

get_forecast(latitude: float, longitude: float)

Gets a detailed weather forecast for a specific location. Provide latitude and longitude coordinates.

search_weather_history(query: str, limit: int = 5)

Searches through stored weather data using keyword matching. Returns up to limit results matching the query.

Available Resources

  • weather://alerts - Lists all stored weather alerts
  • weather://forecasts - Lists all stored weather forecasts
  • weather://recent - Shows recent weather data entries

Testing

Run the test script to verify the server is working:

uv run python test_server.py

Project Structure

  • main.py - Main MCP server entry point
  • weather.py - Weather tool implementations
  • storage.py - Data storage and RAG search functionality
  • utils.py - Utility functions for API requests
  • test_server.py - Test script for the MCP server
  • weather_data.json - JSON file storing weather data

Dependencies

  • fastapi[standard] - Web framework
  • httpx - HTTP client for API requests
  • mcp[cli] - Model Context Protocol implementation

License

This project is provided as-is for educational and development purposes.