MCP Weather Server

MCP Weather Server

Provides weather forecasts, alerts, and current conditions via the Model Context Protocol, using simulated data and supporting both stdio and HTTP transports.

Category
Visit Server

README

🌀️ MCP Weather Server

A production-ready Model Context Protocol weather server built with the official Anthropic FastMCP Python SDK. Provides weather forecasts, alerts, and current conditions through a standardized AI-agent interface.

License: MIT Python 3.10+ MCP SDK


✨ Features

  • πŸ”§ 2 Tools: get_alerts (weather alerts by state) and get_forecast (5-day forecast by coordinates)
  • πŸ“„ 1 Resource: weather://{state}/current β€” formatted current conditions
  • πŸ’¬ 1 Prompt: weather_assistant(state) β€” guided weather analysis template
  • πŸ”Œ Dual Transport: stdio (local clients) and Streamable HTTP (remote clients)
  • πŸͺ΅ Structured Logging: All server logs go to stderr (compatible with stdio transport)
  • πŸ“¦ No API Keys Required: Uses realistic simulated weather data
  • πŸ§ͺ Test Client Included: Ready-to-run example client

πŸš€ Quick Start

Option 1: pip

python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
python weather_server.py

Option 2: uv (recommended)

uv venv
source .venv/bin/activate
uv add "mcp[cli]>=1.27,<2" httpx
python weather_server.py

Option 3: Setup script

chmod +x setup.sh
./setup.sh
python weather_server.py

πŸ“‹ Usage

stdio Transport (default)

python weather_server.py

The server listens on stdin/stdout, ready to connect to Claude Desktop, Cursor, or any MCP client.

Streamable HTTP Transport

python weather_server.py --transport streamable-http --port 8000

Now available at http://localhost:8000/mcp for HTTP-based clients.

Run the Test Client

# In one terminal:
python weather_server.py

# In another terminal:
source .venv/bin/activate
python client_example.py

πŸ› οΈ Tools Reference

get_alerts(state: str) -> list[dict]

Get active weather alerts for a US state.

Parameter Type Description Example
state str 2-letter US state code "CA", "TX", "FL"

Returns: List of alerts with type, severity, and area.

get_forecast(latitude: float, longitude: float) -> list[dict]

Get a 5-day weather forecast for coordinates.

Parameter Type Description
latitude float Decimal degrees (-90 to 90)
longitude float Decimal degrees (-180 to 180)

Returns: 5-day forecast with date, temperature_f, condition, humidity_pct, wind_mph.


πŸ“„ Resources Reference

weather://{state}/current

Returns formatted current weather conditions for a state as markdown.


πŸ’¬ Prompts Reference

weather_assistant(state: str)

Creates a weather analysis assistant prompt template.

Parameter Type Description
state str 2-letter US state code

πŸ”Œ Connecting to Clients

Claude Desktop

Add to your claude_desktop_config.json:

{
  "mcpServers": {
    "weather": {
      "command": "python",
      "args": ["/ABSOLUTE/PATH/TO/mcp-weather-server/weather_server.py"]
    }
  }
}

Cursor

In Cursor Settings β†’ Features β†’ MCP Servers, add:

  • Name: weather
  • Type: command
  • Command: python /ABSOLUTE/PATH/TO/mcp-weather-server/weather_server.py

HTTP Client (Streamable HTTP)

curl -X POST http://localhost:8000/mcp \
  -H "Content-Type: application/json" \
  -d '{"jsonrpc":"2.0","id":"1","method":"tools/list","params":{}}'

πŸ“ Project Structure

mcp-weather-server/
β”œβ”€β”€ weather_server.py      # Main server implementation
β”œβ”€β”€ client_example.py      # Example MCP client
β”œβ”€β”€ requirements.txt       # Python dependencies
β”œβ”€β”€ setup.sh              # Automated setup script
β”œβ”€β”€ README.md             # This file
└── .gitignore

🧠 Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     stdio/HTTP      β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  MCP Client  β”‚ ◄──────────────►  β”‚  Weather Server   β”‚
β”‚ (Claude, etc)β”‚                    β”‚  (FastMCP)        β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                           β”‚
                                    β”Œβ”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”
                                    β”‚  Simulated   β”‚
                                    β”‚  Weather Dataβ”‚
                                    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸ“œ License

MIT β€” see LICENSE for details.

πŸ™Œ Contributing

PRs welcome! Please ensure tools have proper type hints and docstrings.

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