Skip to main content
Glama
README.md
# Weather MCP Server

A Model Context Protocol (MCP) server that provides weather information using the National Weather Service (NWS) API.

## Features

- Get weather forecasts for any US location
- Check current weather conditions
- View active weather alerts by state
- Built-in caching to reduce API calls

## Installation

### 1. Clone the repository

```bash
git clone https://github.com/YOUR_USERNAME/weather-mcp-server.git
cd weather-mcp-server
```

### 2. Create a virtual environment and install

```bash
python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate
pip install -e .
```

This installs the package and all its dependencies (mcp, httpx) automatically.

## Configuration for Claude Desktop

### macOS
Edit `~/Library/Application Support/Claude/claude_desktop_config.json`:

```json
{
  "mcpServers": {
    "weather": {
      "command": "/ABSOLUTE/PATH/TO/YOUR/weather-mcp-server/venv/bin/python",
      "args": ["-m", "weather.main"],
      "cwd": "/ABSOLUTE/PATH/TO/YOUR/weather-mcp-server"
    }
  }
}
```

### Windows
Edit `%APPDATA%\Claude\claude_desktop_config.json`:

```json
{
  "mcpServers": {
    "weather": {
      "command": "C:\\ABSOLUTE\\PATH\\TO\\YOUR\\weather-mcp-server\\venv\\Scripts\\python.exe",
      "args": ["-m", "weather.main"],
      "cwd": "C:\\ABSOLUTE\\PATH\\TO\\YOUR\\weather-mcp-server"
    }
  }
}
```

**Important**: Replace `/ABSOLUTE/PATH/TO/YOUR/` with your actual path. You can get it by running `pwd` (macOS/Linux) or `cd` (Windows) in the project directory.

### After configuration

1. Save the config file
2. **Completely quit and restart Claude Desktop** (Cmd+Q on macOS, not just close window)
3. In Claude connectors you can see your tools.

## Available Tools

- **get_forecast(latitude, longitude)** - Get 5-period weather forecast
- **get_current_conditions(latitude, longitude)** - Get current weather conditions
- **get_alerts(state)** - Get active weather alerts for a US state (use 2-letter code like "CA", "NY")
- **get_metrics()** - View server usage statistics

## Usage Examples

Once configured in Claude Desktop, you can ask:
- "What's the weather forecast for New York City?"
- "Are there any weather alerts in California?"
- "What are the current conditions in Chicago?"

## Development

### Running tests
```bash
# Test the server manually
python -m weather.main
```

The server should output:
```
2025-12-16 14:51:11,260 INFO Starting weather MCP server
=== MCP server running ===
```

Press Ctrl+C to stop.

## Troubleshooting

### Server not appearing in Claude

1. **Check the config file path** is correct for your OS
2. **Use absolute paths** in the config (not relative paths or ~)
3. **Restart Claude Desktop completely** (Quit, don't just close)
4. **Check logs** (macOS: `~/Library/Logs/Claude/mcp*.log`)

### ModuleNotFoundError

Make sure you:
1. Activated your virtual environment: `source venv/bin/activate`
2. Installed the package: `pip install -e .`

### Connection issues

The server uses the National Weather Service API which:
- Only works for US locations
- May have occasional downtime
- Has built-in caching (60 second TTL)

## License

MIT

## Contributing

Pull requests are welcome! Please feel free to submit issues or improvements.