Weather MCP Server
Weather MCP Server
A Model Context Protocol (MCP) server that provides weather alerts and forecasts using the National Weather Service (NWS) API.
Features
Weather Alerts: Get active weather alerts for any US state
Location Forecasts: Retrieve detailed weather forecasts for specific coordinates
Real-time Data: Pulls live data from the official NWS API
MCP Compliance: Fully compatible with Claude Desktop and other MCP clients
Installation
Clone the repository:
git clone https://github.com/MikeySharma/weather-mcp-server.git
cd weather-mcp-serverInstall dependencies:
npm installBuild the project:
npm run buildConfiguration
Claude Desktop Setup
Add the following to your Claude Desktop MCP settings:
macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
Windows: %APPDATA%/Claude/claude_desktop_config.json
{
"mcpServers": {
"weather": {
"command": "node",
"args": ["/absolute/path/to/weather-mcp-server/build/index.js"],
"env": {
"NODE_ENV": "production"
}
}
}
}Environment Variables
The server uses the following environment variables (optional):
# For debugging
export DEBUG_MCP=true
export NODE_ENV=developmentUsage
Available Tools
1. Get Weather Alerts
get_alerts(state: string)state: Two-letter US state code (e.g., "CA", "NY", "TX")
Returns: Active weather alerts for the specified state
2. Get Weather Forecast
get_forecast(latitude: number, longitude: number)latitude: Geographic latitude (-90 to 90)
longitude: Geographic longitude (-180 to 180)
Returns: 7-day weather forecast for the location
Example Usage with Claude
@weather get_alerts(state: "CA")@weather get_forecast(latitude: 37.7749, longitude: -122.4194)API Reference
National Weather Service API
This server uses the official NWS API:
Base URL:
https://api.weather.govRate Limits: Please respect rate limits (typically 10 requests/minute)
Data Coverage: US territories only
Response Formats
Alerts Response
{
features: Array<{
properties: {
event: string;
severity: string;
description: string;
instruction: string;
areaDesc: string;
effective: string;
expires: string;
}
}>
}Forecast Response
{
properties: {
periods: Array<{
name: string;
temperature: number;
temperatureUnit: string;
windSpeed: string;
windDirection: string;
shortForecast: string;
detailedForecast: string;
}>
}
}Development
Project Structure
weather-mcp-server/
├── src/
│ ├── index.ts # Main server entry point
│ ├── tools/
│ │ └── weather-tools.ts # Tool implementations
│ └── helpers/
│ └── weather-service.helpers.ts # API helpers
├── build/ # Compiled JavaScript
├── package.json
└── tsconfig.jsonBuilding from Source
Install TypeScript (if not already installed):
npm install -g typescriptBuild the project:
npm run buildDevelopment mode with watch:
npm run devTesting
Run the server in standalone mode for testing:
npm startError Handling
The server includes comprehensive error handling for:
Network timeouts
API rate limiting
Invalid coordinates
Unsupported locations (non-US)
Malformed responses
Limitations
US Only: NWS API only provides data for US territories
Rate Limits: Respect NWS API rate limits (10 requests/minute)
Coordinate Precision: Limited to 4 decimal places for grid points
Contributing
Fork the repository
Create a feature branch (
git checkout -b feature/amazing-feature)Commit your changes (
git commit -m 'Add amazing feature')Push to the branch (
git push origin feature/amazing-feature)Open a Pull Request
License
This project is licensed under the MIT License - see the LICENSE file for details.
Acknowledgments
National Weather Service for providing the free API
Anthropic for the Model Context Protocol specification
MCP SDK developers
Support
For issues and questions:
Check the existing issues
Create a new issue with detailed description
Include error logs and reproduction steps
Changelog
v1.0.0
Initial release with alerts and forecast functionality
MCP protocol compliance
TypeScript implementation
Comprehensive error handling
Note: This server requires an internet connection to fetch weather data from the NWS API.
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/MikeySharma/weather-mcp-server'
If you have feedback or need assistance with the MCP directory API, please join our Discord server