SuperAPIAI Directory

mcp-weather-server

github.com · AI developer platforms

mcp-weather-server is a lightweight server based on the Model Context Protocol (MCP) that provides National Weather Service (NWS) weather data to AI agents. It offers two read-only tools, get-alerts and get-forecast: the former returns currently active weather alerts by two-letter state code, and the latter returns up to five forecast periods by latitude and longitude. Data comes from the free NWS API, requiring no key or account, and only supports the United States and its territories. The project is published on npm under the ISC license, can be run locally via stdio, and also offers a pay-per-call hosted HTTP endpoint.

Open website Alternatives
PricingOpen source开源项目(可免费自部署)
PlatformsAPI

About this tool

Purpose

mcp-weather-server is a minimal Model Context Protocol (MCP) server that wraps National Weather Service (NWS) API weather data as two read-only tools for AI agents or MCP clients to call. It originated from the MCP "Build a server" tutorial and was later extended with typed output schemas, read-only annotations, bounded requests, explicit failure conventions, and a test suite.

Key capabilities

  • get-alerts: accepts a two-letter state code and returns all active alerts for that state, including event, area, severity, description, and official instructions.
  • get-forecast: accepts latitude and longitude and returns up to five forecast periods, including name, temperature, wind speed and direction, and plain-language forecast.
  • Both tools declare readOnlyHint: true and destructiveHint: false, so hosts that respect tool annotations can call them without asking; because they access api.weather.gov, both are marked openWorldHint: true.
  • Both tools declare outputSchema and return structuredContent, and their schemas are both objects: get-forecast returns { latitude, longitude, periods }, and get-alerts returns { alerts: [...] }. get-alerts originally declared a top-level array, but was changed to an object wrapper because some MCP SDK clients reject array schemas.
  • Missing fields use fallback values rather than outputting null, for example a missing event name displays as Unknown and a missing temperature displays as Unknown.
  • Each request has a 10-second timeout, so an upstream stall manifests as a tool call failure rather than a hang.
  • Failures are returned as tool results rather than protocol errors:{ isError: true, content: [{ type: "text", text: "<what failed>" }] }, and clients can display the text and retry.

Usage

Running locally is free, and the project is published under the ISC license as the npm package @thx93/mcp-weather-server. Running node build/index.js uses the MCP protocol over stdio: it outputs to stderr and waits for a client on stdin, so it should be started by a host rather than run manually.

When adding it to an MCP client, most hosts use the same three-line configuration form; you can also install it directly from npm, either as a client configuration entry or directly from the repository (no registry account required). Installing from the repository works because prepare builds the server during installation;build/ Not submitted, otherwise bin will point to a nonexistent file.

The hosted version is pay-per-use, paid via x402 with USDC on Base, suitable for agents that do not want to carry a Node process and data layer. The hosted endpoint provides the same two tools, the same output schema, and the same null fallback, plus a free health tool and a free tools/list for discovery and probing; a tools/call to get-alerts or get-forecast returns 402 with the price. The server.json in the repository declares this remote endpoint, so MCP clients can install it by registry name without cloning.

When to use

Suitable for AI agents that need US weather alerts or short-term forecasts, MCP clients (such as Claude Desktop, Cursor, etc.), and developers who want to integrate weather data with minimal dependencies.

Limitations

  • Only supports the United States and its territories; coordinates outside the US return an error rather than a guess.
  • Data comes from NWS, and correctness can be verified directly against the source data.
  • The hosted endpoint is charged per use, with pricing and payment method as described in the materials; running locally is free.
  • The test suite drives the real server via InMemoryTransport and mocks the NWS API,npm test without network access and without credentials.

Build and test

Tests cover tool discovery and annotations, the get-alerts and get-forecast data paths, fallback when NWS returns null fields, failure conventions, and input validation.

Up/Down to navigate · Enter to open · ESC to closeBrowse all tools