home / mcp / weather mcp server
Provides live weather data by location via an MCP tool backed by the OpenWeatherMap API.
Configuration
View docs{
"mcpServers": {
"billumi-mcp-sample": {
"command": "mcp",
"args": [
"dev",
"src/mcp_weather.py"
],
"env": {
"OPENWEATHER_API_KEY": "your_api_key_here"
}
}
}
}You build a lightweight MCP (Model Context Protocol) weather server that exposes a tool to fetch current weather data for a location using the OpenWeatherMap API. This server lets AI agents query real-time weather information through a simple, client-friendly interface.
You interact with the weather MCP server through an MCP client. Once the server is running, your AI agent can invoke the weather tool by providing a location, and the server will return the current weather data for that location. Use the tool to integrate live weather queries into your prompts, dashboards, or automations.
Prerequisites: you need a machine with Python-compatible tooling and the uv runtime for MCPs.
1) Create and activate a Python virtual environment using uv.
uv venv
source .venv/bin/activate2) Synchronize dependencies with uv to install required packages.
uv sync3) Prepare your OpenWeatherMap API key by obtaining a key from your account dashboard and exporting it as an environment variable.
export OPENWEATHER_API_KEY=your_api_key_here4) Run the MCP server for weather data. The server is started in development mode with the path to the main script.
mcp dev src/mcp_weather.pyYou can configure the MCP client to connect to the weather server using a local CLI-based setup. The following example shows a typical entry you would place in your MCP client configuration to point at the weather tool.
{
"mcpServers": {
"weather": {
"command": "uv",
"args": ["dev", "src/mcp_weather.py"],
"env": {
"OPENWEATHER_API_KEY": "your_api_key_here"
}
}
}
}The weather tool exposes a function named get_weather that takes a location and returns current conditions for that location. You can expose this as a capability in your prompts so your AI agent can request live weather data by location name.
Get current weather for a location