# MCP Server — Design Capture

De Design Capture app exposeert 6 tools via het Model Context Protocol (MCP).
Andere apps kunnen hiermee programmatisch design data opvragen en captures starten.

## Connectie

### Via SSE (HTTP, aanbevolen voor externe apps)

```yaml
# In Hermes config.yaml of andere MCP-client
mcp_servers:
  design-capture:
    transport: sse
    url: http://design-capture-web-1:80/mcp
```

### Via stdio (direct Python)

```bash
python /app/app/mcp/server.py
```

## Tools

### `design_list_companies`

Toon alle bedrijven waarvan design tokens zijn opgeslagen.

**Parameters**: geen

**Response**: Lijst met company ID, naam, domein, datum.

**Voorbeeld**:
```
**Captured Companies:**
- ID 1: Example Corp
  Domain: example.com
  Captured: 2026-05-17 22:30
```

---

### `design_get_tokens`

Haal alle design tokens op voor een bedrijf.

**Parameters**:
| Parameter | Type | Verplicht | Beschrijving |
|---|---|---|---|
| `company_id` | integer | ✅ | Company ID (uit `design_list_companies`) |

**Response**: JSON met company info, colors, typography, spacing, borders, gradients, assets, breakpoints.

**Voorbeeld**:
```json
{
  "company": { "id": 1, "name": "Example Corp", "domain": "example.com" },
  "colors": [
    { "hex": "#1a1a2e", "role": "primary", "css_var": "--color-primary" },
    { "hex": "#e94560", "role": "accent", "css_var": "--color-accent" }
  ],
  "typography": [
    { "font_family": "Inter", "usage_tag": "body", "font_size": "16px" },
    { "font_family": "Poppins", "usage_tag": "h1", "is_heading": 1 }
  ]
}
```

---

### `design_capture_website`

Start een nieuwe design capture voor een website.

**Parameters**:
| Parameter | Type | Verplicht | Beschrijving |
|---|---|---|---|
| `company_name` | string | ✅ | Naam van het bedrijf |
| `url` | string | ✅ | Volledige URL (bv. https://example.com) |

**Response**: Statusbericht met company ID, capture ID, en aantallen.

**Voorbeeld**:
```
✅ Capture complete for Example Corp!

Company ID: 1
Capture ID: 1

Colors: 12
Fonts: 8
```

**Let op**: dit is een synchrone call. Bij grote sites kan het 10-30 seconden duren.

---

### `design_search`

Doorzoek alle opgeslagen design data.

**Parameters**:
| Parameter | Type | Verplicht | Beschrijving |
|---|---|---|---|
| `query` | string | ✅ | Zoekterm (bedrijfsnaam, kleur hex, font naam) |

**Response**: Overzicht van matching companies, colors, typography.

**Voorbeeld**:
```
**Companies:**
- ID 1: Example Corp (example.com)

**Colors:**
- #1a1a2e (primary) — Example Corp

**Typography:**
- Inter (body) — Example Corp
```

---

### `design_generate_css`

Genereer CSS custom properties voor een bedrijf.

**Parameters**:
| Parameter | Type | Verplicht | Beschrijving |
|---|---|---|---|
| `company_id` | integer | ✅ | Company ID |

**Response**: CSS met `:root { ... }` block.

**Voorbeeld**:
```css
/* Design tokens for Example Corp */
:root {
  --color-primary: #1a1a2e;
  --color-accent: #e94560;
  --font-body-family: 'Inter', sans-serif;
  --font-heading-family: 'Poppins', sans-serif;
  --font-heading-size: 48px;
  --padding: 24px;
}
```

---

### `design_export_theme`

Exporteer het complete theme als gestructureerd JSON.

**Parameters**:
| Parameter | Type | Verplicht | Beschrijving |
|---|---|---|---|
| `company_id` | integer | ✅ | Company ID |

**Response**: Genest JSON-object met `theme.colors`, `theme.typography`, `theme.spacing`, `theme.borderRadius`, `theme.shadows`, `theme.breakpoints`.

**Voorbeeld**:
```json
{
  "theme": {
    "name": "Example Corp",
    "domain": "example.com"
  },
  "colors": {
    "primary": { "--color-primary": "#1a1a2e" },
    "accent": { "--color-accent": "#e94560" },
    "background": { "--bg": "#ffffff" },
    "text": { "--text": "#333333" }
  },
  "typography": {
    "body": { "fontFamily": "Inter", "fontSize": "16px" },
    "heading": { "fontFamily": "Poppins", "fontWeight": "700" }
  }
}
```

## Foutafhandeling

- Onbekende company ID → "Company ID X not found."
- Capture mislukt → "❌ Capture failed: <error message>"
- Geen resultaten bij search → "No results found for 'X'."
- Onbekend tool → "Unknown tool: X"
