Weather MCP Server

Weather MCP Server

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.

Category
Visit Server

README

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

  1. Clone and navigate to the project:

    cd /opt/projects/mcp-hack/weather
    
  2. Install dependencies:

    uv sync
    

Configuration

The server uses a hardcoded Brave Search API key. If you want to use your own API key, you can:

  1. Get a free API key from Brave Search API
  2. Update the BRAVE_API_KEY constant in weather.py

Running the Server

Method 1: Direct Python execution

uv run python weather.py

Method 2: Using the main module

uv run python main.py

Method 3: Using uv with module execution

uv run -m weather

Usage Examples

Once the server is running, you can use the following tools:

Weather Tools

# Get weather alerts for California
get_alerts("CA")

# Get forecast for San Francisco (37.7749, -122.4194)
get_forecast(37.7749, -122.4194)

Search Tool

# Search the web with default 3 results
brave_search("python programming tutorials")

# Search with custom result count
brave_search("weather forecast San Francisco", 5)

Math Tool

# Add two numbers
add_numbers(15.5, 24.3)

Prompts

# Get weather-based event suggestions
suggest_events("San Francisco")
# or with coordinates
suggest_events("37.7749,-122.4194")

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

weather/
├── weather.py          # Main MCP server with all tools
├── main.py            # Alternative entry point
├── pyproject.toml     # Project dependencies
├── uv.lock           # Dependency lock file
└── README.md         # This file

Adding New Tools

To add new tools, follow the FastMCP pattern:

@mcp.tool()
async def your_tool_name(param1: str, param2: int = 10) -> str:
    """Tool description.
    
    Args:
        param1: Description of parameter 1
        param2: Description of parameter 2 (default: 10)
    """
    # Your tool logic here
    return "Tool result"

Troubleshooting

Common Issues

  1. "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 in weather.py
  2. Weather API errors

    • Ensure you're using valid US state codes (2 letters) for alerts
    • Verify latitude/longitude coordinates are valid for forecasts
  3. Import errors

    • Run uv sync to ensure all dependencies are installed
    • Make sure you're using Python 3.11 or higher

Dependencies

Key dependencies include:

  • fastmcp: MCP server framework
  • httpx: HTTP client for API requests
  • langchain-community: Brave Search integration
  • langchain-core: Core LangChain functionality

License

This project is part of the MCP hack and is provided as-is for educational and development purposes.

Recommended Servers

playwright-mcp

playwright-mcp

A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.

Official
Featured
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.

Official
Featured
Local
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.

Official
Featured
Local
TypeScript
VeyraX MCP

VeyraX MCP

Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.

Official
Featured
Local
graphlit-mcp-server

graphlit-mcp-server

The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.

Official
Featured
TypeScript
Kagi MCP Server

Kagi MCP Server

An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.

Official
Featured
Python
E2B

E2B

Using MCP to run code via e2b.

Official
Featured
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
Exa Search

Exa Search

A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.

Official
Featured
Qdrant Server

Qdrant Server

This repository is an example of how to create a MCP server for Qdrant, a vector search engine.

Official
Featured