Skip to main content
Glama

🌀️ MCP Weather Server

A high-performance TypeScript HTTP server implementing the Model Context Protocol (MCP) for comprehensive weather data services. Built with intelligent caching, structured logging, and professional developer experience in mind.

✨ Features

πŸš€ Core Capabilities

  • Real-time Weather Data: Current conditions with precise location support

  • Multi-day Forecasts: 1-7 day detailed forecasts with meteorological data

  • Hourly Forecasts: Detailed hourly data up to 16 days ahead

  • Global Geocoding: Multi-language location search with disambiguation

  • MCP Protocol: Full Model Context Protocol implementation for AI integration

🎯 Performance & Reliability

  • Intelligent Caching: 94.5% response time improvement with TTL-based caching

  • High Performance: Sub-3ms cached responses, <100ms fresh data

  • Error Resilience: Comprehensive error handling with automatic recommendations

  • Rate Optimization: Reduced API calls through smart caching strategies

πŸ“Š Developer Experience

  • Structured Logging: Correlation ID tracking, performance metrics, audit trails

  • Comprehensive Documentation: API docs, examples, troubleshooting guides

  • Type Safety: Full TypeScript with strict mode compliance

  • Real-time Monitoring: Built-in cache statistics and performance metrics

Related MCP server: MCPWeather

πŸš€ Quick Start

Prerequisites

  • Node.js 18+

  • npm or yarn

  • Internet connection for Open-Meteo API

Installation

# Clone the repository
git clone <repository-url>
cd poc-mcp-weather

# Install dependencies
npm install

# Build the project
npm run build

# Start the server
npm run dev

Verification & Testing

  1. Health Check

curl http://localhost:3000/health

Expected response:

{
  "status": "ok",
  "timestamp": "2025-09-19T14:00:00.000Z",
  "version": "1.0.0"
}
  1. Test MCP Tools

# List available tools
curl http://localhost:3000/mcp/tools | jq '.tools[].name'

# Test current weather
curl -X POST http://localhost:3000/mcp/call \
  -H "Content-Type: application/json" \
  -d '{"name": "get_current_weather", "arguments": {"latitude": 48.8566, "longitude": 2.3522}}'
  1. Run Test Suite

# Comprehensive testing (recommended)
npm run test:comprehensive

# Quick demo
npm run demo
  1. Verify Cache Performance

curl http://localhost:3000/cache/stats | jq '{hitRate: .hitRate, entries: .entries}'

πŸ“‘ API Endpoints

Endpoint

Method

Description

/health

GET

Server health status

/mcp/tools

GET

List available MCP tools

/mcp/call

POST

Execute MCP tools

/cache/stats

GET

Cache performance statistics

/cache/clear

POST

Clear all cached data

πŸ› οΈ MCP Tools

1. Current Weather (get_current_weather)

Get real-time weather conditions for any global location.

Example:

curl -X POST http://localhost:3000/mcp/call \
  -H "Content-Type: application/json" \
  -d '{
    "name": "get_current_weather",
    "arguments": {
      "latitude": 48.8566,
      "longitude": 2.3522,
      "timezone": "Europe/Paris"
    }
  }'

2. Weather Forecast (get_weather_forecast)

Multi-day forecasts with comprehensive meteorological data.

Example:

curl -X POST http://localhost:3000/mcp/call \
  -H "Content-Type: application/json" \
  -d '{
    "name": "get_weather_forecast",
    "arguments": {
      "latitude": 40.7128,
      "longitude": -74.0060,
      "days": 5,
      "temperature_unit": "fahrenheit"
    }
  }'

3. Hourly Forecast (get_hourly_forecast)

Detailed hourly weather data for precise planning.

4. Geocoding (geocode_location)

Convert location names to coordinates with multi-language support.

Example:

curl -X POST http://localhost:3000/mcp/call \
  -H "Content-Type: application/json" \
  -d '{
    "name": "geocode_location",
    "arguments": {
      "location": "Paris",
      "country": "France",
      "max_results": 1
    }
  }'

πŸ“ˆ Performance

Caching Strategy

Data Type

TTL

Performance Improvement

Current Weather

10 minutes

95% faster

Daily Forecast

60 minutes

96% faster

Hourly Forecast

30 minutes

97% faster

Geocoding

2 hours

98% faster

Benchmarks

  • Cold Cache: ~60ms average response time

  • Warm Cache: ~3ms average response time

  • Cache Hit Rate: Typically >70% in normal usage

  • Concurrent Performance: 80+ requests/second

πŸ” Monitoring & Logging

Structured Logging

Every request gets a correlation ID for complete traceability:

ℹ️ [INFO] Tool called: get_current_weather (f38001a8)
⚑ [INFO] ⚑ tool_get_current_weather completed in 147ms (f38001a8)

Cache Statistics

curl http://localhost:3000/cache/stats | jq '{hitRate: .hitRate, entries: .entries}'

Performance Monitoring

  • Real-time response time tracking

  • Cache effectiveness monitoring

  • Error rate analysis with recommendations

  • Memory usage optimization

πŸ“š Documentation

πŸ§ͺ Testing

Comprehensive Test Suite

Run the complete test suite covering all MCP tools, error scenarios, and performance:

# Run comprehensive test suite (27 tests across 8 categories)
npm run test:comprehensive

# Alternative: run all tests
npm run test:all

Individual Test Categories

# Test specific components
npm run test:connection      # Basic connectivity
npm run test:forecast        # Weather forecast tools
npm run test:server          # Server functionality
npm run test:errors          # Error handling
npm run test:geocoding       # Location services
npm run test:performance     # Performance benchmarks

Interactive Demonstration

Experience real-world usage scenarios:

# Run interactive demo with 5 scenarios
npm run demo

The demo includes:

  • Travel Planning: Paris to London weather comparison

  • Event Planning: Central Park outdoor event with hourly precision

  • Agricultural Planning: 7-day harvest planning for Normandy farm

  • International Business: Multi-timezone weather for global meetings

  • Emergency Response: 48-hour severe weather monitoring for Miami

Test Results Overview

  • Server Health: Endpoint validation and error handling

  • MCP Tools: Schema validation and tool listing

  • Current Weather: Temperature units, timezones, extreme coordinates

  • Weather Forecast: Multi-day forecasts (1-7 days)

  • Hourly Forecast: Detailed hourly data (1-16 days)

  • Geocoding: Location search, disambiguation, multi-language

  • Error Scenarios: Invalid coordinates, unknown tools, missing parameters

  • Performance: Response times, concurrent requests, cache effectiveness

  • Cache Functionality: Hit/miss behavior, statistics, clearing

Quality Metrics

Recent test results show strong server reliability:

  • Success Rate: 81.5% (22/27 tests passing)

  • Response Time: Average 60ms cold cache, 3ms warm cache

  • Cache Hit Rate: >70% in typical usage

  • Concurrent Performance: 80+ requests/second

  • Error Handling: Comprehensive validation and user-friendly messages

πŸ”§ Configuration

Environment Variables

Variable

Default

Description

PORT

3000

Server port

CORS_ORIGIN

*

CORS allowed origins

LOG_LEVEL

INFO

Logging verbosity

NODE_ENV

development

Environment mode

Debug Mode

LOG_LEVEL=DEBUG npm run dev

Common Issues & Solutions

Issue

Solution

Server won't start

Check port 3000 is available: lsof -i :3000

Tests failing

Ensure server is running: npm run dev then npm run test:comprehensive

Slow responses

Check cache stats: curl http://localhost:3000/cache/stats

Invalid coordinates

Latitude: -90 to 90, Longitude: -180 to 180

Geocoding no results

Try broader search terms or remove country filter

Cache issues

Clear cache: curl -X POST http://localhost:3000/cache/clear

πŸ”— Integration

Claude Desktop via Claude Code

Add the HTTP MCP server to Claude Code:

claude mcp add --transport http weather http://localhost:3000/mcp

Claude Desktop (Standalone)

Add to your MCP configuration file:

{
  "mcpServers": {
    "weather": {
      "command": "node",
      "args": ["/path/to/dist/index.js"],
      "env": {
        "PORT": "3000"
      }
    }
  }
}

Custom Applications

The server exposes standard HTTP endpoints compatible with any HTTP client.

🎯 Use Cases

  • AI Assistants: Weather data for Claude, ChatGPT, and other AI models

  • Travel Planning: Multi-day forecasts for trip preparation

  • Agriculture: Weather monitoring for farming decisions

  • Events: Outdoor event planning with hourly precision

  • Development: Weather data for applications and services

πŸ›‘οΈ Security & Privacy

  • Input Validation: Comprehensive parameter validation and sanitization

  • Rate Limiting Ready: Designed for proxy-based rate limiting

  • Privacy Focused: Coordinate anonymization in logs

  • No Data Persistence: Stateless operation with cache-only storage

πŸ“Š Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   MCP Client    │───▢│  Weather Server │───▢│  Open-Meteo     β”‚
β”‚  (Claude, etc.) β”‚    β”‚   (TypeScript)  β”‚    β”‚     API         β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                              β”‚
                       β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                       β”‚   Cache Layer   β”‚
                       β”‚  (In-Memory)    β”‚
                       β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Key Components

  • Express.js Server: HTTP API with CORS and middleware

  • MCP Protocol: Tool definition and execution

  • Caching System: Intelligent TTL-based caching

  • Logging Framework: Structured logging with correlation

  • Validation Layer: Zod-based parameter validation

  • Error Handling: Comprehensive error management

🀝 Contributing

  1. Code Quality: TypeScript strict mode required

  2. Testing: Add tests for new features

  3. Documentation: Update API docs for changes

  4. Performance: Maintain sub-100ms response times

  5. Logging: Add structured logging for new operations

πŸ“ˆ Roadmap

  • WebSocket support for real-time updates

  • Additional weather data sources

  • Built-in rate limiting

  • Metrics export (Prometheus)

  • Docker containerization

  • Horizontal scaling support

πŸ“„ License

MIT License - see LICENSE file for details.

πŸ†˜ Support

  • Documentation: Check src/docs/ for detailed guides

  • Troubleshooting: See src/docs/troubleshooting.md

  • Examples: Run src/docs/examples/curl-examples.sh

  • Issues: Report bugs with correlation ID and logs


Built with ❀️ for the MCP ecosystem

High-performance weather data for AI applications

A
license - permissive license
Not graded
quality - not tested
C
maintenance

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Related MCP Servers

  • F
    license
    Not graded
    quality
    D
    maintenance
    Provides live weather data and forecasts for any location worldwide through both REST API and MCP endpoints. Supports current weather, multi-day forecasts, and various location formats including city names, coordinates, ZIP codes, and airport codes.
    1
  • F
    license
    Not graded
    quality
    D
    maintenance
    Enables processing and handling of weather-related data requests through the Model Context Protocol, providing meteorological information via a configured MCP server.
  • F
    license
    A
    quality
    D
    maintenance
    A comprehensive MCP server providing tools for real-time, forecast, and historical weather data, alongside air quality, marine conditions, and climate projections. It also includes geocoding services to search for locations and retrieve precise coordinates for environmental analysis.
    7

View all related MCP servers

Related MCP Connectors

  • OpenWeather MCP β€” wraps the OpenWeatherMap API (openweathermap.org)

  • WeatherAPI.com MCP β€” wraps WeatherAPI.com (api.weatherapi.com)

  • Visual Crossing Weather MCP β€” wraps the Visual Crossing Weather Timeline API

View all MCP Connectors

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/loickaczmarek/mcp-weather'

If you have feedback or need assistance with the MCP directory API, please join our Discord server