Philip-Walsh

Weather MCP Service

Community Philip-Walsh
Updated

A lightweight weather service that provides live data and forecasts over REST and MCP, with built-in database caching to reduce API calls

Weather MCP Service

A lite weather service providing live weather data and forecasts via both REST API and MCP (Model Context Protocol) endpoints.

A minimal, production-ready weather service designed for local deployment with dual protocol support and comprehensive monitoring.

TypeScriptNode.jsDocker

Quick Start

# Clone & install
git clone <repo-url>
cd weather-mcp-db
npm install

# Set up environment
cp .env.example .env
# Add your WeatherAPI.com key to .env
# Get your free API key at: https://www.weatherapi.com/

# Run
npm run dev

Server runs on: http://localhost:3000

Weather Data Source

This service uses WeatherAPI.com for weather data, which provides:

  • Real-time weather data for any location worldwide
  • 14-day weather forecasts with hourly and daily intervals
  • Historical weather data going back to 2010
  • Air quality data and weather alerts
  • Free tier with 1 million calls per month
  • Reliable uptime and fast response times

Getting Your API Key

  1. Visit WeatherAPI.com
  2. Click "Get Started" or "Sign Up"
  3. Create a free account (no credit card required)
  4. Copy your API key from the dashboard
  5. Add it to your .env file: WEATHER_API_KEY=your_key_here

πŸ“– Documentation: WeatherAPI.com Docs

API

REST Endpoints

GET  /api/weather?city=London     # Current weather
GET  /api/forecast?city=London    # 3-day forecast
GET  /api/local                   # Default location
GET  /api/health                  # Health check

Supported Query Formats:

  • City names: London, New York, Tokyo
  • Coordinates: 48.8567,2.3508 (lat,lon)
  • US ZIP codes: 10001, 90210
  • UK postcodes: SW1, M1 1AA
  • Airport codes: LHR, JFK (via IATA)
  • IP addresses: auto:ip for IP lookup

MCP Protocol

POST /mcp                         # MCP JSON-RPC 2.0

Available Tools:

  • get_weather - Current weather for a city
  • get_forecast - Weather forecast (1-10 days)
  • get_local_weather - Default location weather

Usage

REST API

# Current weather
curl "http://localhost:3000/api/weather?city=London"

# Forecast (1-14 days)
curl "http://localhost:3000/api/forecast?city=London&days=5"

# Default location weather
curl "http://localhost:3000/api/local"

# Health check
curl "http://localhost:3000/api/health"

MCP Protocol

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

# Get weather
curl -X POST http://localhost:3000/mcp \
  -H "Content-Type: application/json" \
  -d '{"jsonrpc":"2.0","id":2,"method":"tools/call","params":{"name":"get_weather","arguments":{"city":"London"}}}'

Development

npm run dev          # Development server
npm run build        # Build for production
npm run mcp          # Standalone MCP server (stdio)
npm test             # Run tests
npm run lint         # Lint code

Deployment

Docker

# Local development
docker-compose up -d

# Production
docker build -t weather-mcp-db .
docker run -p 3000:3000 -e WEATHER_API_KEY=your_key weather-mcp-db

Kubernetes

# Using Helm
helm install weather-service ./helm/weather-service \
  --set env.WEATHER_API_KEY=your_key

Configuration

Variable Default Description
WEATHER_API_KEY - WeatherAPI.com key (required)
DEFAULT_LOCATION London Default city
TEMP_UNIT C Temperature unit
PORT 3000 Server port

Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ REST Client β”‚    β”‚ MCP Client  β”‚
β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”˜
       β”‚                  β”‚
       β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜
                  β”‚
         β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”
         β”‚ Express Server  β”‚
         β”‚ /api + /mcp     β”‚
         β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                  β”‚
         β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”
         β”‚ Weather Service β”‚
         β”‚ WeatherAPI.com  β”‚
         β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Features

  • βœ… Dual Protocol - REST + MCP in one server
  • βœ… Official MCP SDK - @modelcontextprotocol/sdk
  • βœ… TypeScript - Full type safety
  • βœ… Security - Rate limiting, validation, headers
  • βœ… Monitoring - Health checks, metrics, logging
  • βœ… Testing - 68 tests (unit, integration, e2e)
  • βœ… Docker - Multi-stage build with nginx
  • βœ… Kubernetes - Helm charts included

License

MIT

MCP Server Β· Populars

MCP Server Β· New

    dylanroscover

    πŸ’¬ Embody

    Have a conversation with TouchDesigner

    Community dylanroscover
    Swap-API

    Swap API

    MCP Server

    Community Swap-API
    juyterman1000

    Entroly

    Entroly helps AI coding tools like Cursor, Copilot, and Claude Code use the right context from your entire codebaseβ€”improving output quality while reducing token usage.

    Community juyterman1000
    unbrowse-ai

    Unbrowse

    Unbrowse β€” api native browser skill/cli for any agent. Auto-discovers APIs from browser traffic, generates skills on the fly to call APIs directly 100x faster, 80% cheaper locally.

    Community unbrowse-ai
    campfirein

    ByteRover CLI

    ByteRover CLI (brv) - The portable memory layer for autonomous coding agents (formerly Cipher)

    Community campfirein