Skip to main content
Glama
Lumeo-sd

opensprinkler-mcp

by Lumeo-sd
README.md
# OpenSprinkler MCP Server

MCP server for managing OpenSprinkler controllers via Claude Desktop.

## Available Tools

| Tool | Description |
|------|-------------|
| `get_controller_status` | Get controller status (device time, enabled state, rain delay) |
| `get_stations` | Get all stations with their current status |
| `run_station` | Start a station for a specified duration |
| `stop_station` | Stop a running station |
| `stop_all_stations` | Stop all running stations immediately |
| `set_rain_delay` | Set rain delay in hours (0 to clear) |
| `enable_controller` | Enable or disable the controller |
| `reboot_controller` | Reboot the OpenSprinkler controller |
| `get_programs` | Get all watering programs |
| `get_options` | Get controller options and settings |

## Configuration

### Environment Variables

| Variable | Description | Default |
|----------|-------------|---------|
| `OPEN_SPRINKLER_HOST` | IP address of OpenSprinkler | localhost |
| `OPEN_SPRINKLER_PASSWORD` | Password (plain text or MD5 hash) | (empty) |
| `OPEN_SPRINKLER_PORT` | HTTP port | 80 |

---

## Docker

### Build Image

```bash
docker build -t opensprinkler-mcp .
```

### Run Manually (Test)

```bash
docker run -i --rm ^
  -e OPEN_SPRINKLER_HOST=192.168.1.100 ^
  -e OPEN_SPRINKLER_PASSWORD=your_password ^
  opensprinkler-mcp
```

**Windows (PowerShell):**
```powershell
docker run -i --rm `
  -e OPEN_SPRINKLER_HOST=192.168.1.100 `
  -e OPEN_SPRINKLER_PASSWORD=your_password `
  opensprinkler-mcp
```

**Linux/Mac:**
```bash
docker run -i --rm \
  -e OPEN_SPRINKLER_HOST=192.168.1.100 \
  -e OPEN_SPRINKLER_PASSWORD=your_password \
  opensprinkler-mcp
```

### Auto-Start Options

#### Option 1: Docker Compose (Recommended)

Create `docker-compose.yml`:

```yaml
version: '3.8'

services:
  opensprinkler-mcp:
    image: opensprinkler-mcp
    container_name: opensprinkler-mcp
    restart: unless-stopped
    environment:
      - OPEN_SPRINKLER_HOST=192.168.1.100
      - OPEN_SPRINKLER_PASSWORD=your_password
```

Start:
```bash
docker compose up -d
```

#### Option 2: Docker Run with Restart

```bash
docker run -d --name opensprinkler-mcp ^
  --restart unless-stopped ^
  -e OPEN_SPRINKLER_HOST=192.168.1.100 ^
  -e OPEN_SPRINKLER_PASSWORD=your_password ^
  opensprinkler-mcp
```

---

## Claude Desktop Configuration

Add to your `claude_desktop_config.json`:

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

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

### Linux
```
~/.config/Claude/claude_desktop_config.json
```

#### Docker (Recommended)
```json
{
  "mcpServers": {
    "opensprinkler": {
      "command": "docker",
      "args": [
        "run",
        "-i",
        "--rm",
        "-e",
        "OPEN_SPRINKLER_HOST=192.168.1.100",
        "-e",
        "OPEN_SPRINKLER_PASSWORD=your_password",
        "opensprinkler-mcp"
      ]
    }
  }
}
```

#### Pre-built Container (with auto-restart)
```json
{
  "mcpServers": {
    "opensprinkler": {
      "command": "docker",
      "args": [
        "run",
        "--rm",
        "-e",
        "OPEN_SPRINKLER_HOST=192.168.1.100",
        "-e",
        "OPEN_SPRINKLER_PASSWORD=your_password",
        "opensprinkler-mcp"
      ]
    }
  }
}
```

---

## Examples

### Get all stations status
```
What stations are currently running?
```

### Start a station
```
Run station 0 for 10 minutes
```

### Set rain delay
```
Set 24 hour rain delay
```

---

## Password

The OpenSprinkler API accepts both plain text passwords and MD5 hashes. You can generate an MD5 hash online or use the plain text password directly.

---

## Troubleshooting

### "Server disconnected" error

This usually means the MCP server is not running or not accessible. Try:

1. **Test Docker manually:**
   ```bash
   docker run -i --rm ^
     -e OPEN_SPRINKLER_HOST=YOUR_IP ^
     -e OPEN_SPRINKLER_PASSWORD=YOUR_PASSWORD ^
     opensprinkler-mcp
   ```
   If it runs without errors, press `Ctrl+C` to stop.

2. **Check your IP address** - make sure OpenSprinkler is reachable from your computer.

3. **Restart Claude Desktop** after changing configuration.