mcp-weather-server

mohaimenhasan/mcp-weather-server

3.4

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.

MCP Review Certified

๐Ÿš€ 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:

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)

  1. Clone and build:

    git clone https://github.com/mohaimenhasan/mcp-weather-server.git
    cd mcp-weather-server
    npm run setup
    
  2. Get 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:
    {
      "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 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:

{
  "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
  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

๐ŸŽ‰ 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