Skip to main content
Glama
PlantUML SLD MCP Server

PlantUML SLD MCP Server

by puran-water
README.md
# PlantUML SLD MCP Server

MCP server for generating electrical Single-Line Diagrams (SLDs) using PlantUML.

## Features

- Generate SLD diagrams from YAML topology definitions
- Bootstrap topology from load-list-skill output
- Support for multiple distribution templates (radial, redundant, generator)
- System view (collapsed) and detailed view (expanded) rendering
- Shareable PlantUML URLs for collaboration
- Machine-readable YAML topology as source of truth

## Installation

```bash
# Using uv
uv pip install -e .

# With optional pandapower analysis
uv pip install -e ".[analysis]"

# With dev dependencies
uv pip install -e ".[dev]"
```

## PlantUML Backend

The server requires a PlantUML backend. Install one of:

1. **Native binary** (recommended):
   ```bash
   apt install plantuml
   ```

2. **Java JAR**:
   ```bash
   export PLANTUML_JAR=/path/to/plantuml.jar
   ```

3. **Docker**:
   ```bash
   docker pull plantuml/plantuml
   ```

## MCP Tools

| Tool | Description |
|------|-------------|
| `sld_validate_topology` | Validate SLD topology YAML against schema |
| `sld_get_plantuml_source` | Generate PlantUML source from topology |
| `sld_get_plantuml_source_per_bus` | Generate PlantUML source for a single bus/MCC |
| `sld_generate_diagram` | Render diagram to PNG/SVG |
| `sld_encode_plantuml` | Generate shareable PlantUML URLs |
| `sld_check_plantuml` | Check PlantUML backend availability |
| `sld_list_symbols` | List available electrical symbols |
| `sld_bootstrap_from_loadlist` | Create topology from load-list-skill output |

## Usage

### Claude Code Configuration

Add to your Claude Code MCP settings:

```json
{
  "mcpServers": {
    "plantuml-sld": {
      "command": "uv",
      "args": ["run", "--directory", "/path/to/plantuml-sld-mcp-server", "plantuml-sld-mcp"]
    }
  }
}
```

### Example Workflow

1. **Bootstrap from load list**:
   ```yaml
   # Use sld_bootstrap_from_loadlist with load-list.yaml
   # Choose distribution template: single_utility_radial
   ```

2. **Validate topology**:
   ```yaml
   # Use sld_validate_topology to check for errors
   ```

3. **Generate diagram**:
   ```yaml
   # Use sld_generate_diagram for PNG/SVG output
   # Or sld_encode_plantuml for shareable URL
   ```

## Topology Schema

See `schemas/sld-topology.schema.yaml` in electrical-distribution-skill for the full schema.

### Key Components

- **Buses**: Main switchboards, MCCs, distribution panels
- **Equipment**: Utilities, transformers, breakers, motors, VFDs
- **Connections**: Feeders, bus ties, control circuits

### Distribution Templates

| Template | Description |
|----------|-------------|
| `single_utility_radial` | Utility → Transformer → MSB → MCCs |
| `utility_plus_generator` | Adds standby generator with ATS |
| `dual_utility_redundant` | Split bus with tie breaker |

## View Modes

- **System View**: Collapsed buses with aggregated loads
- **Detailed View**: Individual feeders and equipment per bus

## Development

```bash
# Run tests
pytest

# Run with coverage
pytest --cov=src

# Lint
ruff check src tests
```

## Workflow Integration

This server is part of the puran-water electrical engineering workflow:

```
┌─────────────────────────┐     ┌──────────────────────────┐     ┌─────────────────────┐
│  equipment-list-skill   │ ──► │    load-list-skill       │ ──► │ electrical-         │
│  (equipment + power_kw) │     │    (FLC, protection,     │     │ distribution-skill  │
└─────────────────────────┘     │     MCC schedules)       │     │ (SLD generation)    │
                                └──────────────────────────┘     └─────────────────────┘
                                             │                              │
                                             │                              ▼
                                             │                   ┌─────────────────────┐
                                             └──────────────────►│ plantuml-sld-mcp    │
                                                                 │ (this server)       │
                                                                 └─────────────────────┘
                                                                            │
                                                                            ▼
                                                                 ┌─────────────────────┐
                                                                 │ PlantUML PNG/SVG    │
                                                                 │ + shareable URLs    │
                                                                 └─────────────────────┘
```

## Related Projects

### Upstream (Data Sources)
- [load-list-skill](https://github.com/puran-water/load-list-skill) - NEC/IEC-compliant electrical load lists with MCC schedules
- [equipment-list-skill](https://github.com/puran-water/equipment-list-skill) - Equipment lists with power ratings and feeder types

### Companion Skill
- [electrical-distribution-skill](https://github.com/puran-water/electrical-distribution-skill) - Claude Code skill that orchestrates this MCP server

### Similar Pattern
- [plantuml-csa-mcp-server](https://github.com/puran-water/plantuml-csa-mcp-server) - Control System Architecture diagrams (same YAML → PlantUML pattern)
- [csa-diagram-skill](https://github.com/puran-water/csa-diagram-skill) - CSA skill using plantuml-csa-mcp-server

## License

MIT License - Puran Water