Weather MCP Server

Weather MCP Server

Provides weather forecasts and active alerts for US locations using the National Weather Service API. It supports both local stdio and remote HTTP/SSE transport modes for flexible integration with MCP clients.

Category
Visit Server

README

Weather MCP Server - Usage Guide

A Model Context Protocol (MCP) server that provides weather information using the National Weather Service API. Supports both local (stdio) and remote (HTTP/SSE) access.

Features

  • Dual Transport Support: Run locally via stdio or remotely via HTTP/SSE
  • Weather Alerts: Get active weather alerts by state
  • Weather Forecasts: Get detailed forecasts by coordinates (US locations only)
  • Session Management: Automatic session handling for remote connections

Installation

npm install
npm run build

Usage

Local Mode (Stdio Transport)

For local use with MCP clients like Claude Desktop:

# Default mode - no environment variable needed
node build/index.js

# Or explicitly set stdio mode
TRANSPORT=stdio node build/index.js

Configuration for Claude Desktop (claude_desktop_config.json):

{
  "mcpServers": {
    "weather": {
      "command": "node",
      "args": ["/path/to/weather/build/index.js"]
    }
  }
}

Remote Mode (HTTP/SSE Transport)

For remote access via HTTP:

# Start HTTP server on default port 3000
TRANSPORT=http node build/index.js

# Or specify a custom port
TRANSPORT=http PORT=8080 node build/index.js

The server will start on http://localhost:3000/mcp (or your specified port).

Remote Access Examples

1. Initialize Session

curl -X POST http://localhost:3000/mcp \
  -H "Content-Type: application/json" \
  -H "Accept: application/json, text/event-stream" \
  -d '{
    "jsonrpc": "2.0",
    "id": 1,
    "method": "initialize",
    "params": {
      "protocolVersion": "2024-11-05",
      "capabilities": {},
      "clientInfo": {
        "name": "my-client",
        "version": "1.0.0"
      }
    }
  }'

Response: Returns session ID in mcp-session-id header. Save this for subsequent requests.

2. Get Weather Forecast

curl -X POST http://localhost:3000/mcp \
  -H "Content-Type: application/json" \
  -H "Accept: application/json, text/event-stream" \
  -H "mcp-session-id: YOUR_SESSION_ID" \
  -d '{
    "jsonrpc": "2.0",
    "id": 2,
    "method": "tools/call",
    "params": {
      "name": "get_forecast",
      "arguments": {
        "latitude": 37.7749,
        "longitude": -122.4194
      }
    }
  }'

3. Get Weather Alerts

curl -X POST http://localhost:3000/mcp \
  -H "Content-Type: application/json" \
  -H "Accept: application/json, text/event-stream" \
  -H "mcp-session-id: YOUR_SESSION_ID" \
  -d '{
    "jsonrpc": "2.0",
    "id": 3,
    "method": "tools/call",
    "params": {
      "name": "get_alerts",
      "arguments": {
        "state": "CA"
      }
    }
  }'

4. Open SSE Stream (Optional)

For receiving server-initiated messages:

curl -N http://localhost:3000/mcp \
  -H "Accept: text/event-stream" \
  -H "mcp-session-id: YOUR_SESSION_ID"

5. Terminate Session

curl -X DELETE http://localhost:3000/mcp \
  -H "mcp-session-id: YOUR_SESSION_ID"

Available Tools

get_forecast

Get weather forecast for a location.

Parameters:

  • latitude (number): Latitude of the location (-90 to 90)
  • longitude (number): Longitude of the location (-180 to 180)

Note: Only US locations are supported by the National Weather Service API.

get_alerts

Get active weather alerts for a US state.

Parameters:

  • state (string): Two-letter state code (e.g., "CA", "NY")

Environment Variables

Variable Description Default Example
TRANSPORT Transport mode: stdio or http stdio http
PORT HTTP server port (HTTP mode only) 3000 8080

Architecture

Stdio Mode

  • Single server instance
  • Communicates via stdin/stdout
  • Ideal for local MCP clients

HTTP Mode

  • Express-based HTTP server
  • Session-based architecture
  • Multiple concurrent sessions supported
  • Automatic session cleanup on disconnect
  • SSE streaming for real-time updates

Deployment

Local Development

TRANSPORT=http PORT=3000 node build/index.js

Production (with PM2)

pm2 start build/index.js --name weather-mcp -- TRANSPORT=http PORT=3000

Docker

FROM node:20-alpine
WORKDIR /app
COPY package*.json ./
RUN npm ci --only=production
COPY build ./build
ENV TRANSPORT=http
ENV PORT=3000
EXPOSE 3000
CMD ["node", "build/index.js"]

Troubleshooting

"Failed to retrieve grid point data"

  • Ensure coordinates are within the United States
  • NWS API only supports US locations

"Invalid or missing session ID"

  • Initialize a session first using the initialize method
  • Include the mcp-session-id header in all subsequent requests

Server not starting in HTTP mode

  • Check if port is already in use
  • Verify TRANSPORT=http environment variable is set

License

ISC

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
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
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
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