mohaimenhasan/mcp-weather-server
MCP Weather Server is a simple Model Context Protocol server providing weather data via an Express API.
๐ค๏ธ 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.
๐ What Makes This Special?
This isn't just another weather tool - it's a comprehensive weather intelligence system that provides:
๐ฏ 9 Powerful Weather Tools:
- ๐ก๏ธ Enhanced Current Weather - Detailed conditions with emojis and comprehensive data
- ๐ 5-Day Weather Forecast - Complete weather predictions with trends
- ๐ฌ๏ธ Air Quality Index - Real-time pollution levels and health warnings
- โ๏ธ UV Index & Sun Safety - Solar radiation levels with safety recommendations
- ๐ Multi-City Comparison - Compare weather across multiple locations
- ๐จ Weather Alerts - Severe weather warnings and emergency notifications
- ๐ Astronomy Data - Sunrise, sunset, day length, and astronomical information
- ๐ Weather Statistics - Comprehensive trends, averages, and climate insights
- ๐บ๏ธ 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:
npm install -g mohaimen-weather-mcp
Then in your settings just add
"<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)
-
Clone and build:
git clone https://github.com/mohaimenhasan/mcp-weather-server.git cd mcp-weather-server npm run setup
-
Get your API key:
- Visit OpenWeatherMap (free account)
- Copy your API key
-
Add to VS Code:
- Open VS Code
- Press
Ctrl+Shift+P
(orCmd+Shift+P
on Mac) - Type "Preferences: Open User Settings (JSON)"
- Add this to your settings:
{ "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
# 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
orAPI_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 fordays
(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:
{
"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
-
"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 replaceYOUR_API_KEY_HERE
with your actual API key - Or create a
.env
file withOPENWEATHER_API_KEY=your_api_key_here
-
"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
- Make sure you've set your API key in the environment variables or
-
"Module not found" error:
- Run
npm run build
to compile TypeScript - Ensure all dependencies are installed with
npm install
- Run
-
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
-
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
- If buttons open in browser instead of VS Code:
Getting Help
- ๐ง Contact: @mohaimenhasan
- ๐ Issues: GitHub Issues
- ๐ MCP Documentation: Model Context Protocol
๐ 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