weather-mcp

flannerychristopher/weather-mcp

3.2

If you are the rightful owner of weather-mcp and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to henry@mcphub.com.

A Model Context Protocol (MCP) server providing weather data via the National Weather Service API.

Tools
2
Resources
0
Prompts
0

Weather MCP Server

A practice project implementing a Model Context Protocol (MCP) server that provides weather data through the National Weather Service API. This project follows the Anthropic MCP documentation and serves as a useful reference for building other MCP servers.

Overview

This MCP server provides two main tools for weather information:

  • Weather Alerts: Get active weather alerts for any US state
  • Weather Forecast: Get detailed weather forecasts for specific coordinates

The server uses the National Weather Service (NWS) API, which provides free, reliable weather data for US locations.

Features

  • State Weather Alerts: Retrieve active weather alerts by state code
  • Location Forecasts: Get detailed forecasts using latitude/longitude coordinates
  • Error Handling: Robust error handling for API failures and invalid locations
  • TypeScript: Full TypeScript implementation with proper type definitions
  • Zod Validation: Input validation using Zod schemas

Installation

  1. Clone the repository:
git clone <repository-url>
cd weather-mcp
  1. Install dependencies:
npm install
  1. Build the project:
npm run build

Usage

As an MCP Server

The server runs on stdio and can be integrated with MCP-compatible clients:

node /path/to/weather-mcp/build/index.js

Available Tools

get_alerts

Get weather alerts for a specific state.

Parameters:

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

Example:

{
  "name": "get_alerts",
  "arguments": {
    "state": "CA"
  }
}
get_forecast

Get weather forecast for specific coordinates.

Parameters:

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

Example:

{
  "name": "get_forecast",
  "arguments": {
    "latitude": 37.7749,
    "longitude": -122.4194
  }
}

Development

Scripts

  • npm run build: Compile TypeScript to JavaScript
  • npm test: Run tests (currently not implemented)

Dependencies

  • @modelcontextprotocol/sdk: Core MCP SDK
  • zod: Schema validation library
  • typescript: TypeScript compiler
  • @types/node: Node.js type definitions

Limitations

  • Only supports US locations (NWS API limitation)
  • Requires internet connection for API calls
  • Rate limited by NWS API (though limits are generous)

References