MCP Weather Server

MCP Weather Server

Provides real-time weather forecasts and active weather alerts for US locations using the National Weather Service API. It enables users to retrieve detailed local forecasts via coordinates and monitor state-specific weather warnings.

Category
Visit Server

README

MCP WEATHER SERVER WRITTEN IN TYPESCRIPT

Protocol Map

This weather MCP server implements the Model Context Protocol (MCP) to provide weather data through a standardized interface. Below is the complete protocol mapping showing how the server communicates with MCP clients.

Server Information

Capabilities

{
  "capabilities": {
    "tools": {
      "listChanged": true
    }
  }
}

Tools

The server exposes two tools for weather data retrieval:

1. get_alerts

Retrieves active weather alerts for a US state.

Input Schema:

{
  "type": "object",
  "properties": {
    "state": {
      "type": "string",
      "description": "Two-letter US state code (e.g. CA, NY)",
      "minLength": 2,
      "maxLength": 2
    }
  },
  "required": ["state"]
}

Example Request:

{
  "method": "tools/call",
  "params": {
    "name": "get_alerts",
    "arguments": {
      "state": "CA"
    }
  }
}

Example Response:

{
  "content": [
    {
      "type": "text",
      "text": "Event: Heat Advisory\nArea: Los Angeles County\nSeverity: Moderate\nDescription: Dangerously hot conditions...\nInstructions: Drink plenty of fluids..."
    }
  ]
}

Error Response:

{
  "content": [
    {
      "type": "text",
      "text": "Unable to fetch alerts or no alerts found."
    }
  ]
}

2. get_forecast

Retrieves weather forecast for a specific location using latitude and longitude coordinates.

Input Schema:

{
  "type": "object",
  "properties": {
    "latitude": {
      "type": "number",
      "description": "Latitude of the location",
      "minimum": -90,
      "maximum": 90
    },
    "longitude": {
      "type": "number",
      "description": "Longitude of the location",
      "minimum": -180,
      "maximum": 180
    }
  },
  "required": ["latitude", "longitude"]
}

Example Request:

{
  "method": "tools/call",
  "params": {
    "name": "get_forecast",
    "arguments": {
      "latitude": 38.5816,
      "longitude": -121.4944
    }
  }
}

Example Response:

{
  "content": [
    {
      "type": "text",
      "text": "Tonight:\nTemperature: 65°F\nWind: 5 mph SW\nForecast: Partly cloudy with a slight chance of showers.\n---\nTomorrow:\nTemperature: 78°F\nWind: 10 mph W\nForecast: Sunny skies throughout the day."
    }
  ]
}

Error Responses:

{
  "content": [
    {
      "type": "text",
      "text": "Failed to retrieve grid point data for coordinates: 38.5816, -121.4944. This location may not be supported by the NWS API (only US locations are supported)."
    }
  ]
}

Communication Flow

sequenceDiagram
    participant Client as MCP Client (Claude)
    participant Server as Weather Server
    participant NWS as National Weather Service API

    Client->>Server: Initialize Connection (STDIO)
    Server->>Client: Server Info + Capabilities
    
    Client->>Server: List Tools
    Server->>Client: [get_alerts, get_forecast]
    
    Client->>Server: Call Tool: get_forecast(lat, lon)
    Server->>NWS: GET /points/{lat},{lon}
    NWS->>Server: Grid Point Data
    Server->>NWS: GET {forecast_url}
    NWS->>Server: Forecast Data
    Server->>Client: Formatted Forecast Text
    
    Client->>Server: Call Tool: get_alerts(state)
    Server->>NWS: GET /alerts/active/area/{state}
    NWS->>Server: Active Alerts
    Server->>Client: Formatted Alerts Text

Protocol Messages

Initialization

Client → Server:

{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "initialize",
  "params": {
    "protocolVersion": "2024-11-05",
    "capabilities": {},
    "clientInfo": {
      "name": "Claude Desktop",
      "version": "1.0.0"
    }
  }
}

Server → Client:

{
  "jsonrpc": "2.0",
  "id": 1,
  "result": {
    "protocolVersion": "2024-11-05",
    "capabilities": {
      "tools": {
        "listChanged": true
      }
    },
    "serverInfo": {
      "name": "weather",
      "version": "1.0.0"
    }
  }
}

Tool Discovery

Client → Server:

{
  "jsonrpc": "2.0",
  "id": 2,
  "method": "tools/list"
}

Server → Client:

{
  "jsonrpc": "2.0",
  "id": 2,
  "result": {
    "tools": [
      {
        "name": "get_alerts",
        "description": "Get weather alerts for a US state.",
        "inputSchema": {
          "type": "object",
          "properties": {
            "state": {
              "type": "string",
              "description": "Two-letter US state code (e.g. CA, NY)"
            }
          },
          "required": ["state"]
        }
      },
      {
        "name": "get_forecast",
        "description": "Get weather forecast for a location.",
        "inputSchema": {
          "type": "object",
          "properties": {
            "latitude": {
              "type": "number",
              "description": "Latitude of the location"
            },
            "longitude": {
              "type": "number",
              "description": "Longitude of the location"
            }
          },
          "required": ["latitude", "longitude"]
        }
      }
    ]
  }
}

External API Integration

National Weather Service API

The server integrates with the following NWS API endpoints:

Endpoint Purpose Rate Limit
GET /alerts/active/area/{state} Retrieve active alerts for a state User-Agent required
GET /points/{latitude},{longitude} Get grid point metadata User-Agent required
GET {forecast_url} Retrieve detailed forecast User-Agent required

Required Headers:

User-Agent: weather-app/1.0
Accept: application/geo+json

Error Handling

The server implements graceful error handling for:

  1. Invalid coordinates: Returns error message for non-US locations
  2. Network failures: Returns "Unable to fetch..." messages
  3. Missing data: Returns "No active alerts" or similar user-friendly messages
  4. API errors: Catches and handles HTTP errors from NWS API

Transport Layer

  • Type: STDIO (Standard Input/Output)
  • Encoding: UTF-8
  • Message Format: JSON-RPC 2.0
  • Framing: Newline-delimited JSON

Security Considerations

  1. Input Validation: All parameters are validated against schema
  2. Rate Limiting: Respects NWS API rate limits
  3. Error Sanitization: External API errors are sanitized before returning to client
  4. No Authentication: Server uses public NWS API (no credentials required)

Logging

  • STDIO Servers: All logs written to stderr (never stdout)
  • Log Location: Configured in MCP client (e.g., ~/Library/Logs/Claude/mcp-server-weather.log)
  • Log Level: Errors and warnings only (to avoid STDIO corruption)

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