Metadata-Version: 2.4
Name: weather-mcp-v1
Version: 0.1.2
Summary: A weather MCP server using WeatherAPI
Project-URL: Homepage, https://github.com/yourusername/weather-mcp
License: MIT
Keywords: ai,claude,mcp,weather
Requires-Python: >=3.10
Requires-Dist: mcp>=1.0.0
Requires-Dist: pydantic>=2.0.0
Requires-Dist: python-dotenv>=1.0.0
Requires-Dist: requests>=2.31.0
Description-Content-Type: text/markdown

# weather-mcp

A weather MCP server powered by [WeatherAPI](https://www.weatherapi.com/). Works with Claude and any MCP-compatible client.

## Installation

```bash
pip install weather-mcp-v1
```

## Setup

1. Get a free API key from [weatherapi.com](https://www.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:

```bash
# 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.

```python
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:**
```bash
# 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:**
```python
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:
```python
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`:

```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
