Skip to main content
Glama
imvedanshmehra

weather-mcp-server

README.md
# Weather MCP Server

A simple [Model Context Protocol](https://modelcontextprotocol.io) (MCP) server that exposes weather tools backed by the US [National Weather Service (NWS) API](https://www.weather.gov/documentation/services-web-api).

The server runs over stdio and can be plugged into any MCP-compatible client (e.g. Cursor, Claude Desktop).

## Tools

The server registers two tools:

- **`get_alerts`** — Get active weather alerts for a US state.
  - Input: `state` — two-letter state code (e.g. `CA`, `NY`).
- **`get_forecast`** — Get the weather forecast for a location.
  - Input: `latitude` (-90 to 90), `longitude` (-180 to 180).
  - Note: Only US locations are supported by the NWS API.

## Requirements

- Node.js (with support for ES modules)
- npm

## Installation

```bash
npm install
```

## Build

```bash
npm run build
```

This compiles TypeScript into the `build/` directory and marks `build/index.js` as executable.

## Run

After building, run the server directly:

```bash
node build/index.js
```

You should see:

```
Weather MCP Server running on stdio
```

## Using with an MCP client

Configure your MCP client to launch this server. Example configuration:

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

## Project structure

```
src/
  index.ts          # MCP server entry point, tool registration
  utils/
    helper.ts       # NWS API helpers and alert formatting
```