home / mcp / weather mcp server

Weather MCP Server

Provides live weather data by location via an MCP tool backed by the OpenWeatherMap API.

Installation
Add the following to your MCP client configuration file.

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.

How to use

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.

How to install

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/activate

2) Synchronize dependencies with uv to install required packages.

uv sync

3) 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_here

4) 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.py

Additional configuration and examples

You 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"
      }
    }
  }
}

What you can do with the weather tool

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.

Available tools

get_weather

Get current weather for a location