flannerychristopher/weather-mcp
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.
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
- Clone the repository:
git clone <repository-url>
cd weather-mcp
- Install dependencies:
npm install
- 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 JavaScriptnpm test
: Run tests (currently not implemented)
Dependencies
@modelcontextprotocol/sdk
: Core MCP SDKzod
: Schema validation librarytypescript
: 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)