
An MCP (Model Context Protocol) tool that provides real-time weather data, forecasts, and historical weather information using the OpenWeatherMap API, specifically designed for Claude Desktop.
概览
An MCP (Model Context Protocol) tool that provides real-time weather data, forecasts, and historical weather information using the OpenWeatherMap API, specifically designed for Claude Desktop. For a detailed guide on setting up and using this tool, check out our comprehensive Medium tutorial: Tutorial: Using Claude Desktop with Weather MCP Tool to Access Real-Time Weather Data Worldwide - Real-time weather conditions for any location - Weather forecasts (up to 5 days) - Historical weather data (last 5 days) - Air quality information - Weather alerts and warnings - Location search functionality 1. Ensure you have Python 3.10 or higher installed 3. Get an API key from OpenWeatherMap (free tier available) - Note: New API keys may take up to 24 hours to activate 4. Set up environment variables for API key (recommended method): - Create a .env file in the project directory - Add your API key to the file: - Add .env to your .gitignore file to prevent committing sensitive data 5.
README
以下为原文 README 节选,完整内容请查看原文。
Weather MCP Tool for Claude Desktop
An MCP (Model Context Protocol) tool that provides real-time weather data, forecasts, and historical weather information using the OpenWeatherMap API, specifically designed for Claude Desktop.
Tutorial
For a detailed guide on setting up and using this tool, check out our comprehensive Medium tutorial: Tutorial: Using Claude Desktop with Weather MCP Tool to Access Real-Time Weather Data Worldwide
Features
- Real-time weather conditions for any location
- Weather forecasts (up to 5 days)
- Historical weather data (last 5 days)
- Air quality information
- Weather alerts and warnings
- Location search functionality
Setup
-
Ensure you have Python 3.10 or higher installed
-
Install dependencies:
pip install -r requirements.txt
-
Get an API key from OpenWeatherMap (free tier available)
- Note: New API keys may take up to 24 hours to activate
-
Set up environment variables for API key (recommended method):
- Create a
.envfile in the project directory - Add your API key to the file:
OPENWEATHER_API_KEY=your_openweathermap_api_key- Add
.envto your.gitignorefile to prevent committing sensitive data
- Create a
-
Update
main.pyto 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")
Integration with Claude Desktop
- Configure your MCP settings in Claude Desktop by adding the following to your MCP configuration:
{
"mcpServers": {
"weather-mcp": {
"command": "py",
"args": ["-3.13", "C:\\Path\\To\\Your\\Weather-MCP-ClaudeDesktop\\main.py"]
}
}
}
- Replace the path with the full path to your main.py file
- Run the server using:
py -3.13 main.py
- Keep the server running while using Claude Desktop
Available Tools
1. get_current_weather
Get real-time weather conditions for a location:
{
"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"
}
2. get_weather_forecast
Get weather forecast for a location:
{
"location": {
安装
This server does not publish a one-line install command.
Open the repository installation guide 新手?先看 mcpskill.org 教程 →配置
{
"mcpServers": {
"weather-mcp": {
"command": "py",
"args": ["-3.13", "C:\\Path\\To\\Your\\Weather-MCP-ClaudeDesktop\\main.py"]
}
}
}