feat: Crush Integration - MCP Server Support #308

Closed
opened 2026-01-25 18:57:12 +00:00 by jack · 1 comment
Owner

Zusammenfassung

Integration von remembr in Crush, den AI Coding Agent von Charmbracelet (Nachfolger von OpenCode).


Über Crush

Crush ist ein Terminal-basierter AI Coding Agent:

  • Entwickler: Charmbracelet (Bubble Tea, Lip Gloss, etc.)
  • Sprache: Go (komplett, keine Plugins)
  • Features: Multi-Model, LSP, Session Management
  • Erweiterung: Nur via MCP (kein Plugin-System - aber geplant!)
  • Repository: https://github.com/charmbracelet/crush

Geschichte: Crush war ursprünglich "OpenCode", wurde aber vom Charm-Team übernommen und weiterentwickelt.


Upstream: Hooks System in Entwicklung

Update 25.01.2026: Crush arbeitet an einem Hook-System ähnlich wie Claude Code!

Upstream Status Link
Issue #1336 Offen General hooks system
PR #1487 WIP initial hook

Charm-Team Bestätigung (meowgorithm, 5. Dez 2025): "We still intend to add this."

Bedeutung: Sobald Hooks verfügbar sind, können wir ein vollwertiges Plugin wie für OpenCode entwickeln mit Auto-Session-Erfassung, Tool-Output-Archivierung und Context Injection.


Integrationsstrategie

Phase 1: MCP (Aktuell möglich)

Da Crush noch kein Plugin-System hat, ist MCP die einzige Integrationsmöglichkeit. Crush unterstützt drei MCP-Typen:

Typ Beschreibung Für remembr
stdio Lokaler Prozess Nicht ideal
http REST Endpoint Möglich
sse Server-Sent Events Empfohlen

Unser Backend nutzt bereits SSE - perfekte Passung!

Phase 2: Plugin (Sobald Hooks verfügbar)

Nach Release von Crush Hooks (geschätzt Q1-Q2 2026):

  • Hook-basierte Session-Erfassung
  • Automatische Observation-Extraktion
  • Context Injection wie bei OpenCode

MCP Server Implementierung

Crush-Konfiguration

{
  "$schema": "https://charm.land/crush.json",
  "mcp": {
    "remembr": {
      "type": "sse",
      "url": "http://localhost:37777/mcp/sse",
      "timeout": 120,
      "headers": {
        "Authorization": "Bearer {env:REMEMBR_API_KEY}"
      }
    }
  },
  "permissions": {
    "allowed_tools": [
      "mcp_remembr_search",
      "mcp_remembr_save_memory",
      "mcp_remembr_timeline",
      "mcp_remembr_get_observations"
    ]
  }
}

Backend: MCP SSE Router

// packages/backend/src/routes/mcp-sse.ts
import { Router, Request, Response } from "express"
import { BaseRouter } from "./base-router.js"

interface MCPTool {
  name: string
  description: string
  inputSchema: object
}

interface MCPRequest {
  jsonrpc: "2.0"
  id: string | number
  method: string
  params?: unknown
}

interface MCPResponse {
  jsonrpc: "2.0"
  id: string | number
  result?: unknown
  error?: { code: number; message: string }
}

export class MCPSSERouter extends BaseRouter {
  private tools: MCPTool[] = [
    {
      name: "search",
      description: "Search remembr memories using semantic search",
      inputSchema: {
        type: "object",
        properties: {
          query: { type: "string", description: "Search query" },
          limit: { type: "number", default: 10 },
          type: { 
            type: "string", 
            enum: ["decision", "bugfix", "feature", "discovery"] 
          },
          project: { type: "string" },
        },
        required: ["query"],
      },
    },
    {
      name: "save_memory",
      description: "Save an important observation to remembr",
      inputSchema: {
        type: "object",
        properties: {
          text: { type: "string", description: "Memory content" },
          type: { 
            type: "string", 
            enum: ["decision", "discovery", "note", "bookmark"],
            default: "note",
          },
          title: { type: "string" },
          project: { type: "string" },
        },
        required: ["text"],
      },
    },
    {
      name: "timeline",
      description: "Get context around a specific memory",
      inputSchema: {
        type: "object",
        properties: {
          anchor: { type: "number", description: "Memory ID" },
          query: { type: "string", description: "Or search query" },
          depth_before: { type: "number", default: 3 },
          depth_after: { type: "number", default: 3 },
          project: { type: "string" },
        },
      },
    },
    {
      name: "get_observations",
      description: "Fetch full details for specific observation IDs",
      inputSchema: {
        type: "object",
        properties: {
          ids: { 
            type: "array", 
            items: { type: "number" },
            description: "Observation IDs to fetch",
          },
          project: { type: "string" },
        },
        required: ["ids"],
      },
    },
  ]

  protected setupRoutes(): void {
    // SSE Endpoint für MCP
    this.router.get("/sse", this.handleSSE.bind(this))
    
    // Alternative: HTTP Endpoint
    this.router.post("/", this.handleRequest.bind(this))
  }

  // ... (siehe vollständige Implementierung im Kommentar)
}

Tool-Spezifikationen

// Input
{ query: string, limit?: number, type?: string, project?: string }

// Output
[{ id, type, title, text, createdAt, score }]

2. save_memory

// Input
{ text: string, type?: string, title?: string, project?: string }

// Output
{ success: true, id: number, message: string }

3. timeline

// Input
{ anchor?: number, query?: string, depth_before?: number, depth_after?: number }

// Output
{ anchor: {...}, before: [...], after: [...] }

4. get_observations

// Input
{ ids: number[], project?: string }

// Output
[{ id, type, title, text, ... }]

Implementierungs-Roadmap

Phase 1: MCP Endpoint (Sofort)

  • /api/mcp Route erstellen
  • JSON-RPC 2.0 Handler
  • Tool-Discovery (tools/list)
  • Tool-Execution (tools/call)
  • SSE Streaming

Phase 2: Testing & Docs

  • Mit Crush testen
  • Konfigurationsbeispiele
  • Troubleshooting Guide

Phase 3: Plugin (Nach Crush Hooks Release)

  • Upstream PR #1487 beobachten
  • Hook-basierte Integration implementieren
  • Feature-Parität mit OpenCode Plugin

Aufwand-Schätzung

Task Aufwand
MCP HTTP/SSE Router 10-14h
Tool-Implementierungen 4-6h
Crush-Kompatibilitätstests 3-4h
Dokumentation 2-3h
Phase 1 Gesamt 19-27h
Phase 3 (nach Hooks) +10-15h

Feature-Vergleich

Feature Mit MCP (Phase 1) Mit Hooks (Phase 3)
Auto Session-Start Manual Automatisch
Auto Observation-Extraktion Manual Automatisch
Context Injection User muss suchen Automatisch
Tool-Output-Archivierung Nicht möglich Möglich
Semantic Search Via Tool Via Tool
Manual Memory Save Via Tool Via Tool

Akzeptanzkriterien

Phase 1 (MCP)

  • MCP SSE Endpoint funktioniert mit Crush
  • Alle 4 Tools verfügbar
  • JSON-RPC 2.0 konform
  • Dokumentation vollständig

Phase 3 (Hooks)

  • Automatische Session-Erfassung
  • Tool-Output-Archivierung
  • Context Injection

Referenzen

## Zusammenfassung Integration von remembr in [Crush](https://github.com/charmbracelet/crush), den AI Coding Agent von Charmbracelet (Nachfolger von OpenCode). --- ## Über Crush Crush ist ein Terminal-basierter AI Coding Agent: - **Entwickler:** Charmbracelet (Bubble Tea, Lip Gloss, etc.) - **Sprache:** Go (komplett, keine Plugins) - **Features:** Multi-Model, LSP, Session Management - **Erweiterung:** Nur via MCP (kein Plugin-System - **aber geplant!**) - **Repository:** https://github.com/charmbracelet/crush **Geschichte:** Crush war ursprünglich "OpenCode", wurde aber vom Charm-Team übernommen und weiterentwickelt. --- ## ⚡ Upstream: Hooks System in Entwicklung > **Update 25.01.2026:** Crush arbeitet an einem Hook-System ähnlich wie Claude Code! | Upstream | Status | Link | |----------|--------|------| | Issue #1336 | Offen | [General hooks system](https://github.com/charmbracelet/crush/issues/1336) | | PR #1487 | WIP | [initial hook](https://github.com/charmbracelet/crush/pull/1487) | **Charm-Team Bestätigung** (meowgorithm, 5. Dez 2025): *"We still intend to add this."* **Bedeutung:** Sobald Hooks verfügbar sind, können wir ein vollwertiges Plugin wie für OpenCode entwickeln mit Auto-Session-Erfassung, Tool-Output-Archivierung und Context Injection. --- ## Integrationsstrategie ### Phase 1: MCP (Aktuell möglich) Da Crush noch kein Plugin-System hat, ist **MCP die einzige Integrationsmöglichkeit**. Crush unterstützt drei MCP-Typen: | Typ | Beschreibung | Für remembr | |-----|--------------|-------------| | `stdio` | Lokaler Prozess | ❌ Nicht ideal | | `http` | REST Endpoint | ✅ Möglich | | `sse` | Server-Sent Events | ✅ **Empfohlen** | Unser Backend nutzt bereits SSE - perfekte Passung! ### Phase 2: Plugin (Sobald Hooks verfügbar) Nach Release von Crush Hooks (geschätzt Q1-Q2 2026): - Hook-basierte Session-Erfassung - Automatische Observation-Extraktion - Context Injection wie bei OpenCode --- ## MCP Server Implementierung ### Crush-Konfiguration ```json { "$schema": "https://charm.land/crush.json", "mcp": { "remembr": { "type": "sse", "url": "http://localhost:37777/mcp/sse", "timeout": 120, "headers": { "Authorization": "Bearer {env:REMEMBR_API_KEY}" } } }, "permissions": { "allowed_tools": [ "mcp_remembr_search", "mcp_remembr_save_memory", "mcp_remembr_timeline", "mcp_remembr_get_observations" ] } } ``` ### Backend: MCP SSE Router ```typescript // packages/backend/src/routes/mcp-sse.ts import { Router, Request, Response } from "express" import { BaseRouter } from "./base-router.js" interface MCPTool { name: string description: string inputSchema: object } interface MCPRequest { jsonrpc: "2.0" id: string | number method: string params?: unknown } interface MCPResponse { jsonrpc: "2.0" id: string | number result?: unknown error?: { code: number; message: string } } export class MCPSSERouter extends BaseRouter { private tools: MCPTool[] = [ { name: "search", description: "Search remembr memories using semantic search", inputSchema: { type: "object", properties: { query: { type: "string", description: "Search query" }, limit: { type: "number", default: 10 }, type: { type: "string", enum: ["decision", "bugfix", "feature", "discovery"] }, project: { type: "string" }, }, required: ["query"], }, }, { name: "save_memory", description: "Save an important observation to remembr", inputSchema: { type: "object", properties: { text: { type: "string", description: "Memory content" }, type: { type: "string", enum: ["decision", "discovery", "note", "bookmark"], default: "note", }, title: { type: "string" }, project: { type: "string" }, }, required: ["text"], }, }, { name: "timeline", description: "Get context around a specific memory", inputSchema: { type: "object", properties: { anchor: { type: "number", description: "Memory ID" }, query: { type: "string", description: "Or search query" }, depth_before: { type: "number", default: 3 }, depth_after: { type: "number", default: 3 }, project: { type: "string" }, }, }, }, { name: "get_observations", description: "Fetch full details for specific observation IDs", inputSchema: { type: "object", properties: { ids: { type: "array", items: { type: "number" }, description: "Observation IDs to fetch", }, project: { type: "string" }, }, required: ["ids"], }, }, ] protected setupRoutes(): void { // SSE Endpoint für MCP this.router.get("/sse", this.handleSSE.bind(this)) // Alternative: HTTP Endpoint this.router.post("/", this.handleRequest.bind(this)) } // ... (siehe vollständige Implementierung im Kommentar) } ``` --- ## Tool-Spezifikationen ### 1. search ```typescript // Input { query: string, limit?: number, type?: string, project?: string } // Output [{ id, type, title, text, createdAt, score }] ``` ### 2. save_memory ```typescript // Input { text: string, type?: string, title?: string, project?: string } // Output { success: true, id: number, message: string } ``` ### 3. timeline ```typescript // Input { anchor?: number, query?: string, depth_before?: number, depth_after?: number } // Output { anchor: {...}, before: [...], after: [...] } ``` ### 4. get_observations ```typescript // Input { ids: number[], project?: string } // Output [{ id, type, title, text, ... }] ``` --- ## Implementierungs-Roadmap ### Phase 1: MCP Endpoint (Sofort) - [ ] `/api/mcp` Route erstellen - [ ] JSON-RPC 2.0 Handler - [ ] Tool-Discovery (`tools/list`) - [ ] Tool-Execution (`tools/call`) - [ ] SSE Streaming ### Phase 2: Testing & Docs - [ ] Mit Crush testen - [ ] Konfigurationsbeispiele - [ ] Troubleshooting Guide ### Phase 3: Plugin (Nach Crush Hooks Release) - [ ] Upstream PR #1487 beobachten - [ ] Hook-basierte Integration implementieren - [ ] Feature-Parität mit OpenCode Plugin --- ## Aufwand-Schätzung | Task | Aufwand | |------|---------| | MCP HTTP/SSE Router | 10-14h | | Tool-Implementierungen | 4-6h | | Crush-Kompatibilitätstests | 3-4h | | Dokumentation | 2-3h | | **Phase 1 Gesamt** | **19-27h** | | Phase 3 (nach Hooks) | +10-15h | --- ## Feature-Vergleich | Feature | Mit MCP (Phase 1) | Mit Hooks (Phase 3) | |---------|-------------------|---------------------| | Auto Session-Start | ❌ Manual | ✅ Automatisch | | Auto Observation-Extraktion | ❌ Manual | ✅ Automatisch | | Context Injection | ❌ User muss suchen | ✅ Automatisch | | Tool-Output-Archivierung | ❌ Nicht möglich | ✅ Möglich | | Semantic Search | ✅ Via Tool | ✅ Via Tool | | Manual Memory Save | ✅ Via Tool | ✅ Via Tool | --- ## Akzeptanzkriterien ### Phase 1 (MCP) - [ ] MCP SSE Endpoint funktioniert mit Crush - [ ] Alle 4 Tools verfügbar - [ ] JSON-RPC 2.0 konform - [ ] Dokumentation vollständig ### Phase 3 (Hooks) - [ ] Automatische Session-Erfassung - [ ] Tool-Output-Archivierung - [ ] Context Injection --- ## Referenzen - [Crush GitHub](https://github.com/charmbracelet/crush) - [Crush Hooks Issue #1336](https://github.com/charmbracelet/crush/issues/1336) - [Crush Hooks PR #1487](https://github.com/charmbracelet/crush/pull/1487) - [MCP Specification](https://modelcontextprotocol.io/) - [JSON-RPC 2.0](https://www.jsonrpc.org/specification)
Author
Owner

Update: Crush Hooks System in Entwicklung

Gute Nachrichten!

Crush plant ein Hook-System ähnlich wie Claude Code. Dies würde die Integration deutlich verbessern.

Status (Stand: 25.01.2026)

Issue/PR Titel Status
#1336 General hooks system Offen
#1487 wip: initial hook In Arbeit

Bestätigung vom Charm-Team (meowgorithm, 5. Dez 2025):

"We still intend to add this."

Geplante Hook-Events (basierend auf Issue)

Referenziert Claude Code Hooks:

  • PreToolUse / PostToolUse
  • Session Start/End
  • Permission Request
  • Agent Done

Auswirkung auf remembr Integration

Aktuell (nur MCP):

  • Keine automatische Session-Erfassung
  • Kein Tool-Output-Archivierung
  • Kein Context Injection
  • Manuelle Search/Save Tools

Mit Hooks (geplant):

  • Automatische Session-Erfassung
  • Tool-Output-Archivierung
  • Context Injection
  • Volle Feature-Parität mit OpenCode Plugin

Empfehlung

  1. Phase 1: MCP-Integration wie geplant implementieren
  2. Phase 2: Sobald Crush Hooks released, Plugin-Wrapper hinzufügen

Zeitschätzung

Hook-System könnte in 1-3 Monaten erscheinen (aktive Entwicklung). Wir sollten den PR #1487 beobachten.

## Update: Crush Hooks System in Entwicklung ### Gute Nachrichten! Crush plant ein Hook-System ähnlich wie Claude Code. Dies würde die Integration deutlich verbessern. ### Status (Stand: 25.01.2026) | Issue/PR | Titel | Status | |----------|-------|--------| | [#1336](https://github.com/charmbracelet/crush/issues/1336) | General hooks system | Offen | | [#1487](https://github.com/charmbracelet/crush/pull/1487) | wip: initial hook | In Arbeit | **Bestätigung vom Charm-Team** (meowgorithm, 5. Dez 2025): > "We still intend to add this." ### Geplante Hook-Events (basierend auf Issue) Referenziert Claude Code Hooks: - `PreToolUse` / `PostToolUse` - Session Start/End - Permission Request - Agent Done ### Auswirkung auf remembr Integration **Aktuell (nur MCP):** - ❌ Keine automatische Session-Erfassung - ❌ Kein Tool-Output-Archivierung - ❌ Kein Context Injection - ✅ Manuelle Search/Save Tools **Mit Hooks (geplant):** - ✅ Automatische Session-Erfassung - ✅ Tool-Output-Archivierung - ✅ Context Injection - ✅ Volle Feature-Parität mit OpenCode Plugin ### Empfehlung 1. **Phase 1:** MCP-Integration wie geplant implementieren 2. **Phase 2:** Sobald Crush Hooks released, Plugin-Wrapper hinzufügen ### Zeitschätzung Hook-System könnte in 1-3 Monaten erscheinen (aktive Entwicklung). Wir sollten den PR [#1487](https://github.com/charmbracelet/crush/pull/1487) beobachten.
jack closed this issue 2026-01-25 20:11:17 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
customable/claude-mem#308
No description provided.