Uses dotenv for environment variable management to configure the server with NWS API settings
Implemented as a Node.js application, allowing it to be run as a CLI tool or integrated with VS Code
Built with TypeScript for type-safe implementation of the weather data service
Employs Zod for runtime type validation of API responses and request parameters
🌤️ Weather MCP Server
A Model Context Protocol (MCP) server that provides weather data and alerts using the National Weather Service API.
📋 Description
This MCP server provides weather forecast and alert data for US locations through the National Weather Service API. It offers two main tools:
Weather Alerts: Get active weather alerts for any US state
Weather Forecast: Get detailed weather forecasts for specific coordinates
🚀 Features
⚡ Get weather alerts by state code
📍 Get weather forecasts by latitude/longitude
🇺🇸 Supports all US locations via NWS API
🔄 Real-time weather data
📦 Built with TypeScript and MCP SDK
🔧 CLI executable for easy installation and usage
🖥️ VS Code integration with MCP support
🛠️ Installation
Clone the repository
git clone <repository-url> cd MCP_NodeInstall dependencies
npm installSet up environment variables
cp .envExample .envEdit the
.env
file with your configuration.Build the project
npm run buildInstall globally (optional)
npm install -g .After global installation, you can run the server with:
weather
⚙️ Configuration
The server requires the following environment variables:
NWS_API_BASE
: Base URL for the National Weather Service APIUSER_AGENT
: User agent string for API requests
See .envExample
for default values.
🔧 Usage
Running the Server
Option 1: Using npm script
Option 2: Direct node execution
Option 3: Using global installation
VS Code Integration
This server is configured to work with VS Code's MCP support. The configuration is available in .vscode/mcp.json
. To use it in VS Code:
Ensure the server is built:
npm run build
The server will be available as
salil-weather-mcp-server
in your VS Code MCP settingsSupported models: GPT-4.1 and Claude Sonnet 4
CLI Usage
After installing globally with npm install -g .
, you can use the weather command directly:
The CLI tool provides the same functionality as running the server directly, but with easier access from anywhere on your system.
Available Tools
🚨 get-alerts
Get weather alerts for a specific state.
Parameters:
state
(string): Two-letter state code (e.g., "CA", "NY")
Example:
🌦️ get-forecast
Get weather forecast for a specific location.
Parameters:
latitude
(number): Latitude (-90 to 90)longitude
(number): Longitude (-180 to 180)
Example:
📁 Project Structure
🔗 Dependencies
Production
@modelcontextprotocol/sdk
: MCP SDK for server implementationdotenv
: Environment variable managementzod
: Runtime type validation
Development
typescript
: TypeScript compiler@types/node
: Node.js type definitions@types/dotenv
: Dotenv type definitions
🔧 CLI Installation & Usage
This package can be installed as a global CLI tool for easy access:
Global Installation
CLI Command
After global installation, the weather
command becomes available system-wide:
This starts the MCP server and makes it available for integration with MCP-compatible tools and applications.
Package Distribution
The package is configured with:
Binary entry point:
weather
command pointing to./build/index.js
ESM modules: Uses modern JavaScript module syntax
Files whitelist: Only distributes the essential
build/
directory
🌐 API Reference
This server uses the National Weather Service API which provides:
Weather forecasts
Weather alerts
Observation data
Grid point data
Note: The NWS API only supports US locations.
🐛 Error Handling
The server includes comprehensive error handling for:
Missing environment variables
Invalid coordinates
API request failures
Unsupported locations (non-US)
📝 License
ISC
👥 Contributing
Fork the repository
Create a feature branch
Make your changes
Run tests and build
Submit a pull request
🔍 Troubleshooting
Common Issues
"Missing required environment variable"
Ensure
.env
file exists and contains required variables
"This location may not be supported"
The NWS API only supports US locations
Verify coordinates are within US boundaries
"Server not recognized in VS Code"
Ensure the project is built:
npm run build
Check that
.vscode/mcp.json
exists and is properly configuredRestart VS Code after making configuration changes
"Permission denied when installing globally"
On Windows: Run PowerShell as Administrator
On macOS/Linux: Use
sudo npm install -g .
📊 Development
Available Scripts
Build: Compile TypeScript to JavaScript
npm run buildStart: Run the compiled server
npm startGlobal Install: Install as a global CLI tool
npm install -g .
VS Code Development
This project includes VS Code configuration for:
MCP Integration: Pre-configured MCP server settings
IntelliSense: Enhanced TypeScript support
Debugging: Launch configurations for debugging
Spell Check: Custom dictionary for technical terms
File Overview
src/index.ts: Main application entry point, initializes the MCP server
src/server.ts: Registers weather tools and handles tool logic
src/weatherContracts.ts: TypeScript interfaces for API responses
src/weatherRequest.ts: Utility functions for making API requests
This server cannot be installed
remote-capable server
The server can be hosted and run remotely because it primarily relies on remote services or has no dependency on the local environment.
Provides weather forecast and alert data for US locations through the National Weather Service API, enabling access to real-time weather alerts by state and detailed forecasts by coordinates.
Related MCP Servers
- -securityFlicense-qualityA lightweight microservice that fetches weather alerts and forecasts from the National Weather Service API, providing U.S. state-level alerts and location-based forecasts.Last updated -
- AsecurityFlicenseAqualityProvides real-time weather forecasts and alerts by fetching data from the National Weather Service API, allowing Claude to answer weather-related questions with up-to-date information.Last updated -2
- AsecurityAlicenseAqualityA JavaScript ES Modules server that provides weather information including alerts and forecasts for US locations using the National Weather Service API.Last updated -3Apache 2.0
- AsecurityFlicenseAqualityEnables AI assistants to access real-time US weather forecasts and alerts through the National Weather Service API.Last updated -25