Weather MCP Server
A Model Context Protocol (MCP) server that provides weather information, web search capabilities, and basic math operations using FastMCP.
Features
š¤ļø Weather Tools
get_alerts: Get weather alerts for any US state
get_forecast: Get detailed weather forecast for any location (latitude/longitude)
š Search Tools
brave_search: Search the web using Brave Search API
add_numbers: Add two numbers together
š” Prompts
suggest_events: Get comprehensive weather data and event suggestions for a location
Prerequisites
Python 3.11 or higher
uv package manager
Brave Search API key (free from Brave Search API)
Installation
Clone and navigate to the project:
cd /opt/projects/mcp-hack/weatherInstall dependencies:
uv sync
Configuration
The server uses a hardcoded Brave Search API key. If you want to use your own API key, you can:
Get a free API key from Brave Search API
Update the
BRAVE_API_KEY
constant inweather.py
Running the Server
Method 1: Direct Python execution
Method 2: Using the main module
Method 3: Using uv with module execution
Usage Examples
Once the server is running, you can use the following tools:
Weather Tools
Search Tool
Math Tool
Prompts
API Integration
This server integrates with:
National Weather Service API: For weather data and alerts
Brave Search API: For web search functionality
FastMCP: For MCP server implementation
LangChain Community: For Brave Search tool integration
Development
Project Structure
Adding New Tools
To add new tools, follow the FastMCP pattern:
Troubleshooting
Common Issues
"BRAVE_SEARCH_API_KEY environment variable not set"
The API key is hardcoded in the server, but if you see this error, check that
BRAVE_API_KEY
is properly set inweather.py
Weather API errors
Ensure you're using valid US state codes (2 letters) for alerts
Verify latitude/longitude coordinates are valid for forecasts
Import errors
Run
uv sync
to ensure all dependencies are installedMake sure you're using Python 3.11 or higher
Dependencies
Key dependencies include:
fastmcp
: MCP server frameworkhttpx
: HTTP client for API requestslangchain-community
: Brave Search integrationlangchain-core
: Core LangChain functionality
License
This project is part of the MCP hack and is provided as-is for educational and development purposes.
This server cannot be installed
remote-capable server
The server can be hosted and run remotely because it primarily relies on remote services or has no dependency on the local environment.
Provides weather information including alerts and forecasts for any location, web search capabilities through Brave Search API, and basic math operations. Includes weather-based event suggestions to help users plan activities based on current conditions.