mcp-server-weather-py

srjv11/mcp-server-weather-py

3.2

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

The Weather MCP Server is a production-ready server that provides weather data from the National Weather Service API, featuring caching, monitoring, robust error handling, and comprehensive testing.

Tools
  1. get_alerts

    Get weather alerts with optional severity filtering

  2. get_forecast

    Get weather forecast for specific coordinates

  3. get_location_forecast

    Get weather forecast by city and state

  4. health_check

    Check server health and performance metrics

Weather MCP Server

Build Status Coverage Python 3.13 Docker MCP

A comprehensive, production-ready MCP (Model Context Protocol) server providing weather data from the National Weather Service API with caching, monitoring, robust error handling, and comprehensive testing.

๐Ÿš€ Quick Start

# Install dependencies
uv sync --group dev

# Run the weather MCP server
uv run weather-mcp
# or
uv run -m src.main

# Run tests
uv run pytest tests/ -v

# Run code quality checks
ruff check --fix && ruff format

๐Ÿ“ Project Structure

mcp-server-weather-py/
โ”œโ”€โ”€ ๐Ÿ“„ Core Application
โ”‚   โ””โ”€โ”€ src/
โ”‚       โ”œโ”€โ”€ main.py              # Main entry point
โ”‚       โ”œโ”€โ”€ client.py            # HTTP client with caching
โ”‚       โ”œโ”€โ”€ config.py            # Configuration management
โ”‚       โ”œโ”€โ”€ exceptions.py        # Custom exception classes
โ”‚       โ”œโ”€โ”€ formatters.py        # Data formatting utilities
โ”‚       โ”œโ”€โ”€ models.py            # Data models and types
โ”‚       โ”œโ”€โ”€ tools.py             # MCP tools implementation
โ”‚       โ”œโ”€โ”€ validators.py        # Input validation
โ”‚       โ””โ”€โ”€ weather.py           # Alternative entry point
โ”‚
โ”œโ”€โ”€ ๐Ÿงช Testing & Quality
โ”‚   โ””โ”€โ”€ tests/
โ”‚       โ”œโ”€โ”€ test_client.py       # HTTP client tests
โ”‚       โ”œโ”€โ”€ test_config.py       # Configuration tests
โ”‚       โ”œโ”€โ”€ test_exceptions.py   # Exception handling tests
โ”‚       โ”œโ”€โ”€ test_formatters.py   # Data formatting tests
โ”‚       โ”œโ”€โ”€ test_models.py       # Data model tests
โ”‚       โ”œโ”€โ”€ test_tools.py        # MCP tools tests
โ”‚       โ”œโ”€โ”€ test_validators.py   # Validation tests
โ”‚       โ””โ”€โ”€ test_weather.py      # Main module tests
โ”‚
โ”œโ”€โ”€ ๐Ÿณ Deployment
โ”‚   โ”œโ”€โ”€ Dockerfile               # Container configuration
โ”‚   โ”œโ”€โ”€ docker-compose.yml       # Multi-service orchestration
โ”‚   โ””โ”€โ”€ .dockerignore            # Container build optimization
โ”‚
โ”œโ”€โ”€ ๐Ÿ“š Configuration & Documentation
โ”‚   โ”œโ”€โ”€ pyproject.toml           # Package configuration & dependencies
โ”‚   โ”œโ”€โ”€ CLAUDE.md                # Development guide
โ”‚   โ”œโ”€โ”€ MCP_SETUP.md             # MCP integration guide
โ”‚   โ””โ”€โ”€ docs/README_ENHANCED.md  # Detailed enhancement documentation
โ”‚
โ””โ”€โ”€ ๐Ÿ“„ Examples & Utilities
    โ”œโ”€โ”€ examples.py              # Usage examples & demos
    โ”œโ”€โ”€ example_state_machine.py # Educational state machine example
    โ””โ”€โ”€ setup_script.py          # Setup automation script

โœจ Features

  • ๐Ÿ›ก๏ธ Robust Error Handling: Custom exception hierarchy with retry logic
  • โšก Performance: In-memory caching with TTL and rate limiting
  • ๐Ÿ“Š Monitoring: Health checks and structured logging
  • ๐Ÿงช Comprehensive Testing: 95%+ test coverage across 8 modules
  • ๐Ÿณ Production Ready: Docker support and deployment configs
  • ๐Ÿ”ง Configurable: Environment-based configuration
  • ๐ŸŒ MCP Integration: Ready for Claude Code integration

๐Ÿ› ๏ธ API Reference

Core MCP Tools

  • get_alerts(state, severity_filter=None): Get weather alerts with optional severity filtering
  • get_forecast(latitude, longitude): Get weather forecast for specific coordinates
  • get_location_forecast(city, state): Get weather forecast by city and state
  • health_check(): Check server health and performance metrics

๐Ÿงช Testing

# Run all tests with coverage
uv run pytest tests/ -v --cov=. --cov-report=html

# Run specific test modules
uv run pytest tests/test_validators.py -v
uv run pytest tests/test_tools.py -v

Test Coverage: 46 tests across 8 modules covering validation, data models, HTTP client, MCP tools, formatting, exceptions, and configuration.

๐Ÿณ Deployment

Local Development

uv sync --group dev
uv run weather-mcp

Docker Deployment

docker build -t weather-mcp .
docker run -it weather-mcp

Production with Docker Compose

docker-compose up -d

๐Ÿ”— MCP Integration

Connect to Claude Code for interactive weather queries. See MCP_SETUP.md for complete setup instructions.

๐Ÿ“š Documentation

Quick Reference

  • CLAUDE.md: Development guide with commands and architecture details
  • MCP_SETUP.md: Claude Code integration instructions
  • examples.py: Interactive usage demonstrations

Comprehensive Documentation


Weather MCP Server - Production-ready weather data for Large Language Models ๐ŸŒค๏ธ