diff --git a/docs/operations-runbook.md b/docs/operations-runbook.md index 19acd85..6755e07 100644 --- a/docs/operations-runbook.md +++ b/docs/operations-runbook.md @@ -52,6 +52,28 @@ - **אפס עלות API** — claude CLI משתמש ב-claude.ai subscription של chaim. הנחת היסוד של `claude_session.py` (claude CLI מקומי בלבד) נשמרת. - Coolify dependency: ה-Service Definition של legal-ai חייב להכיל `extra_hosts: host.docker.internal:host-gateway` (אחרת ה-proxy יקבל ConnectError). +### legal-mcp-http — שרת ה-MCP ב-HTTP (מאוגוסט 2026) +- פורט: `127.0.0.1:8790` (loopback בלבד) · קונפיג: [`scripts/legal-mcp-http.config.cjs`](../scripts/legal-mcp-http.config.cjs) +- **הדלת של סוכני הפלטפורמה** אל 108 כלי ה-MCP. סשן אינטראקטיבי מגיע לאותו שרת ב-stdio דרך `~/.claude.json` — **אותו קוד, שתי תחבורות** (G2). +- שער Bearer (`MCP_HTTP_SHARED_SECRET`); השרת **מסרב לעלות** בלי טוקן. בדיקה: ללא טוקן → `401`, עם טוקן → `200`. +- **⚠️ שינוי קוד ב-`mcp-server/` לא נכנס לתוקף עד `pm2 restart legal-mcp-http`.** זה תהליך ארוך-חיים, בניגוד ל-stdio שנטען מחדש בכל סשן. אחרי מיזוג שנוגע ב-`mcp-server/` — להפעיל מחדש, אחרת הסוכנים ירוצו על קוד ישן בשקט. + +> #### 🚨 דריפט תצורה פתוח — `STORAGE_BACKEND` +> הקונטיינר רץ `STORAGE_BACKEND=s3`; שרת ה-MCP נופל לברירת-המחדל `filesystem`, כי +> `~/.env` אינו מגדיר אותו. כלומר **סוכן שכותב קובץ דרך MCP כותב לדיסק, בעוד ה-web +> קורא מ-S3** — שני מסלולים שמתפצלים (G2 / INV-STG1). +> +> **למה זה עדיין לא תוקן:** ההעברה ל-s3 דורשת `MINIO_ENDPOINT` + `MINIO_ACCESS_KEY` + +> `MINIO_SECRET_KEY`, ואלה **אינם קיימים ב-Infisical** — רק ב-env של Coolify. הפיכת +> הדגל בלעדיהם תפתור את `MINIO_ENDPOINT` לברירת-המחדל `http://minio:9000` (שם-רשת +> פנימי של דוקר, לא נגיש מהמארח) ותשבור כל פעולת-בלוב. +> +> **מה שצריך כדי לסגור:** ליצור את שלושת המפתחות ב-Infisical תחת `/apps/legal-ai` +> (תגית `credentials`, באישור חיים — ראה כלל "Saving a NEW secret" ב-`~/CLAUDE.md`), +> לטעון אותם בקונפיג ה-pm2 כמו `MCP_HTTP_SHARED_SECRET`, ואז להוסיף +> `STORAGE_BACKEND: "s3"`. MinIO **כן** נגיש מהמארח: `https://s3.nautilus.marcusgroup.org` +> (אומת — `/minio/health/live` מחזיר 200). + --- ## מבנה תיקיות diff --git a/scripts/legal-mcp-http.config.cjs b/scripts/legal-mcp-http.config.cjs index ed34ff5..f0708f2 100644 --- a/scripts/legal-mcp-http.config.cjs +++ b/scripts/legal-mcp-http.config.cjs @@ -56,6 +56,20 @@ const env = { // transports read exactly the same corpus. DOTENV_PATH: "/home/chaim/.env", DATA_DIR: "/home/chaim/legal-ai/data", + // Retrieval flags must match the container's, or the two doors into the same + // corpus rank differently (G2 — a parallel path that drifts). The container + // runs MULTIMODAL_ENABLED=true; without this the MCP door skipped the + // page-image merge entirely, so an agent and the web UI could answer the same + // question from different result sets. ~/.env sets neither, so both fell to + // the code defaults (false) — the drift was silent. + // + // NOT set here: STORAGE_BACKEND. The container runs `s3`, this service falls + // back to `filesystem`, and closing that gap needs MinIO credentials that do + // not exist in Infisical yet (only in Coolify's env). Flipping the flag + // without them would resolve MINIO_ENDPOINT to the in-cluster default + // `http://minio:9000` — unreachable from the host — and break every blob + // read. Tracked separately; see the note in docs/operations-runbook.md. + MULTIMODAL_ENABLED: "true", MCP_TRANSPORT: "streamable-http", MCP_HTTP_HOST: "127.0.0.1", MCP_HTTP_PORT: "8790",