- Home
- MCP servers
- OpenWeather
OpenWeather
- python
7
GitHub Stars
python
Language
6 months ago
First Indexed
2 months ago
Catalog Refreshed
Documentation & install
Readme and setup notes from the catalogue, plus a client-ready config you can copy for your MCP host.
Installation
Add the following to your MCP client configuration file.
Configuration
View docs{
"mcpServers": {
"zippland-weather-mcp": {
"command": "python",
"args": [
"/full_path/weather_mcp_server.py"
],
"env": {
"OPENWEATHER_API_KEY": "your_openweathermap_key_here"
}
}
}
}OpenWeather MCP Server provides global weather forecasts and current weather conditions through a simple MCP (Model Control Protocol) interface. You can run a Python-based server locally, provide your OpenWeatherMap API key, and query weather data from any MCP-enabled client. This makes it easy to integrate reliable weather data into your apps and workflows without building your own weather API layer.
How to use
You run the weather MCP server locally and connect to it from an MCP client. Start by providing your OpenWeatherMap API key and then invoke the weather endpoints to get current conditions or forecasts for any location.
Run the server with the API key supplied via environment variable or as a parameter when starting the program.
To configure the MCP client, point it to the stdio-based server command and ensure the API key variable is available in the client’s environment. The two available tools let you fetch current weather and forecasts for a specified location.
How to install
Prerequisites: you need Python installed on your system.
pip install mcp-server requests pydantic
Set your OpenWeatherMap API key and start the server using one of the two methods.
# Method 1: Using Environment Variables
export OPENWEATHER_API_KEY="your_api_key" # Linux/Mac
set OPENWEATHER_API_KEY=your_api_key # Windows
# Run the server
python weather_mcp_server.py
# Method 2: Provide When Calling the Tool
python weather_mcp_server.py
When calling the tool, you can supply the api_key parameter if desired.
## Configuration and usage notes
Environment variable to set: OPENWEATHER\_API\_KEY. This key is used by the server to authenticate requests to the OpenWeatherMap API.
Optional client configuration allows you to pass the API key and specify the location and timezone offset when requesting data.
Example client configuration to use the weather MCP server (as part of a larger MCP client configuration):
{ "weather_forecast": { "command": "python", "args": [ "/full_path/weather_mcp_server.py" ], "env": { "OPENWEATHER_API_KEY": "your_openweathermap_key_here" }, "disabled": false, "autoApprove": ["get_weather", "get_current_weather"] } }
## Available tools and parameters
get\_weather returns current weather and a future forecast for a specified location.
Parameters:
- location: name of the location (e.g., "Beijing", "New York", "Tokyo")
- api\_key: OpenWeatherMap API key (optional; reads from environment variable if not provided)
- timezone\_offset: timezone offset in hours (e.g., 8 for Beijing, -4 for New York); defaults to 0 (UTC)
get\_current\_weather returns the current weather for a specified location.
Parameters:
- location: name of the location (e.g., "Beijing", "New York", "Tokyo")
- api\_key: OpenWeatherMap API key (optional; reads from environment variable if not provided)
- timezone\_offset: timezone offset in hours (e.g., 8 for Beijing, -4 for New York); defaults to 0 (UTC)
## Troubleshooting
If you encounter a missing API key error, ensure OPENWEATHER\_API\_KEY is set in your environment or provide api\_key when calling the tools.
If the location name is not recognized, try a more precise city name or include a country code, for example "Beijing,CN" or "Paris,FR".
## Available tools
### get\_weather
Fetch current weather and a multi-hour forecast for a given location, with optional API key and timezone offset.
### get\_current\_weather
Fetch the current weather for a given location with optional API key and timezone offset.