- Home
- MCP servers
- Weather
Weather
- python
1
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.
You set up a Python-based MCP server that lets a language model fetch live weather information from OpenWeather API by exposing a fetch_weather tool. This enables real-time, location-based queries to be answered with up-to-date weather data while keeping the integration scalable and easy to customize.
How to use
To use this MCP server, run the server locally and connect an MCP client that can send tool calls to the fetch_weather endpoint. You can ask the agent about current conditions for any location, and the agent will dynamically retrieve weather data from OpenWeather through the exposed tool.
How to install
Prerequisites you need before starting:
- Python 3.8 or newer installed on your machine
- A Python virtual environment tool (optional but recommended)
- Access to an OpenWeather API key
- Access to an OpenAI API key if you plan to use an OpenAI model through the MCP workflow
- Git to clone any sample code if you want to mirror the setup locally
# clone the sample project (if you are following the example)
git clone https://example.com/llamaindex-mcp-openweather-agent
cd llamaindex-mcp-openweather-agent
# create and activate a virtual environment
python3 -m venv venv
source venv/bin/activate
# install dependencies
pip install "mcp>=1.9.1,<2" python-dotenv llama_index llama-index-tools-mcp llama-index-llms-google-genai
# copy example env and configure keys
cp .env.example .env
# edit the .env file to set YOUR_OPENAI_API_KEY and YOUR_OPENWEATHER_API_KEY
# run the MCP server (stdio config)
python mcp_server.py --server_type=sse
Additional setup notes
-
Ensure your .env contains your OpenAI API key and your OpenWeather API key. These keys are required for the MCP server to perform language model calls and live weather data fetches.
-
The MCP server exposes a tool named fetch_weather. This tool retrieves current weather data for a specified location via the OpenWeather API.
-
Start the server with the provided command and then run your MCP client or notebook to interactively query weather information. For example, you can ask for the weather in a city and the agent will respond with the current conditions, temperature, and humidity sourced from OpenWeather.
Examples
User: What is the weather in Addis Ababa? Agent: The current weather in Addis Ababa is clear sky, with a temperature of 21.7°C and 37% humidity.
Available tools
fetch_weather
Fetches current weather data for a given location from the OpenWeather API via the MCP tool interface.