mohaimen-weather-mcp
Version:
Enhanced MCP Weather Server with comprehensive weather data, forecasts, air quality, UV index, alerts, and more. Provides 9 powerful weather tools for Claude via Model Context Protocol.
573 lines (438 loc) β’ 16.9 kB
Markdown
# π€οΈ Enhanced MCP Weather Server v2.0
A **comprehensive** Model Context Protocol (MCP) server that provides extensive weather data, forecasts, air quality, UV index, and much more! Get detailed weather information directly in your VS Code chat with 9 powerful tools.
[](https://mcpreview.com/mcp-servers/mohaimenhasan/mcp-weather-server)
## π **What Makes This Special?**
This isn't just another weather tool - it's a **comprehensive weather intelligence system** that provides:
### π― **9 Powerful Weather Tools:**
1. **π‘οΈ Enhanced Current Weather** - Detailed conditions with emojis and comprehensive data
2. **π
5-Day Weather Forecast** - Complete weather predictions with trends
3. **π¬οΈ Air Quality Index** - Real-time pollution levels and health warnings
4. **βοΈ UV Index & Sun Safety** - Solar radiation levels with safety recommendations
5. **π Multi-City Comparison** - Compare weather across multiple locations
6. **π¨ Weather Alerts** - Severe weather warnings and emergency notifications
7. **π
Astronomy Data** - Sunrise, sunset, day length, and astronomical information
8. **π Weather Statistics** - Comprehensive trends, averages, and climate insights
9. **πΊοΈ Weather Maps** - Access to radar, satellite, and weather map data
### π‘ **Why Use This Tool?**
**For Developers:**
- ποΈ **Building weather apps?** Get comprehensive data in one place
- π **Need location-based features?** Access weather, air quality, and astronomy data
- π± **Creating travel apps?** Compare weather across multiple destinations
- π― **Building outdoor apps?** Get UV index, air quality, and safety information
**For Data Analysis:**
- π **Weather trends and patterns** for business intelligence
- π‘οΈ **Climate data analysis** for research projects
- π **Multi-city comparisons** for location planning
- πΊοΈ **Geographic weather mapping** for visualization projects
**For Personal Use:**
- βοΈ **Travel planning** with detailed forecasts and air quality
- π **Outdoor activities** with UV index and weather safety
- π **Multi-location monitoring** for family/business across cities
- π± **Comprehensive weather briefings** beyond basic conditions
**For Content Creation:**
- π **Weather-aware content** with detailed environmental data
- π₯ **Location scouting** with comprehensive weather analysis
- π **Data visualization** with rich weather statistics
- π‘οΈ **Climate storytelling** with historical and trend data
> **π¨ Quick Note:** If the install buttons below open in your browser instead of VS Code, use **Method 1** below for manual configuration - it's more reliable!
## π **Easy Installation Methods**
### π― **Method 1: NPM Package (Recommended)**
Install directly from npm with automated setup:
```bash
npm install -g mohaimen-weather-mcp
```
Then in your settings just add
```json
"<name of your server>":
{
"command": "npx",
"args": [
"mohaimen-weather-mcp"
],
"env": {
"OPENWEATHER_API_KEY": "<YOUR_KEY>"
}
}
```
This will:
- Install the package globally
- Run an interactive setup that asks for your API key
- Automatically configure VS Code settings with correct paths
- No manual configuration needed!
### π― **Method 2: Manual Configuration (Most Reliable)**
1. **Clone and build:**
```bash
git clone https://github.com/mohaimenhasan/mcp-weather-server.git
cd mcp-weather-server
npm run setup
```
2. **Get your API key:**
- Visit [OpenWeatherMap](https://openweathermap.org/api) (free account)
- Copy your API key
3. **Add to VS Code:**
- Open VS Code
- Press `Ctrl+Shift+P` (or `Cmd+Shift+P` on Mac)
- Type "Preferences: Open User Settings (JSON)"
- Add this to your settings:
```json
{
"mcpServers": {
"weather": {
"command": "node",
"args": ["/absolute/path/to/mcp-weather-server/dist/index.js"],
"env": {
"OPENWEATHER_API_KEY": "your_api_key_here"
}
}
}
}
```
## β¨ All Features & Examples
### οΏ½οΈ **Enhanced Current Weather**
```
π€οΈ Weather in London, GB
π‘οΈ Temperature: βοΈ 22Β°C (feels like βοΈ 24Β°C)
π Condition: clear sky
π§ Humidity: 65%
π¬οΈ Wind: 3.2 m/s (120Β°)
ποΈ Visibility: 10.0 km
π‘οΈ Pressure: 1013 hPa
π Min/Max: βοΈ 18Β°C / βοΈ 26Β°C
βοΈ Cloudiness: 10%
π
Sunrise: 6:42:15 AM
π Sunset: 8:15:30 PM
π Coordinates: 51.5074, -0.1278
```
### π
**5-Day Weather Forecast**
```
π
5-Day Weather Forecast for Paris
βοΈ Day 1 - 12/27/2024
π‘οΈ Temp: βοΈ 24Β°C (βοΈ 20Β°C - βοΈ 28Β°C)
π clear sky
π§ Humidity: 68%
π¬οΈ Wind: 2.1 m/s
βοΈ Clouds: 15%
```
### π¬οΈ **Air Quality Index**
```
π¬οΈ Air Quality in Tokyo
π Overall AQI: 2/5 - π‘ Fair - Moderate air quality
Pollutant Levels (ΞΌg/mΒ³):
οΏ½ CO: 233.75
π NO: 0.01
π NOβ: 8.13
π«οΈ Oβ: 78.32
π¨ SOβ: 1.64
π PM2.5: 5.15
π PM10: 8.04
π¨ NHβ: 0.63
```
### βοΈ **UV Index & Sun Safety**
```
βοΈ UV Index for Sydney
π Current UV Index: 7.2
π High - Protection essential
Sun Safety Tips:
π§΄ Apply sunscreen (SPF 30+)
π Wear protective clothing
πΆοΈ Wear sunglasses and hat
```
### π **Multi-City Weather Comparison**
```
π Weather Comparison
βοΈ London, GB
π‘οΈ βοΈ 22Β°C (feels like βοΈ 24Β°C)
π clear sky
π§ 65% humidity
π¬οΈ 3.2 m/s wind
π§οΈ Seattle, US
π‘οΈ π‘οΈ 16Β°C (feels like π‘οΈ 14Β°C)
π moderate rain
π§ 85% humidity
π¬οΈ 5.1 m/s wind
```
### π¨ **Weather Alerts**
```
π¨ Weather Alerts for Miami
β οΈ Alert 1: Hurricane Warning
π
Start: 12/27/2024, 2:00:00 PM
π
End: 12/28/2024, 8:00:00 AM
π Hurricane conditions expected...
π’ Source: National Weather Service
```
### π
**Astronomy Data**
```
π
Astronomy Data for Tokyo
βοΈ Currently: Daytime
π
Sunrise: 6:47:12 AM
π Sunset: 4:32:45 PM
β° Day Length: 9h 45m
π Location: 35.6762Β°, 139.6503Β°
π Timezone: UTC+9
β³ Next sunset: in 3h 15m
```
### π **Weather Statistics & Trends**
```
π Weather Statistics for Berlin
Current Conditions:
π‘οΈ Temperature: π‘οΈ 18Β°C
π§ Humidity: 72%
π‘οΈ Pressure: 1015 hPa
ποΈ Visibility: 8.5 km
24-Hour Trends:
π‘οΈ Temperature Range: π‘οΈ 15Β°C to βοΈ 21Β°C
π Average Temperature: π‘οΈ 18Β°C
π Temperature Trend: Rising π
π§ Average Humidity: 68.2%
π‘οΈ Average Pressure: 1014.8 hPa
π Pressure Trend: Rising π
```
### πΊοΈ **Weather Maps**
```
πΊοΈ Weather Maps for New York
π Coordinates: 40.7128, -74.0060
Available Map Layers:
οΏ½οΈ Precipitation: Rainfall and snow patterns
βοΈ Clouds: Cloud coverage and density
π‘οΈ Temperature: Temperature distribution
π¬οΈ Wind Speed: Wind patterns and speeds
π‘οΈ Pressure: Atmospheric pressure systems
Center Map On: Latitude 40.7128, Longitude -74.0060
Recommended Zoom: 10 for city view
```
## π― Usage Examples
Once installed, you can ask VS Code Copilot questions like:
### π‘οΈ **Basic Weather Queries:**
- "What's the weather like in London?"
- "Get me comprehensive weather data for Tokyo"
- "Show me detailed current conditions in New York"
### π
**Forecast Queries:**
- "What's the 5-day forecast for Paris?"
- "Give me the weather forecast for Seattle this week"
- "Show me a 3-day forecast for Berlin"
### π¬οΈ **Air Quality & Health:**
- "What's the air quality in Beijing?"
- "Check pollution levels in Delhi"
- "Is the air quality safe in Los Angeles?"
### βοΈ **Sun & UV Safety:**
- "What's the UV index in Sydney?"
- "Do I need sunscreen in Miami today?"
- "Check sun safety for outdoor activities in Phoenix"
### π **Multi-City Comparisons:**
- "Compare weather between London, Paris, and Berlin"
- "Which city has better weather: Miami or San Diego?"
- "Show me weather comparison for Tokyo, Seoul, and Bangkok"
### π¨ **Weather Alerts:**
- "Are there any weather warnings for Florida?"
- "Check for severe weather alerts in Texas"
- "Show me storm warnings for the East Coast"
### π
**Astronomy & Timing:**
- "When does the sun rise in Moscow?"
- "What time is sunset in Hawaii?"
- "Show me astronomical data for Stockholm"
### π **Weather Analysis:**
- "Give me weather statistics for Chicago"
- "Show weather trends for the past 24 hours in Denver"
- "Analyze weather patterns in San Francisco"
### πΊοΈ **Weather Maps:**
- "How can I access weather radar for Dallas?"
- "Show me weather map information for Portland"
- "Get precipitation map data for the Pacific Northwest"
### π‘ **Advanced Usage Examples:**
**Travel Planning:**
"I'm planning a trip to Rome next week. Show me the forecast, air quality, and UV index."
**Outdoor Event Planning:**
"Compare weather conditions between Austin, Nashville, and Denver for an outdoor concert."
**Health & Safety:**
"Check air quality and UV index for Los Angeles - I have respiratory issues and need safe outdoor exercise conditions."
**Agricultural/Gardening:**
"Show me detailed weather statistics and forecast for Portland - I need to plan my garden watering schedule."
**Photography/Filming:**
"Give me sunrise/sunset times and weather conditions for Yosemite for a photo shoot."
## π οΈ Development
### Prerequisites
- Node.js (>= 18.x)
- npm (>= 9.x)
- OpenWeatherMap API key
### Local Development
```bash
# Install dependencies
npm install
# Build the project
npm run build
# Start in development mode (with auto-rebuild)
npm run dev
# Test the server
npm start
# Generate install URLs for your own use
npm run install-urls
# Get manual configuration for VS Code settings
npm run config
```
### Project Structure
```
mcp-weather-server/
βββ .vscode/
β βββ settings.json # Pre-configured MCP settings (user-specific)
β βββ settings.template.json # Template for settings.json
β βββ tasks.json # VS Code tasks for easy setup
β βββ inputs.json # Input prompts for API key
β βββ launch.json # Debug configuration
β βββ extensions.json # Recommended extensions
βββ dist/ # Compiled JavaScript (generated)
βββ index.ts # Main server code
βββ mcp-config.json # MCP configuration template
βββ install.html # Beautiful one-click install page
βββ generate-install-urls.js # Script to generate install URLs
βββ setup.bat # Windows setup script
βββ setup.sh # Unix setup script
βββ .env # Environment variables (user-specific)
βββ .gitignore # Git ignore rules
βββ package.json
```
## π§ Configuration
The server uses environment variables for configuration:
- `OPENWEATHER_API_KEY` or `API_KEY`: Your OpenWeatherMap API key (required)
## π‘ Complete API Reference
### Available Tools
#### π‘οΈ `get-weather`
**Enhanced current weather with comprehensive data**
**Parameters:**
- `city` (string): Name of the city to get weather for
**Returns:**
- Detailed temperature with emoji indicators
- Weather conditions with icons
- Humidity, wind speed, visibility
- Pressure, cloudiness, min/max temps
- Sunrise/sunset times
- Geographic coordinates
#### π
`get-forecast`
**5-day weather forecast with detailed predictions**
**Parameters:**
- `city` (string): Name of the city to get forecast for
- `days` (number, optional): Number of days to show (1-5, default: 5)
**Returns:**
- Daily temperature ranges with emojis
- Weather conditions for each day
- Humidity, wind, and cloud coverage
- Organized by day with clear formatting
#### π¬οΈ `get-air-quality`
**Air quality index and pollution data**
**Parameters:**
- `city` (string): Name of the city to get air quality for
**Returns:**
- Overall Air Quality Index (1-5 scale)
- Detailed pollutant levels (CO, NO, NOβ, Oβ, SOβ, PM2.5, PM10, NHβ)
- Health recommendations based on AQI
- Color-coded quality indicators
#### βοΈ `get-uv-index`
**UV index and sun safety information**
**Parameters:**
- `city` (string): Name of the city to get UV index for
**Returns:**
- Current UV index value
- Safety level description (Low/Moderate/High/Very High/Extreme)
- Specific sun protection recommendations
- Time-based safety advice
#### π `compare-weather`
**Compare weather between multiple cities**
**Parameters:**
- `cities` (array of strings): Array of city names to compare (2-5 cities)
**Returns:**
- Side-by-side weather comparison
- Temperature, conditions, humidity for each city
- Weather emojis for quick visual reference
- Organized display for easy comparison
#### π¨ `get-weather-alerts`
**Severe weather alerts and warnings**
**Parameters:**
- `city` (string): Name of the city to get weather alerts for
**Returns:**
- Active weather warnings and alerts
- Alert severity and timing
- Detailed descriptions of weather threats
- Official source attribution
#### π
`get-astronomy`
**Detailed sunrise, sunset, and astronomical data**
**Parameters:**
- `city` (string): Name of the city to get astronomy data for
**Returns:**
- Sunrise and sunset times
- Day length calculation
- Current day/night status
- Time until next sunrise/sunset
- Geographic coordinates and timezone
- Moon phase information (with additional API)
#### π `get-weather-stats`
**Comprehensive weather statistics and trends**
**Parameters:**
- `city` (string): Name of the city to get weather statistics for
**Returns:**
- Current weather conditions summary
- 24-hour temperature trends and ranges
- Pressure and humidity patterns
- Weather trend indicators (rising/falling)
- Statistical analysis of recent conditions
#### πΊοΈ `get-weather-maps`
**Weather map information and access URLs**
**Parameters:**
- `city` (string): Name of the city to get map information for
**Returns:**
- Geographic coordinates for mapping
- Available weather layer types
- Direct URLs for weather map tiles
- Integration instructions for mapping libraries
- Recommended zoom levels and center points
### API Response Format
All tools return responses in this format:
```json
{
"content": [{
"type": "text",
"text": "Formatted weather information with emojis and detailed data"
}]
}
```
### Error Handling
The server handles various error conditions:
- **404 Errors**: City not found - suggests checking spelling
- **401 Errors**: Invalid API key - prompts key configuration check
- **Network Errors**: Timeout or connection issues - suggests retrying
- **API Limitations**: Some features require premium OpenWeatherMap subscription
## π Troubleshooting
### Common Issues
1. **"Undefined input variable 'openweatherApiKey'" error:**
- This happens when VS Code can't resolve the input variable
- **Solution**: Copy `.vscode/settings.template.json` to `.vscode/settings.json` and replace `YOUR_API_KEY_HERE` with your actual API key
- Or create a `.env` file with `OPENWEATHER_API_KEY=your_api_key_here`
2. **"API key is required" error:**
- Make sure you've set your API key in the environment variables or `.env` file
- Check that your API key is valid and active at [OpenWeatherMap](https://openweathermap.org/api)
3. **"Module not found" error:**
- Run `npm run build` to compile TypeScript
- Ensure all dependencies are installed with `npm install`
4. **MCP server not appearing in VS Code:**
- Check that the path in your MCP configuration is correct
- Ensure the `dist/index.js` file exists after building
- Restart VS Code after adding the server configuration
5. **One-click install buttons not working:**
- **If buttons open in browser instead of VS Code:**
- The MCP extension might not be installed or URL handler not registered
- Use Method 1 (Manual Configuration) instead - it's more reliable
- Run `npm run config` to get the exact configuration to copy
- Make sure you have VS Code or VS Code Insiders installed
- Ensure your project is built before attempting installation
### Getting Help
- π§ Contact: @mohaimenhasan
- π Issues: [GitHub Issues](https://github.com/mohaimenhasan/mcp-weather-server/issues)
- π MCP Documentation: [Model Context Protocol](https://modelcontextprotocol.io/)
## π What's Next?
After installation, you can:
- Ask weather questions directly in VS Code chat
- Integrate weather data into your coding workflow
- Build weather-aware applications with real-time data
- Explore other MCP servers for enhanced functionality
## π License
MIT License - feel free to use this in your own projects!
---
Made with β€οΈ for the VS Code and MCP community