Skip to main content
Glama
anthonychu

Weather MCP Server

by anthonychu

Weather MCP Server

A Node.js Model Context Protocol (MCP) server that provides weather information tools using Streamable HTTP Transport.

Features

  • get-alerts: Get weather alerts for a US state

  • get-forecast: Get weather forecast for a location using latitude/longitude coordinates

  • HTTP Transport: Uses streamable HTTP instead of stdio for better scalability

  • Session Management: Supports multiple concurrent client sessions

  • Health Check: Built-in health monitoring endpoint

Setup

  1. Install dependencies:

npm install
  1. Build the TypeScript code:

npm run build
  1. Start the HTTP server:

npm start

The server will start on port 3000 by default.

Usage

This server implements the Model Context Protocol using HTTP transport. It provides:

  • MCP Endpoint: http://localhost:3000/mcp

  • Health Check: http://localhost:3000/health

get-alerts

Get weather alerts for a US state.

Parameters:

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

HTTP Example:

curl -X POST http://localhost:3000/mcp \
  -H "Content-Type: application/json" \
  -H "mcp-session-id: your-session-id" \
  -d '{
    "jsonrpc": "2.0",
    "id": 1,
    "method": "tools/call",
    "params": {
      "name": "get-alerts",
      "arguments": {
        "state": "CA"
      }
    }
  }'

get-forecast

Get weather forecast for a location using coordinates.

Parameters:

  • latitude (number): Latitude (-90 to 90)

  • longitude (number): Longitude (-180 to 180)

HTTP Example:

curl -X POST http://localhost:3000/mcp \
  -H "Content-Type: application/json" \
  -H "mcp-session-id: your-session-id" \
  -d '{
    "jsonrpc": "2.0",
    "id": 1,
    "method": "tools/call",
    "params": {
      "name": "get-forecast",
      "arguments": {
        "latitude": 40.7128,
        "longitude": -74.0060
      }
    }
  }'

MCP Client Configuration

Use this configuration in your MCP client:

{
  "mcpServers": {
    "weather": {
      "transport": {
        "type": "http",
        "url": "http://localhost:3000/mcp"
      }
    }
  }
}

Development

  • Run in development mode:

npm run dev
  • Test the server:

npm test
  • Health check:

curl http://localhost:3000/health

Transport Features

  • Session Management: Each client gets a unique session ID

  • Concurrent Connections: Multiple clients can connect simultaneously

  • Server-Sent Events: Real-time notifications via GET requests

  • Session Termination: Clean session cleanup via DELETE requests

  • DNS Rebinding Protection: Disabled for local development (enable in production)

Security Note

For production deployments, enable DNS rebinding protection:

// In src/index.ts
enableDnsRebindingProtection: true,
allowedHosts: ['your-domain.com'],
allowedOrigins: ['https://your-domain.com'],

Environment Variables

  • PORT: Server port (default: 3000)

API Endpoints

  • POST /mcp: Main MCP communication endpoint

  • GET /mcp: Server-to-client notifications (SSE)

  • DELETE /mcp: Session termination

  • GET /health: Health check endpoint

Requirements

  • Node.js 18 or higher

  • TypeScript 5.5 or higher

  • Internet connection for weather API access

Directory Structure

weather-server/
├── src/
│   └── index.ts          # Main HTTP server implementation
├── dist/                 # Compiled JavaScript output
├── package.json          # Node.js dependencies and scripts
├── tsconfig.json         # TypeScript configuration
├── test.js              # HTTP client test script
├── mcp-config.json      # MCP client configuration
└── README.md            # This file

Requirements

  • Node.js 18 or higher

  • TypeScript 5.5 or higher

  • Internet connection for weather API access

-
security - not tested
F
license - not found
-
quality - not tested

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

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

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/anthonychu/20250711-node-mcp'

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