Weather MCP server

Integrates with OpenWeatherMap API to provide real-time weather conditions, forecasts, air quality information, historical data, location search, and weather alerts for seamless access to accurate weather information during conversations.
Back to servers
Provider
SaintDoresh
Release date
Mar 16, 2025
Language
Python
Stats
7 stars

This MCP server provides real-time weather information for Claude Desktop using the OpenWeatherMap API. It enables Claude to access current conditions, forecasts, historical data, air quality, and weather alerts for any location worldwide through a simple conversational interface.

Installation and Setup

Prerequisites

  • Python 3.10 or higher
  • OpenWeatherMap API key

Setup Steps

  1. Install required dependencies:
pip install -r requirements.txt
  1. Get an API key from OpenWeatherMap

    • Note that new API keys may take up to 24 hours to activate
  2. Set up environment variables for your API key:

    • Create a .env file in the project directory
    • Add your API key:
    OPENWEATHER_API_KEY=your_openweathermap_api_key
    
  3. Update main.py to use the environment variable:

# Add these imports at the top
import os
from dotenv import load_dotenv

# Load environment variables
load_dotenv()

# Replace the API_KEY line with
API_KEY = os.getenv("OPENWEATHER_API_KEY")

Integrating with Claude Desktop

  1. Configure your MCP settings in Claude Desktop:
{
  "mcpServers": {
    "weather-mcp": {
      "command": "py",
      "args": ["-3.13", "C:\\Path\\To\\Your\\Weather-MCP-ClaudeDesktop\\main.py"]
    }
  }
}
  1. Replace the path with the full path to your main.py file
  2. Run the server:
py -3.13 main.py
  1. Keep the server running while using Claude Desktop

Available Weather Tools

Current Weather

The get_current_weather tool provides real-time weather conditions:

{
    "location": {
        "name": "New York",
        "country": "US",
        "lat": 40.7128,
        "lon": -74.006
    },
    "temperature": {
        "current": 25.6,
        "feels_like": 26.2,
        "min": 23.4,
        "max": 27.8
    },
    "weather_condition": {
        "main": "Clear",
        "description": "clear sky",
        "icon": "01d"
    },
    "wind": {
        "speed": 3.6,
        "deg": 220
    },
    "clouds": 5,
    "humidity": 65,
    "pressure": 1015,
    "visibility": 10000,
    "sunrise": "2025-03-16T06:12:34",
    "sunset": "2025-03-16T18:04:23",
    "timestamp": "2025-03-16T14:30:00"
}

Weather Forecast

The get_weather_forecast tool provides forecasts for up to 5 days:

{
    "location": {
        "name": "London",
        "country": "GB",
        "lat": 51.5074,
        "lon": -0.1278
    },
    "forecast": [
        {
            "datetime": "2025-03-16T15:00:00",
            "temperature": {
                "temp": 18.2,
                "feels_like": 17.8,
                "min": 17.5,
                "max": 19.1
            },
            "weather_condition": {
                "main": "Rain",
                "description": "light rain",
                "icon": "10d"
            },
            "wind": {
                "speed": 4.2,
                "deg": 180
            },
            "clouds": 75,
            "humidity": 82,
            "pressure": 1010,
            "visibility": 8000,
            "pop": 0.4
        }
        // ... more forecast items
    ],
    "days": 5
}

Air Quality Information

The get_air_quality tool provides pollution data:

{
    "location": {
        "name": "Beijing",
        "country": "CN",
        "lat": 39.9042,
        "lon": 116.4074
    },
    "air_quality_index": 3,
    "air_quality_level": "Moderate",
    "components": {
        "co": 250.34,
        "no": 0.5,
        "no2": 15.2,
        "o3": 140.8,
        "so2": 5.1,
        "pm2_5": 8.2,
        "pm10": 12.3,
        "nh3": 0.7
    },
    "timestamp": "2025-03-16T14:30:00"
}

Historical Weather

The get_historical_weather tool provides data from the last 5 days:

{
    "location": {
        "name": "Paris",
        "country": "FR",
        "lat": 48.8566,
        "lon": 2.3522
    },
    "date": "2025-03-14",
    "temperature": {
        "temp": 20.3,
        "feels_like": 19.8
    },
    "weather_condition": {
        "main": "Clouds",
        "description": "scattered clouds",
        "icon": "03d"
    },
    "wind": {
        "speed": 2.8,
        "deg": 150
    },
    "clouds": 45,
    "humidity": 60,
    "pressure": 1012,
    "visibility": 10000,
    "sunrise": "2025-03-14T06:30:45",
    "sunset": "2025-03-14T18:15:22",
    "timestamp": "2025-03-14T12:00:00"
}

Location Search

The search_location tool helps find places by name:

{
    "results": [
        {
            "name": "Tokyo",
            "state": "",
            "country": "JP",
            "lat": 35.6762,
            "lon": 139.6503
        },
        {
            "name": "Tokyo",
            "state": "Tokyo",
            "country": "JP",
            "lat": 35.6895,
            "lon": 139.6917
        }
        // ... more results
    ]
}

Weather Alerts

The get_weather_alerts tool provides warnings and advisories:

{
    "location": {
        "name": "Miami",
        "country": "US",
        "lat": 25.7617,
        "lon": -80.1918
    },
    "alerts": [
        {
            "sender": "NWS Miami",
            "event": "Heat Advisory",
            "start": "2025-03-16T12:00:00",
            "end": "2025-03-16T20:00:00",
            "description": "Heat index values between 105 and 110 expected",
            "tags": ["Extreme temperature value"]
        }
        // ... more alerts if any
    ],
    "alert_count": 1
}

Using with Claude

You can ask Claude natural language questions like:

  • "What's the current weather in New York?"
  • "Show me the 5-day forecast for London"
  • "What's the air quality like in Beijing today?"
  • "How was the weather in Paris on March 14th?"
  • "Search for locations named 'Tokyo'"
  • "Are there any weather alerts for Miami?"

Troubleshooting

If the server isn't working properly:

  • Ensure the server is running (you should see output when starting the script)
  • Verify the path in your settings is correct and absolute
  • Make sure Python 3.10+ is in your system PATH
  • Check all dependencies are installed
  • Try restarting Claude Desktop

Common API Issues

  • API Key Activation: New OpenWeatherMap API keys may take up to 24 hours to activate
  • Invalid API Key Error: If you get a 401 error, verify your API key is correct and active
  • Rate Limiting: Free tier allows up to 60 calls per minute, which might be exceeded during heavy usage

How to add this MCP server to Cursor

There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json file so that it is available in all of your projects.

If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json file.

Adding an MCP server to Cursor globally

To add a global MCP server go to Cursor Settings > MCP and click "Add new global MCP server".

When you click that button the ~/.cursor/mcp.json file will be opened and you can add your server like this:

{
    "mcpServers": {
        "cursor-rules-mcp": {
            "command": "npx",
            "args": [
                "-y",
                "cursor-rules-mcp"
            ]
        }
    }
}

Adding an MCP server to a project

To add an MCP server to a project you can create a new .cursor/mcp.json file or add it to the existing one. This will look exactly the same as the global MCP server example above.

How to use the MCP server

Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.

The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.

You can also explictly ask the agent to use the tool by mentioning the tool name and describing what the function does.

Want to 10x your AI skills?

Get a free account and learn to code + market your apps using AI (with or without vibes!).

Nah, maybe later