# Charmbracelet Crush

[Charmbracelet Crush](https://github.com/charmbracelet/crush) ist der glamouröse Coding-Agent. Mehr dazu findest du in [Charm Land](https://charm.land). Hier zeigen wir eine minimale Konfiguration, mit der du Crush mit der Aqueduct-Infrastruktur der TU Wien nutzen kannst.

### Crush konfigurieren { #configuring-crush }

Crush sucht eine Konfigurationsdatei entweder als `crush.json` im Ordner, aus dem du es startest, oder in deinem
Home-Verzeichnis unter `~/.config/crush/crush.json`.

``` json
{
  "$schema": "https://charm.land/crush.json",
  "providers": {
    "ollama": {
      "name": "aqueduct",
      "base_url": "https://aqueduct.ai.datalab.tuwien.ac.at/",
      "api_key": "sk-PASTE-YOUR-GLAMOUROUS-AQUEDUCT-KEY-HERE",
      "type": "openai",
      "models": [
        {
          "name": "qwen-3.8-27b",
          "id": "qwen-3.8-27b",
          "context_window": 130000,
          "default_max_tokens": 50000
        },
        {
          "name": "deepseek-v4-vision-exp-284b",
          "id": "deepseek-v4-vision-exp-284b",
          "context_window": 190000,
          "default_max_tokens": 50000
        },
        {
          "name": "glm-5.3-744b-experimental",
          "id": "glm-5.3-744b-experimental",
          "context_window": 130000,
          "default_max_tokens": 50000
        }
      ]
    }
  }
}
```

Mit `Ctrl`+`l` wechselst du in Crush während der Arbeit das Modell. `context_window` ist hier auf etwa die Hälfte des
tatsächlichen Kontextfensters der Modelle gesetzt. Crush überschreitet das Kontextfenster häufig. Mit einem niedrigeren
Wert startet die Zusammenfassung früher, was hoffentlich verhindert, dass das Kontextfenster vollläuft.

### MCP-Server von Aqueduct in Crush einbinden { #adding-aqueduct-hosted-mcp-servers-to-crush }

Auf der [Aqueduct-Website](https://aqueduct.ai.datalab.tuwien.ac.at/aqueduct/management/mcp-servers/) findest du
mehrere MCP-Server, die du in Crush nutzen kannst, etwa die Suche auf der TU-Website oder die Knowledge Base des Campus
IT Service. Crush ist aber nicht vollständig kompatibel damit, wie Aqueduct MCP-Server bereitstellt. Als Workaround
kannst du das folgende Wrapper-Skript verwenden. Setz `BASE_URL` auf die URL des MCP-Servers und `AUTH_HEADER` auf
deinen Authentifizierungs-Token:

```
#!/usr/bin/env python3
"""
MCP stdio wrapper for aqueduct MCP HTTP endpoints.
Translates stdio MCP protocol to HTTP Streamable protocol.
"""
import json
import sys
import requests

BASE_URL = "https://aqueduct.ai.datalab.tuwien.ac.at/mcp-servers/tu-search/mcp"
AUTH_HEADER = "Bearer sk-PASTE-YOUR-GLAMOUROUS-AQUEDUCT-KEY-HERE"

session = requests.Session()
session.headers.update({
    "Authorization": AUTH_HEADER,
    "Content-Type": "application/json",
})
session_id = None

def send_request(payload):
    global session_id
    headers = dict(session.headers)
    if session_id:
        headers["Mcp-Session-Id"] = session_id
    
    resp = session.post(BASE_URL, headers=headers, json=payload, timeout=30)
    
    # Capture session ID from response
    new_session_id = resp.headers.get("Mcp-Session-Id")
    if new_session_id:
        session_id = new_session_id
    
    return resp.json()

def main():
    for line in sys.stdin:
        try:
            msg = json.loads(line.strip())
            method = msg.get("method", "")

            # Handle notifications/initialized
            if method == "notifications/initialized":
                send_request(msg)
                # Don't respond to notifications

            # Handle ping
            elif method == "ping":
                print(json.dumps({"jsonrpc": "2.0", "id": msg.get("id"), "result": {}}), flush=True)

            else:
                # Handle all other possible methods with direct passthrough
                result = send_request(msg)
                print(json.dumps(result), flush=True)

        except Exception as e:
            error = {
                "jsonrpc": "2.0",
                "id": msg.get("id") if 'msg' in locals() else None,
                "error": {"code": -32603, "message": str(e)}
            }
            print(json.dumps(error), flush=True)

if __name__ == "__main__":
    main()
```

Danach kannst du den MCP-Server in deiner `crush.json` eintragen:

```
{
  "$schema": "https://charm.land/crush.json",
  "providers": {
  
  ...
  
  },
  "mcp": {
    "tu-search": {
      "type": "stdio",
      "command": "python3",
      "args": ["/path/to/the/wrapper/script/above.py"]
    }
  }
}
```

!!! tip
	Crush hat einen Skill, mit dem es seine eigene Konfigurationsdatei versteht und bearbeiten kann. Wenn du die `crush.json` ändern willst, sag Crush einfach, was du möchtest. Du kannst es zum Beispiel bitten, die ausführbaren Befehle einzuschränken, Hooks hinzuzufügen und vieles mehr.

!!! tip
    Wenn du selbst geschriebene MCP-Server konfigurieren und eigene Workflows mit Crush automatisieren willst, haben wir dazu ein Video: [https://www.youtube.com/watch?v=L7OWwEOmlZw](https://www.youtube.com/watch?v=L7OWwEOmlZw)