Content
# MCP Weather Server
This project is a **ModelContextProtocol (MCP)** compatible weather server that fetches real-time alerts and forecasts from the **U.S. National Weather Service (NWS)** and exposes them as tools via MCP. It is built with **Node.js**, **TypeScript**, and the official [@modelcontextprotocol/sdk](https://www.npmjs.com/package/@modelcontextprotocol/sdk).
## 🔧 Features
- **`get-alerts`**: Get active weather alerts for any U.S. state.
- **`get-forecast`**: Get a 7-day weather forecast for a given latitude and longitude in the U.S.
- Uses `fetch` with custom headers to communicate with the NWS API.
- Runs over standard input/output (STDIO) transport using MCP.
## 📦 Installation
```bash
git clone https://github.com/JohnnieEmmanuel/mcp-weather-server.git
cd mcp-weather-server
npm install
````
## 🚀 Usage
### Build the project:
```bash
npm run build
```
### Run the server:
```bash
node build/index.js
```
> Ensure the MCP consumer you're connecting to is set up to use STDIO transport.
## 🛠 Tools
### 🔔 `get-alerts`
Fetches active alerts for a U.S. state.
**Input:**
```json
{
"state": "CA"
}
```
**Output (MCP):**
* Text block summarizing active alerts.
---
### 🌦 `get-forecast`
Fetches weather forecast for a given latitude and longitude.
**Input:**
```json
{
"latitude": 37.7749,
"longitude": -122.4194
}
```
**Output (MCP):**
* Text block summarizing forecast periods including temperature, wind, and short description.
---
## 🧱 Tech Stack
* **Node.js** + **TypeScript**
* **Zod** for schema validation
* **node-fetch** for HTTP requests
* **MCP SDK** for server integration and transport
---
## 📄 License
MIT License
---
## 🧠 Credits
Built by [ John Emmanuel (REDJOHN) ](https://github.com/JohnnieEmmanuel) using the ModelContextProtocol SDK.
## 📢 Disclaimer
This server only supports **U.S. locations** as it uses the [api.weather.gov](https://www.weather.gov/documentation/services-web-api), which is limited to U.S. data.
---
## ✨ Example
```bash
> get-alerts { "state": "TX" }
Active alerts for TX:
Event: Excessive Heat Warning
Area: Central Texas
Severity: Severe
Status: Actual
Headline: Dangerously hot conditions expected
---
...
```
---
Connection Info
You Might Also Like
markitdown
Python tool for converting files and office documents to Markdown.
markitdown
MarkItDown-MCP is a lightweight server for converting URIs to Markdown.
Filesystem
Node.js MCP Server for filesystem operations with dynamic access control.
TrendRadar
TrendRadar: Your hotspot assistant for real news in just 30 seconds.
mempalace
The highest-scoring AI memory system ever benchmarked. And it's free.
mempalace
The highest-scoring AI memory system ever benchmarked. And it's free.