mcp-weather-server
Provides real-time weather, 5-day forecasts, and weather alerts for US states via NWS and WeatherAPI.com, accessible through natural language queries.
README
Weather MCP Server š¤ļø written in TypeScript
A Model Context Protocol (MCP) server that provides real-time weather information, forecasts, and alerts using the National Weather Service API and WeatherAPI.com.
Features
- š¤ļø Current Weather - Get real-time weather conditions for any location worldwide
- š 5-Day Forecasts - Detailed weather forecasts with temperature, wind, and conditions
- ā ļø Weather Alerts - Active weather alerts and warnings for US states
- š Global Support - Location search via geocoding (city names, landmarks, etc.)
- š Type-Safe - Built with TypeScript for reliability
Prerequisites
- Node.js 18+
- npm or yarn
- A free API key from WeatherAPI.com
Installation
# Clone the repository
git clone https://github.com/YOUR_USERNAME/weather-mcp-server.git
cd weather-mcp-server
# Install dependencies
npm install
# Create environment file
cp .env.example .env
Configuration
Sign up for a free API key at WeatherAPI.com
Edit .env and add your API key:
env
WEATHER_API_KEY=your_api_key_here
Usage
Development Mode (TypeScript)
bash
npm run dev
Production Build
bash
# Build the project
npm run build
# Run the built version
npm start
Testing with MCP Inspector
bash
# Test with TypeScript source
npm run inspect
# Test with built JavaScript
npm run inspect-built
Integration
Cline (VS Code Extension)
Add to %APPDATA%\Code\User\globalStorage\cline.cline\settings\cline_mcp_settings.json:
json
{
"mcpServers": {
"weather-server": {
"command": "node",
"args": [
"C:\\path\\to\\weather-server\\build\\index.js"
],
"env": {
"WEATHER_API_KEY": "your_api_key_here"
}
}
}
}
Claude Desktop
Add to %APPDATA%\Claude\claude_desktop_config.json:
json
{
"mcpServers": {
"weather": {
"command": "node",
"args": [
"C:\\path\\to\\weather-server\\build\\index.js"
],
"env": {
"WEATHER_API_KEY": "your_api_key_here"
}
}
}
}
Available Tools
get_current_weather
Get current weather conditions for any location.
Input:
json{
"name": "London"
}
Output:
json
{
"location": "London",
"coordinates": { "lat": 51.5074, "lon": -0.1278 },
"temperature": 72,
"temperatureUnit": "F",
"windSpeed": "10 mph",
"windDirection": "SW",
"shortForecast": "Partly Cloudy",
"detailedForecast": "Partly cloudy with a high near 72..."
}
get_forecast
Get 5-day weather forecast for any location.
Input:
json
{
"name": "New York"
}
Output:
json
{
"location": "New York",
"coordinates": { "lat": 40.7128, "lon": -74.0060 },
"forecast": [
{
"name": "Tonight",
"temperature": 45,
"temperatureUnit": "F",
"windSpeed": "5 mph",
"windDirection": "N",
"shortForecast": "Clear",
"detailedForecast": "Clear skies with low around 45..."
}
// ... more periods
]
}
get-alerts
Get active weather alerts for US states.
Input:
json
{
"state": "CA"
}
Output:
json
{
"state": "CA",
"alerts": [
{
"event": "Heat Advisory",
"headline": "Heat Advisory issued June 15...",
"severity": "Moderate",
"urgency": "Expected",
"certainty": "Likely",
"areaDesc": "Los Angeles County"
}
]
}
Development
Project Structure
weather-server/
āāā src/
ā āāā index.ts # TypeScript source code
āāā build/
ā āāā index.js # Compiled JavaScript (generated)
āāā .env # Environment variables (not in git)
āāā .env.example # Example environment file
āāā .gitignore # Git ignore rules
āāā package.json # Dependencies and scripts
āāā tsconfig.json # TypeScript configuration
āāā README.md # This file
Scripts
bash
npm run dev # Run in development mode with tsx
npm run build # Build TypeScript to JavaScript
npm start # Run built JavaScript version
npm run inspect # Test with MCP Inspector (TypeScript)
npm run inspect-built # Test with MCP Inspector (JavaScript)
APIs Used
- National Weather Service API - Free US weather data
- WeatherAPI.com - Global geocoding and location search
Limitations
- Weather alerts (get-alerts) only work for US locations (NWS limitation)
- Current weather and forecasts are US-focused but work globally via geocoding
- Rate limits apply based on your WeatherAPI.com plan (free tier: 1M calls/month)
Troubleshooting
"WEATHER_API_KEY environment variable is required"
- Make sure .env file exists with valid API key
- Check that the key is not expired
"This location might not be supported by the NWS API"
- NWS only covers US locations for detailed forecasts
- Try a US city or use the geocoding to verify location
Type errors in development
- Run npm install to ensure all dependencies are installed
- Check that TypeScript version is 5.7+ with npx tsc --version
## Cline/Claude Desktop Integration
### Cline (VS Code Extension)
**Config Location (depends on Cline version):**
- **Newer versions:** `%APPDATA%\Code\User\globalStorage\cline.cline\settings\cline_mcp_settings.json`
- **Older versions:** `%APPDATA%\Code\User\globalStorage\saoudrizwan.claude-dev\settings\cline_mcp_settings.json`
**Configuration:**
```json
{
"mcpServers": {
"weather-server": {
"command": "node",
"args": [
"C:\\path\\to\\weather-server\\build\\index.js"
],
"env": {
"WEATHER_API_KEY": "your_api_key_here"
},
"autoApprove": [
"get_current_weather",
"get_forecast",
"get-alerts"
]
}
}
}
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (git checkout -b feature/AmazingFeature)
- Commit your changes (git commit -m 'Add some AmazingFeature')
- Push to the branch (git push origin feature/AmazingFeature)
- Open a Pull Request
License
This project is licensed under the MIT License - see the LICENSE file for details.
Author
Herman Adu
Acknowledgments
- Model Context Protocol by Anthropic
- National Weather Service API
- WeatherAPI.com
Support
If you have questions or need help:
- Open an issue on GitHub
- Check the MCP Documentation
Built with ā¤ļø using the Model Context Protocol
---
Recommended Servers
playwright-mcp
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.
Magic Component Platform (MCP)
An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.
Audiense Insights MCP Server
Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.
VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
graphlit-mcp-server
The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.
Kagi MCP Server
An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.
E2B
Using MCP to run code via e2b.
Neon Database
MCP server for interacting with Neon Management API and databases
Exa Search
A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.