Skip to main content

A weather MCP server using WeatherAPI

Project description

weather-mcp

A weather MCP server powered by WeatherAPI. Works with Claude and any MCP-compatible client.

Installation

pip install weather-mcp-v1

Setup

  1. Get a free API key from weatherapi.com
  2. Create a .env file in your working directory:
WEATHER_API_KEY=your_api_key_here

Or set it as an environment variable:

# Linux/Mac
export WEATHER_API_KEY=your_api_key_here

# Windows (PowerShell)
$env:WEATHER_API_KEY="your_api_key_here"

Usage

The server supports two transport modes — stdio for local development and SSE for remote/production deployment.

Mode 1 — stdio (Local Development)

No separate server process needed. The client spawns and manages the server automatically.

from mcp import ClientSession, StdioServerParameters
from mcp.client.stdio import stdio_client

server_params = StdioServerParameters(
    command="python",
    args=["-m", "weather_mcp.server"],
    env={"WEATHER_API_KEY": "your_api_key_here"}
)

async with stdio_client(server_params) as (read, write):
    async with ClientSession(read, write) as session:
        await session.initialize()
        tools = await session.list_tools()

Mode 2 — SSE (Remote / Production)

Run the server independently and connect to it over HTTP.

Start the server:

# Linux/Mac
MCP_TRANSPORT=sse weather-mcp

# Windows (PowerShell)
$env:MCP_TRANSPORT="sse"; weather-mcp

Server starts at http://localhost:8000/sse

Connect from your client:

from mcp.client.sse import sse_client
from mcp import ClientSession

async with sse_client("http://localhost:8000/sse") as (read, write):
    async with ClientSession(read, write) as session:
        await session.initialize()
        tools = await session.list_tools()

When hosted remotely, just change the URL:

async with sse_client("https://your-server.railway.app/sse") as (read, write):
    ...

Connect with Claude Desktop

Add this to your claude_desktop_config.json:

{
  "mcpServers": {
    "weather": {
      "command": "weather-mcp",
      "env": {
        "WEATHER_API_KEY": "your_api_key_here"
      }
    }
  }
}

Environment Variables

Variable Required Default Description
WEATHER_API_KEY Yes Your WeatherAPI key from weatherapi.com
MCP_TRANSPORT No stdio Transport mode: stdio or sse

Available Tools

get_weather

Fetches current weather for a given location.

Input:

  • location (string) — city name, postal code, or coordinates (e.g. "New York", "10001", "48.8566,2.3522")

Output: Full weather JSON from WeatherAPI including:

  • Temperature (Celsius and Fahrenheit)
  • Condition and description
  • Humidity, wind speed, visibility
  • Feels like temperature

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

weather_mcp_v1-0.1.2.tar.gz (2.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

weather_mcp_v1-0.1.2-py3-none-any.whl (3.4 kB view details)

Uploaded Python 3

File details

Details for the file weather_mcp_v1-0.1.2.tar.gz.

File metadata

  • Download URL: weather_mcp_v1-0.1.2.tar.gz
  • Upload date:
  • Size: 2.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.0

File hashes

Hashes for weather_mcp_v1-0.1.2.tar.gz
Algorithm Hash digest
SHA256 12de6cbb513ede9a61c91d830ba6027c2120e6989b35263ab9092cccaf6e63ee
MD5 fe00cc1062bd470f6bb5de4ddd7e437a
BLAKE2b-256 2d6d74f4fda68d2715ac25330629f919c46d2e8b24d861998d04832e23a1b6a4

See more details on using hashes here.

File details

Details for the file weather_mcp_v1-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: weather_mcp_v1-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 3.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.0

File hashes

Hashes for weather_mcp_v1-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 af6a66305a93d7197ff47e09ab4dcd0f5e3ebf5897dc955f15d28b0c99276234
MD5 9313a02340d666daf428c92fc4a711ba
BLAKE2b-256 c3cbcd6aa8da805cb5394b4554a12046f18141e1be6a8d3ba8db4a677cf91e38

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page