knowmind 0.1.17 → 0.1.19

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md ADDED
@@ -0,0 +1,121 @@
1
+ # Knowmind CLI — Änderungen
2
+
3
+ ## 0.1.19 (2026-06-10)
4
+
5
+ **CLI-Befehle repariert (search/stats/health/login)**
6
+ - `knowmind search`, `knowmind stats`, `knowmind health` und die Token-Verifikation in
7
+ `knowmind login` riefen noch die alten Punkt-Tool-Namen (`knowmind.recall`, `knowmind.stats`,
8
+ `knowmind.health`) auf — der Server kennt seit der MCP-Namensschema-Umstellung nur noch
9
+ Unterstrich-Namen (`knowmind_recall`, …). Alle direkten Tool-Calls umgestellt; der
10
+ `knowmind mcp`-Proxy war nicht betroffen (reicht seit 0.1.18 alles durch).
11
+
12
+ **Sync-Härtung**
13
+ - `knowmind sync` speichert das Manifest jetzt nach JEDEM erfolgreichen Upload statt in
14
+ 10er-Batches. Bricht der Prozess mitten im Lauf ab, gehen keine Manifest-Stände mehr
15
+ verloren — identischer Inhalt wurde sonst beim nächsten Lauf endlos re-POSTet.
16
+ - Server-Antwort `unchanged:true` (sha-identischer Inhalt, historisch `duplicate:true`)
17
+ wird in Manifest und Ausgabe sauber erkannt.
18
+
19
+ **Saubere Upload-Meldung**
20
+ - `knowmind upload` meldet bei unverändertem/dupliziertem Inhalt jetzt verständlich
21
+ „Unverändert/Duplikat …" statt `undefined Chunks (Provider undefined)`.
22
+
23
+ **Doku**
24
+ - README: Tool-Liste auf die 11 Server-Tools aktualisiert (`knowmind_list_recent` ergänzt);
25
+ `knowmind_upload_document` als Upsert-per-Titel beschrieben.
26
+
27
+ ## 0.1.18 (2026-06-09)
28
+
29
+ **MCP-stdio als reiner Server-Proxy**
30
+ - `knowmind mcp` hält keine lokalen Tool-Definitionen mehr: `tools/list`, `tools/call`,
31
+ `prompts/*` und alle weiteren Methoden werden 1:1 an den Remote-Endpoint
32
+ (`/api/mcp/v1`) durchgereicht. Tool-Namen, Schemas und Safety-Annotations kommen
33
+ direkt vom Server — eine Abweichung wie der Namens-Drift `knowmind.*` vs.
34
+ `knowmind_*` (machte 0.1.17 gegen den aktualisierten Endpoint unbrauchbar) ist
35
+ damit konstruktiv ausgeschlossen.
36
+ - `initialize` meldet die echte Paketversion; Notifications werden korrekt ignoriert.
37
+
38
+ ## 0.1.17 (2026-06-08)
39
+
40
+ **Rechts-Korrekturen (nach anwaltlicher Vorprüfung)**
41
+ - Datenresidenz-Aussage korrigiert: keine widersprüchliche Stadt-Angabe mehr, und der absolute
42
+ Satz „verlassen den deutschen Rechtsraum nicht" um den **Bring-your-own-Key-Vorbehalt** ergänzt
43
+ (bei eigenen US-Anbieter-Schlüsseln kann ein Drittlandtransfer stattfinden).
44
+ - **High-Risk-Ausschluss** ergänzt: knowmind ist nicht für selbstfahrende Fahrzeuge, kritische
45
+ Infrastruktur oder lebenserhaltende/medizinische Systeme bestimmt; Einsatz dort auf eigenes Risiko.
46
+
47
+ ## 0.1.16 (2026-06-08)
48
+
49
+ **Positionierung + rechtliche Absicherung**
50
+ - „Das Agentengehirn aus Deutschland" als Positionierung in README + npm/Registry-Beschreibung
51
+ (Server in Deutschland, Hetzner/Nürnberg).
52
+ - Volle **Apache-2.0-Lizenz** in `LICENSE` (vorher nur 17-Zeilen-Header-Stub ohne die bindenden
53
+ Abschnitte 7 Disclaimer of Warranty + 8 Limitation of Liability).
54
+ - **Haftung & Nutzung**-Abschnitt im README: „AS IS" ohne Gewährleistung, Bring-your-own-Token,
55
+ eigener Verbrauch/eigene Kosten, Verweis auf AGB/Datenschutz/AVV/Impressum von knowmind.de.
56
+
57
+ ## 0.1.15 (2026-06-08)
58
+
59
+ **Marken-Namensraum**
60
+ - Repo in die Organisation `Schubeler-Consulting` verschoben; MCP-Registry-Namespace
61
+ von `io.github.WhoSoEverM8/knowmind` auf `io.github.Schubeler-Consulting/knowmind`
62
+ (saubere, firmenkonforme Schreibweise). `mcpName`, `server.json` und `repository`
63
+ entsprechend angepasst.
64
+
65
+ ## 0.1.14 (2026-06-08)
66
+
67
+ **MCP-Registry-Namespace**
68
+ - `mcpName` auf die korrekte, case-sensitive Schreibweise `io.github.WhoSoEverM8/knowmind`
69
+ gesetzt (muss dem GitHub-Benutzernamen exakt entsprechen, sonst lehnt die offizielle
70
+ MCP-Registry den Publish mit 403 ab).
71
+
72
+ ## 0.1.13 (2026-06-08)
73
+
74
+ **Konsistenz**
75
+ - Der MCP-Server meldet im `initialize`-Handshake jetzt die echte Paketversion
76
+ (`serverInfo.version` = `VERSION` aus package.json) statt eines hartcodierten,
77
+ veralteten Werts. Damit sind npm-Version, Server-Selbstauskunft, Hermes-Pin und
78
+ das `server.json` der MCP-Registry identisch — eine Quelle der Wahrheit.
79
+
80
+ ## 0.1.12 (2026-06-08)
81
+
82
+ **MCP-Registry-Reife**
83
+ - `package.json` um `mcpName` (`io.github.whosoeverm8/knowmind`) und `repository`
84
+ ergänzt — Voraussetzung für die offizielle MCP-Registry
85
+ (registry.modelcontextprotocol.io) und damit für PulseMCP, Glama, die
86
+ GitHub-MCP-Registry (VS Code/Cursor) u. a.
87
+ - `server.json` (MCP-Registry-Manifest, Schema 2025-12-11) hinzugefügt.
88
+
89
+ **Sync-Korrektur (war 0.1.11, nie publiziert)**
90
+ - `knowmind sync` ignoriert jetzt reine Index-/Navigationsdateien (`MEMORY.md`).
91
+ Diese änderten sich bei jedem Memory-Write und legten beim Sync jedes Mal ein
92
+ NEUES Dokument an (kein Replace) — bis zu 24 Versionen / 1224 Chunks (~38 % des
93
+ Stores), die mit schwachen Einzeiler-Hooks die echten Detail-Dokumente aus dem
94
+ Recall verdrängten. Index-Dateien werden nicht mehr synchronisiert.
95
+
96
+ ## 0.1.10 (2026-05-22)
97
+
98
+ **Install-Sauberkeit**
99
+ - Deprecation-Warnung `boolean@3.2.0 is no longer supported` beim Install
100
+ beseitigt. Ursache war `onnxruntime-node → global-agent@3.0.0 → boolean`.
101
+ Per npm-`overrides` wird `global-agent@^4.1.3` erzwungen, das die
102
+ veraltete `boolean`/`roarr`-Kette nicht mehr braucht. `npm install -g
103
+ knowmind` läuft jetzt ohne Warnungen durch.
104
+
105
+ ## 0.1.9 (2026-05-22)
106
+
107
+ **Neuer Befehl**
108
+ - `knowmind sync <dir>` synchronisiert einen lokalen Ordner mit dem
109
+ Knowmind-Korpus. Idempotent über Content-Hash, Manifest in
110
+ `<dir>/.knowmind-manifest.json`. Wiederholte Aufrufe übertragen nur das
111
+ Delta. Optional `--ext .md,.txt`, `--verbose`, `--title-from-content`.
112
+
113
+ **Korrekturen**
114
+ - Upload-Fehlerpfad gehärtet: leere oder ungültige Server-Antworten werfen
115
+ jetzt eine sprechende Fehlermeldung statt eines kryptischen
116
+ „Unexpected end of JSON input" (siehe `src/client.js`).
117
+ - Sichtbare CLI-Hilfe enthält den neuen `sync`-Befehl.
118
+
119
+ **Bekannte Punkte**
120
+ - `--watch` für `sync` (Datei-Beobachter mit Live-Upload) ist vorgesehen,
121
+ aber noch nicht implementiert.
package/README.md CHANGED
@@ -1,141 +1,151 @@
1
- # knowmind
2
-
3
- **Das Agentengehirn aus Deutschland.** Langzeitgedächtnis und Wissensgraph für Ihre KI —
4
- CLI + MCP-Server. Inhalte und Server in Deutschland (Hetzner-Rechenzentrum).
5
-
6
- <!-- mcp-name: io.github.Schubeler-Consulting/knowmind -->
7
-
8
- [![npm](https://img.shields.io/npm/v/knowmind)](https://www.npmjs.com/package/knowmind) · Apache-2.0 · [knowmind.de](https://knowmind.de)
9
-
10
- ## Installation
11
-
12
- ```
13
- npm install -g knowmind
14
- ```
15
-
16
- Oder ohne Installation direkt als MCP-Server: `npx -y knowmind mcp`
17
-
18
- ## Setup
19
-
20
- 1. Token auf knowmind.de anlegen: Dashboard → API-Tokens
21
- 2. Lokal speichern:
22
-
23
- ```
24
- knowmind login --token kmt_xxxxxxxx
25
- ```
26
-
27
- Alternativ über ENV:
28
-
29
- ```
30
- export KNOWMIND_TOKEN=kmt_xxxxxxxx
31
- export KNOWMIND_API_URL=https://knowmind.de
32
- ```
33
-
34
- ## Befehle
35
-
36
- ```
37
- knowmind search "Wo läuft die OKR-App?"
38
- knowmind upload notizen.md --title "Meeting Notizen 2026-05-12"
39
- knowmind stats
40
- knowmind health
41
- knowmind config
42
- ```
43
-
44
- ## MCP-Server einrichten
45
-
46
- knowmind ist ein MCP-Server (`npx -y knowmind mcp`, stdio). Token aus dem knowmind.de-Dashboard
47
- (→ API-Tokens) als `KNOWMIND_TOKEN`; optional `KNOWMIND_API_URL` (Standard `https://knowmind.de`).
48
-
49
- **Claude Code**
50
- ```
51
- claude mcp add knowmind --env KNOWMIND_TOKEN=kmt_xxx --env KNOWMIND_API_URL=https://knowmind.de -- npx -y knowmind mcp
52
- ```
53
-
54
- **Claude Desktop / Cursor / Windsurf / Cline / Continue / Goose / Zed** (`claude_desktop_config.json`, `~/.cursor/mcp.json`, …)
55
- ```json
56
- {
57
- "mcpServers": {
58
- "knowmind": {
59
- "command": "npx",
60
- "args": ["-y", "knowmind", "mcp"],
61
- "env": { "KNOWMIND_TOKEN": "kmt_xxx", "KNOWMIND_API_URL": "https://knowmind.de" }
62
- }
63
- }
64
- }
65
- ```
66
- > Windows-Hinweis: falls `npx` nicht direkt startet, `"command": "cmd"`, `"args": ["/c", "npx", "-y", "knowmind", "mcp"]`.
67
-
68
- **VS Code / GitHub Copilot** (`.vscode/mcp.json` — Top-Level `servers` + `inputs`)
69
- ```json
70
- {
71
- "inputs": [{ "id": "knowmind_token", "type": "promptString", "description": "Knowmind API token", "password": true }],
72
- "servers": {
73
- "knowmind": {
74
- "command": "npx",
75
- "args": ["-y", "knowmind", "mcp"],
76
- "env": { "KNOWMIND_TOKEN": "${input:knowmind_token}", "KNOWMIND_API_URL": "https://knowmind.de" }
77
- }
78
- }
79
- }
80
- ```
81
-
82
- **Codex CLI** (`~/.codex/config.toml`)
83
- ```toml
84
- [mcp_servers.knowmind]
85
- command = "npx"
86
- args = ["-y", "knowmind", "mcp"]
87
- env = { KNOWMIND_TOKEN = "kmt_xxx", KNOWMIND_API_URL = "https://knowmind.de" }
88
- ```
89
-
90
- **Gemini CLI** (`~/.gemini/settings.json`) — gleiche `mcpServers`-Struktur wie Claude Desktop.
91
-
92
- **Remote (ohne lokale Installation)** — für Clients mit HTTP-MCP-Support direkt der gehostete Endpoint:
93
- ```json
94
- { "type": "http", "url": "https://knowmind.de/api/mcp/v1", "headers": { "Authorization": "Bearer kmt_xxx" } }
95
- ```
96
-
97
- Token kann statt per `env` auch lokal via `knowmind login --token kmt_xxx` (→ `~/.knowmind/config.json`) hinterlegt werden.
98
-
99
- ## Tools (im MCP-Modus)
100
-
101
- - `knowmind.recall` — Hybride Suche im Wissensspeicher des Mandanten
102
- - `knowmind.store` — Neue Erinnerung anlegen (Titel + Inhalt)
103
- - `knowmind.link` — Typisierte Beziehung zwischen zwei Erinnerungen anlegen (Inverse wird automatisch gesetzt)
104
- - `knowmind.unlink` — Beziehung wieder entfernen (samt Inverse)
105
- - `knowmind.relations` — Beziehungen einer Erinnerung auflisten
106
- - `knowmind.stats` — Statistik über gespeicherte Erinnerungen und Beziehungen
107
- - `knowmind.health` — Verfügbarkeits-Status der Plattform
108
-
109
- Die zulässigen Beziehungstypen sind im Tool-Schema von `knowmind.link` als Enum hinterlegt — der Agent sieht sie direkt bei der Werkzeug-Auswahl. Inverse-Beziehungen (z. B. `IS_EMPLOYEE_OF` zu `HAS_EMPLOYEE`) werden serverseitig automatisch mit angelegt.
110
-
111
- ## Daten in Deutschland
112
-
113
- knowmind ist das Agentengehirn aus Deutschland: Ihre Inhalte (Memories, Account- und Metadaten) werden
114
- ausschließlich auf Servern in Deutschland (Hetzner-Rechenzentrum) gespeichert und verlassen Deutschland nicht.
115
- Auftragsverarbeitung (AVV) nach Art. 28 DSGVO verfügbar: https://knowmind.de/legal/avv
116
-
117
- **Hinweis (Bring-your-own-Key):** Wenn Sie eigene Schlüssel externer KI-Anbieter hinterlegen, werden Ihre
118
- Anfragen direkt an den von Ihnen gewählten Anbieter übermittelt. Sitzt dieser außerhalb der EU, kann dabei
119
- ein Drittlandtransfer stattfinden, für den Sie als Verantwortlicher zuständig sind.
120
-
121
- ## Haftung & Nutzung (Disclaimer)
122
-
123
- - **Software:** Dieses Paket steht unter der **Apache-Lizenz 2.0** und wird „AS IS" ohne jegliche
124
- Gewährleistung bereitgestellt; die Haftung ist im Rahmen der Lizenz (Abschnitte 7 und 8)
125
- ausgeschlossen bzw. beschränkt. Siehe `LICENSE`.
126
- - **Eigenes Konto, eigener Token:** knowmind bündelt keine Zugangsdaten. Sie nutzen Ihren eigenen
127
- knowmind.de-Account und API-Token. Anlegen: https://knowmind.de/dashboard/api-tokens
128
- - **Eigene Kosten/Verbrauch:** Jede Nutzung (API-Anfragen, Token-/Kontingentverbrauch, ggf.
129
- modellbezogene Kosten) erfolgt über Ihren eigenen Account und auf Ihre Verantwortung. Verbrauch
130
- und Kosten sind im knowmind.de-Dashboard transparent einsehbar.
131
- - **Service-Bedingungen:** Für die Nutzung der gehosteten Plattform gelten die AGB und die
132
- Datenschutzerklärung von knowmind.de:
133
- [AGB](https://knowmind.de/legal/agb) · [Datenschutz](https://knowmind.de/legal/datenschutz) ·
134
- [AVV](https://knowmind.de/legal/avv) · [Impressum](https://knowmind.de/legal/impressum)
135
- - **Kein Einsatz in sicherheitskritischen Bereichen:** knowmind ist ein Gedächtnis-/Recall-Dienst und
136
- **nicht** für den Betrieb von selbstfahrenden Fahrzeugen, kritischer Infrastruktur, medizinischen oder
137
- lebenserhaltenden Systemen oder sonstigen Anwendungen bestimmt, bei denen ein Fehler oder Ausfall zu Tod,
138
- Personen-, Umwelt- oder schweren Sachschäden führen kann. Ein Einsatz in solchen Umgebungen erfolgt auf
139
- alleiniges Risiko des Nutzers.
140
-
141
- Anbieter: Schübeler Consulting — Johann Jörgen Schübeler. Kontakt: info@schuebeler-consulting.de
1
+ # knowmind
2
+
3
+ **Das Agentengehirn aus Deutschland.** Langzeitgedächtnis und Wissensgraph für Ihre KI —
4
+ CLI + MCP-Server. Inhalte und Server in Deutschland (Hetzner-Rechenzentrum).
5
+
6
+ <!-- mcp-name: io.github.Schubeler-Consulting/knowmind -->
7
+
8
+ [![npm](https://img.shields.io/npm/v/knowmind)](https://www.npmjs.com/package/knowmind) · Apache-2.0 · [knowmind.de](https://knowmind.de)
9
+
10
+ ## Installation
11
+
12
+ ```
13
+ npm install -g knowmind
14
+ ```
15
+
16
+ Oder ohne Installation direkt als MCP-Server: `npx -y knowmind mcp`
17
+
18
+ ## Setup
19
+
20
+ 1. Token auf knowmind.de anlegen: Dashboard → API-Tokens
21
+ 2. Lokal speichern:
22
+
23
+ ```
24
+ knowmind login --token kmt_xxxxxxxx
25
+ ```
26
+
27
+ Alternativ über ENV:
28
+
29
+ ```
30
+ export KNOWMIND_TOKEN=kmt_xxxxxxxx
31
+ export KNOWMIND_API_URL=https://knowmind.de
32
+ ```
33
+
34
+ ## Befehle
35
+
36
+ ```
37
+ knowmind search "Wo läuft die OKR-App?"
38
+ knowmind upload notizen.md --title "Meeting Notizen 2026-05-12"
39
+ knowmind stats
40
+ knowmind health
41
+ knowmind config
42
+ ```
43
+
44
+ ## MCP-Server einrichten
45
+
46
+ knowmind ist ein MCP-Server (`npx -y knowmind mcp`, stdio). Token aus dem knowmind.de-Dashboard
47
+ (→ API-Tokens) als `KNOWMIND_TOKEN`; optional `KNOWMIND_API_URL` (Standard `https://knowmind.de`).
48
+
49
+ **Claude Code**
50
+ ```
51
+ claude mcp add knowmind --env KNOWMIND_TOKEN=kmt_xxx --env KNOWMIND_API_URL=https://knowmind.de -- npx -y knowmind mcp
52
+ ```
53
+
54
+ **Claude Desktop / Cursor / Windsurf / Cline / Continue / Goose / Zed** (`claude_desktop_config.json`, `~/.cursor/mcp.json`, …)
55
+ ```json
56
+ {
57
+ "mcpServers": {
58
+ "knowmind": {
59
+ "command": "npx",
60
+ "args": ["-y", "knowmind", "mcp"],
61
+ "env": { "KNOWMIND_TOKEN": "kmt_xxx", "KNOWMIND_API_URL": "https://knowmind.de" }
62
+ }
63
+ }
64
+ }
65
+ ```
66
+ > Windows-Hinweis: falls `npx` nicht direkt startet, `"command": "cmd"`, `"args": ["/c", "npx", "-y", "knowmind", "mcp"]`.
67
+
68
+ **VS Code / GitHub Copilot** (`.vscode/mcp.json` — Top-Level `servers` + `inputs`)
69
+ ```json
70
+ {
71
+ "inputs": [{ "id": "knowmind_token", "type": "promptString", "description": "Knowmind API token", "password": true }],
72
+ "servers": {
73
+ "knowmind": {
74
+ "command": "npx",
75
+ "args": ["-y", "knowmind", "mcp"],
76
+ "env": { "KNOWMIND_TOKEN": "${input:knowmind_token}", "KNOWMIND_API_URL": "https://knowmind.de" }
77
+ }
78
+ }
79
+ }
80
+ ```
81
+
82
+ **Codex CLI** (`~/.codex/config.toml`)
83
+ ```toml
84
+ [mcp_servers.knowmind]
85
+ command = "npx"
86
+ args = ["-y", "knowmind", "mcp"]
87
+ env = { KNOWMIND_TOKEN = "kmt_xxx", KNOWMIND_API_URL = "https://knowmind.de" }
88
+ ```
89
+
90
+ **Gemini CLI** (`~/.gemini/settings.json`) — gleiche `mcpServers`-Struktur wie Claude Desktop.
91
+
92
+ **Remote (ohne lokale Installation)** — für Clients mit HTTP-MCP-Support direkt der gehostete Endpoint:
93
+ ```json
94
+ { "type": "http", "url": "https://knowmind.de/api/mcp/v1", "headers": { "Authorization": "Bearer kmt_xxx" } }
95
+ ```
96
+
97
+ Token kann statt per `env` auch lokal via `knowmind login --token kmt_xxx` (→ `~/.knowmind/config.json`) hinterlegt werden.
98
+
99
+ ## Tools (im MCP-Modus)
100
+
101
+ Der MCP-Modus ist seit 0.1.18 ein reiner Proxy auf die Plattform: Tool-Namen,
102
+ Schemas und Safety-Annotations kommen direkt vom Server und sind damit immer
103
+ identisch mit dem Remote-Connector (`https://knowmind.de/api/mcp/v1`).
104
+
105
+ - `knowmind_recall` — Hybride Suche im Wissensspeicher des Mandanten
106
+ - `knowmind_recall_at_time` — Recall mit Zeitfilter (bi-temporal)
107
+ - `knowmind_store_memory` — Neue Erinnerung anlegen (Titel + Inhalt)
108
+ - `knowmind_upload_document` — Längeren Text als Dokument ingestieren (Upsert-per-Titel: gleicher Titel ersetzt die alte Version)
109
+ - `knowmind_update_fact` — Fakt bi-temporal aktualisieren (Historie bleibt)
110
+ - `knowmind_link` — Typisierte Beziehung anlegen (Inverse wird automatisch gesetzt)
111
+ - `knowmind_unlink` — Beziehung wieder entfernen (samt Inverse)
112
+ - `knowmind_list_relations` — Beziehungen einer Erinnerung auflisten
113
+ - `knowmind_list_recent` — Zuletzt angelegte Dokumente/Memories des Mandanten auflisten, sortiert nach Anlagedatum absteigend
114
+ - `knowmind_stats` — Statistik über gespeicherte Erinnerungen und Beziehungen
115
+ - `knowmind_health` — Verfügbarkeits-Status der Plattform
116
+
117
+ Inverse-Beziehungen (z. B. `IS_EMPLOYEE_OF` zu `HAS_EMPLOYEE`) werden
118
+ serverseitig automatisch mit angelegt. Hinweis: `knowmind upload` als
119
+ CLI-Befehl läuft über die REST-Schnittstelle (`/api/documents`), nicht über MCP.
120
+
121
+ ## Daten in Deutschland
122
+
123
+ knowmind ist das Agentengehirn aus Deutschland: Ihre Inhalte (Memories, Account- und Metadaten) werden
124
+ ausschließlich auf Servern in Deutschland (Hetzner-Rechenzentrum) gespeichert und verlassen Deutschland nicht.
125
+ Auftragsverarbeitung (AVV) nach Art. 28 DSGVO verfügbar: https://knowmind.de/legal/avv
126
+
127
+ **Hinweis (Bring-your-own-Key):** Wenn Sie eigene Schlüssel externer KI-Anbieter hinterlegen, werden Ihre
128
+ Anfragen direkt an den von Ihnen gewählten Anbieter übermittelt. Sitzt dieser außerhalb der EU, kann dabei
129
+ ein Drittlandtransfer stattfinden, für den Sie als Verantwortlicher zuständig sind.
130
+
131
+ ## Haftung & Nutzung (Disclaimer)
132
+
133
+ - **Software:** Dieses Paket steht unter der **Apache-Lizenz 2.0** und wird „AS IS" ohne jegliche
134
+ Gewährleistung bereitgestellt; die Haftung ist im Rahmen der Lizenz (Abschnitte 7 und 8)
135
+ ausgeschlossen bzw. beschränkt. Siehe `LICENSE`.
136
+ - **Eigenes Konto, eigener Token:** knowmind bündelt keine Zugangsdaten. Sie nutzen Ihren eigenen
137
+ knowmind.de-Account und API-Token. Anlegen: https://knowmind.de/dashboard/api-tokens
138
+ - **Eigene Kosten/Verbrauch:** Jede Nutzung (API-Anfragen, Token-/Kontingentverbrauch, ggf.
139
+ modellbezogene Kosten) erfolgt über Ihren eigenen Account und auf Ihre Verantwortung. Verbrauch
140
+ und Kosten sind im knowmind.de-Dashboard transparent einsehbar.
141
+ - **Service-Bedingungen:** Für die Nutzung der gehosteten Plattform gelten die AGB und die
142
+ Datenschutzerklärung von knowmind.de:
143
+ [AGB](https://knowmind.de/legal/agb) · [Datenschutz](https://knowmind.de/legal/datenschutz) ·
144
+ [AVV](https://knowmind.de/legal/avv) · [Impressum](https://knowmind.de/legal/impressum)
145
+ - **Kein Einsatz in sicherheitskritischen Bereichen:** knowmind ist ein Gedächtnis-/Recall-Dienst und
146
+ **nicht** für den Betrieb von selbstfahrenden Fahrzeugen, kritischer Infrastruktur, medizinischen oder
147
+ lebenserhaltenden Systemen oder sonstigen Anwendungen bestimmt, bei denen ein Fehler oder Ausfall zu Tod,
148
+ Personen-, Umwelt- oder schweren Sachschäden führen kann. Ein Einsatz in solchen Umgebungen erfolgt auf
149
+ alleiniges Risiko des Nutzers.
150
+
151
+ Anbieter: Schübeler Consulting — Johann Jörgen Schübeler. Kontakt: info@schuebeler-consulting.de
package/bin/knowmind.js CHANGED
@@ -93,7 +93,7 @@ async function runLogin() {
93
93
  jsonrpc: "2.0",
94
94
  id: 1,
95
95
  method: "tools/call",
96
- params: { name: "knowmind.health", arguments: {} },
96
+ params: { name: "knowmind_health", arguments: {} },
97
97
  }),
98
98
  }).catch((e) => ({ ok: false, _netError: e.message }));
99
99
  if (r._netError) {
@@ -144,7 +144,11 @@ async function runUpload() {
144
144
  title = title ?? basename(path);
145
145
  }
146
146
  const data = await uploadDocument(title, content);
147
- console.log(`Indexiert: ${data.chunksWritten} Chunks (Provider ${data.embeddingProvider}).`);
147
+ if (data.unchanged || data.duplicate) {
148
+ console.log(`Unverändert/Duplikat: Inhalt liegt bereits indexiert vor (Doc ${data.id ?? "?"}).`);
149
+ } else {
150
+ console.log(`Indexiert: ${data.chunksWritten} Chunks (Provider ${data.embeddingProvider}).`);
151
+ }
148
152
  }
149
153
 
150
154
  async function runSync() {
package/package.json CHANGED
@@ -1,59 +1,60 @@
1
- {
2
- "name": "knowmind",
3
- "version": "0.1.17",
4
- "mcpName": "io.github.Schubeler-Consulting/knowmind",
5
- "description": "Knowmind — das Agentengehirn aus Deutschland: CLI + MCP-Server (Langzeitgedächtnis & Wissensgraph für Ihre KI, Server in Deutschland).",
6
- "type": "module",
7
- "license": "Apache-2.0",
8
- "homepage": "https://knowmind.de",
9
- "repository": {
10
- "type": "git",
11
- "url": "git+https://github.com/Schubeler-Consulting/knowmind.git"
12
- },
13
- "bugs": {
14
- "url": "https://knowmind.de/support",
15
- "email": "info@schuebeler-consulting.de"
16
- },
17
- "author": {
18
- "name": "Knowmind",
19
- "email": "info@schuebeler-consulting.de",
20
- "url": "https://knowmind.de"
21
- },
22
- "engines": {
23
- "node": ">=20"
24
- },
25
- "bin": {
26
- "knowmind": "bin/knowmind.js"
27
- },
28
- "files": [
29
- "bin",
30
- "src",
31
- "README.md",
32
- "LICENSE"
33
- ],
34
- "scripts": {
35
- "test": "node --test src/*.test.js"
36
- },
37
- "dependencies": {
38
- "@huggingface/transformers": "^3.5.0"
39
- },
40
- "overrides": {
41
- "global-agent": "^4.1.3"
42
- },
43
- "keywords": [
44
- "knowmind",
45
- "mcp",
46
- "model-context-protocol",
47
- "knowledge-graph",
48
- "recall",
49
- "memory",
50
- "rag",
51
- "claude",
52
- "openai",
53
- "anthropic",
54
- "ai"
55
- ],
56
- "publishConfig": {
57
- "access": "public"
58
- }
59
- }
1
+ {
2
+ "name": "knowmind",
3
+ "version": "0.1.19",
4
+ "mcpName": "io.github.Schubeler-Consulting/knowmind",
5
+ "description": "Knowmind — das Agentengehirn aus Deutschland: CLI + MCP-Server (Langzeitgedächtnis & Wissensgraph für Ihre KI, Server in Deutschland).",
6
+ "type": "module",
7
+ "license": "Apache-2.0",
8
+ "homepage": "https://knowmind.de",
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "git+https://github.com/Schubeler-Consulting/knowmind.git"
12
+ },
13
+ "bugs": {
14
+ "url": "https://knowmind.de/support",
15
+ "email": "info@schuebeler-consulting.de"
16
+ },
17
+ "author": {
18
+ "name": "Knowmind",
19
+ "email": "info@schuebeler-consulting.de",
20
+ "url": "https://knowmind.de"
21
+ },
22
+ "engines": {
23
+ "node": ">=20"
24
+ },
25
+ "bin": {
26
+ "knowmind": "bin/knowmind.js"
27
+ },
28
+ "files": [
29
+ "bin",
30
+ "src",
31
+ "README.md",
32
+ "CHANGELOG.md",
33
+ "LICENSE"
34
+ ],
35
+ "scripts": {
36
+ "test": "node --test src/*.test.js"
37
+ },
38
+ "dependencies": {
39
+ "@huggingface/transformers": "^3.5.0"
40
+ },
41
+ "overrides": {
42
+ "global-agent": "^4.1.3"
43
+ },
44
+ "keywords": [
45
+ "knowmind",
46
+ "mcp",
47
+ "model-context-protocol",
48
+ "knowledge-graph",
49
+ "recall",
50
+ "memory",
51
+ "rag",
52
+ "claude",
53
+ "openai",
54
+ "anthropic",
55
+ "ai"
56
+ ],
57
+ "publishConfig": {
58
+ "access": "public"
59
+ }
60
+ }
package/src/client.js CHANGED
@@ -1,115 +1,115 @@
1
- /**
2
- * Knowmind-API-Client.
3
- *
4
- * Spricht ausschließlich gegen den MCP-Endpoint /api/mcp/v1 (JSON-RPC),
5
- * weil dieser bereits Bearer-Auth + Tools für recall/stats/health bietet.
6
- * Document-Upload geht zusätzlich gegen die REST-API /api/documents.
7
- */
8
- import { loadConfig } from "./config.js";
9
-
10
- let rpcId = 1;
11
-
12
- async function rpc(method, params, options = {}) {
13
- const { apiUrl, token } = loadConfig();
14
- if (!token) throw new Error("Kein Token konfiguriert — bitte `knowmind login` ausführen.");
15
- const r = await fetch(`${apiUrl}/api/mcp/v1`, {
16
- method: "POST",
17
- headers: {
18
- "content-type": "application/json",
19
- authorization: `Bearer ${token}`,
20
- ...(options.headers ?? {}),
21
- },
22
- body: JSON.stringify({ jsonrpc: "2.0", id: rpcId++, method, params }),
23
- signal: options.signal,
24
- });
25
- const data = await r.json();
26
- if (data.error) throw new Error(`${data.error.code}: ${data.error.message}`);
27
- return data.result;
28
- }
29
-
30
- export async function recall(query, { k = 5, hops = 2 } = {}) {
31
- const res = await rpc("tools/call", {
32
- name: "knowmind.recall",
33
- arguments: { query, k, hops },
34
- });
35
- // MCP-Antwort: { content: [{ type: "text", text: "<JSON>" }] }
36
- const text = res.content?.[0]?.text;
37
- if (!text) return null;
38
- return JSON.parse(text);
39
- }
40
-
41
- export async function stats() {
42
- const res = await rpc("tools/call", { name: "knowmind.stats", arguments: {} });
43
- return JSON.parse(res.content?.[0]?.text ?? "{}");
44
- }
45
-
46
- export async function health() {
47
- const res = await rpc("tools/call", { name: "knowmind.health", arguments: {} });
48
- return JSON.parse(res.content?.[0]?.text ?? "{}");
49
- }
50
-
51
- /**
52
- * Lädt ein Dokument hoch. Default-Pfad: Client rechnet die Embeddings
53
- * lokal und schickt sie mit — der Server speichert nur noch, ohne eigene
54
- * Berechnung. Skaliert deutlich besser.
55
- *
56
- * Wird KNOWMIND_EMBED_MODE=server gesetzt, geht der alte Pfad: Server
57
- * rechnet selbst. Sinnvoll als Fallback, wenn der Client kein Modell
58
- * laden kann (z. B. RAM-knapp).
59
- */
60
- export async function uploadDocument(title, content) {
61
- const { apiUrl, token } = loadConfig();
62
- if (!token) throw new Error("Kein Token konfiguriert.");
63
-
64
- const mode = (process.env.KNOWMIND_EMBED_MODE || "client").toLowerCase();
65
- let body;
66
- if (mode === "client") {
67
- try {
68
- const { prepareChunks, embedBatch, MODEL } = await import("./local-embedding.js");
69
- // prepareChunks zerlegt Text in Standard-Chunks UND extrahiert
70
- // Preference-/Fact-/Update-Statements als Zusatz-Chunks mit type-Tag.
71
- // Recall-Server boostet die getaggten Chunks für passende Queries.
72
- const prepared = await prepareChunks(content);
73
- const vectors = await embedBatch(prepared.map((c) => c.content), "passage");
74
- body = {
75
- title,
76
- content,
77
- chunks: prepared.map((c, i) => ({
78
- content: c.content,
79
- embedding: vectors[i],
80
- ...(c.metadata ? { metadata: c.metadata } : {}),
81
- })),
82
- embeddingModel: MODEL,
83
- };
84
- } catch (err) {
85
- process.stderr.write(
86
- `[knowmind] lokales Embedding fehlgeschlagen, fallback auf Server: ${err.message}\n`,
87
- );
88
- body = { title, content };
89
- }
90
- } else {
91
- body = { title, content };
92
- }
93
-
94
- const r = await fetch(`${apiUrl}/api/documents`, {
95
- method: "POST",
96
- headers: { "content-type": "application/json", authorization: `Bearer ${token}` },
97
- body: JSON.stringify(body),
98
- });
99
- const text = await r.text();
100
- let data;
101
- try {
102
- data = text ? JSON.parse(text) : {};
103
- } catch {
104
- if (!r.ok) {
105
- throw new Error(`HTTP ${r.status} ${r.statusText} — ${text.slice(0, 200)}`);
106
- }
107
- throw new Error(`HTTP ${r.status} lieferte ungültiges JSON: ${text.slice(0, 200)}`);
108
- }
109
- if (!r.ok) throw new Error(data.error ?? `HTTP ${r.status} ${r.statusText}`);
110
- return data;
111
- }
112
-
113
- export async function listTools() {
114
- return await rpc("tools/list", {});
115
- }
1
+ /**
2
+ * Knowmind-API-Client.
3
+ *
4
+ * Spricht ausschließlich gegen den MCP-Endpoint /api/mcp/v1 (JSON-RPC),
5
+ * weil dieser bereits Bearer-Auth + Tools für recall/stats/health bietet.
6
+ * Document-Upload geht zusätzlich gegen die REST-API /api/documents.
7
+ */
8
+ import { loadConfig } from "./config.js";
9
+
10
+ let rpcId = 1;
11
+
12
+ async function rpc(method, params, options = {}) {
13
+ const { apiUrl, token } = loadConfig();
14
+ if (!token) throw new Error("Kein Token konfiguriert — bitte `knowmind login` ausführen.");
15
+ const r = await fetch(`${apiUrl}/api/mcp/v1`, {
16
+ method: "POST",
17
+ headers: {
18
+ "content-type": "application/json",
19
+ authorization: `Bearer ${token}`,
20
+ ...(options.headers ?? {}),
21
+ },
22
+ body: JSON.stringify({ jsonrpc: "2.0", id: rpcId++, method, params }),
23
+ signal: options.signal,
24
+ });
25
+ const data = await r.json();
26
+ if (data.error) throw new Error(`${data.error.code}: ${data.error.message}`);
27
+ return data.result;
28
+ }
29
+
30
+ export async function recall(query, { k = 5, hops = 2 } = {}) {
31
+ const res = await rpc("tools/call", {
32
+ name: "knowmind_recall",
33
+ arguments: { query, k, hops },
34
+ });
35
+ // MCP-Antwort: { content: [{ type: "text", text: "<JSON>" }] }
36
+ const text = res.content?.[0]?.text;
37
+ if (!text) return null;
38
+ return JSON.parse(text);
39
+ }
40
+
41
+ export async function stats() {
42
+ const res = await rpc("tools/call", { name: "knowmind_stats", arguments: {} });
43
+ return JSON.parse(res.content?.[0]?.text ?? "{}");
44
+ }
45
+
46
+ export async function health() {
47
+ const res = await rpc("tools/call", { name: "knowmind_health", arguments: {} });
48
+ return JSON.parse(res.content?.[0]?.text ?? "{}");
49
+ }
50
+
51
+ /**
52
+ * Lädt ein Dokument hoch. Default-Pfad: Client rechnet die Embeddings
53
+ * lokal und schickt sie mit — der Server speichert nur noch, ohne eigene
54
+ * Berechnung. Skaliert deutlich besser.
55
+ *
56
+ * Wird KNOWMIND_EMBED_MODE=server gesetzt, geht der alte Pfad: Server
57
+ * rechnet selbst. Sinnvoll als Fallback, wenn der Client kein Modell
58
+ * laden kann (z. B. RAM-knapp).
59
+ */
60
+ export async function uploadDocument(title, content) {
61
+ const { apiUrl, token } = loadConfig();
62
+ if (!token) throw new Error("Kein Token konfiguriert.");
63
+
64
+ const mode = (process.env.KNOWMIND_EMBED_MODE || "client").toLowerCase();
65
+ let body;
66
+ if (mode === "client") {
67
+ try {
68
+ const { prepareChunks, embedBatch, MODEL } = await import("./local-embedding.js");
69
+ // prepareChunks zerlegt Text in Standard-Chunks UND extrahiert
70
+ // Preference-/Fact-/Update-Statements als Zusatz-Chunks mit type-Tag.
71
+ // Recall-Server boostet die getaggten Chunks für passende Queries.
72
+ const prepared = await prepareChunks(content);
73
+ const vectors = await embedBatch(prepared.map((c) => c.content), "passage");
74
+ body = {
75
+ title,
76
+ content,
77
+ chunks: prepared.map((c, i) => ({
78
+ content: c.content,
79
+ embedding: vectors[i],
80
+ ...(c.metadata ? { metadata: c.metadata } : {}),
81
+ })),
82
+ embeddingModel: MODEL,
83
+ };
84
+ } catch (err) {
85
+ process.stderr.write(
86
+ `[knowmind] lokales Embedding fehlgeschlagen, fallback auf Server: ${err.message}\n`,
87
+ );
88
+ body = { title, content };
89
+ }
90
+ } else {
91
+ body = { title, content };
92
+ }
93
+
94
+ const r = await fetch(`${apiUrl}/api/documents`, {
95
+ method: "POST",
96
+ headers: { "content-type": "application/json", authorization: `Bearer ${token}` },
97
+ body: JSON.stringify(body),
98
+ });
99
+ const text = await r.text();
100
+ let data;
101
+ try {
102
+ data = text ? JSON.parse(text) : {};
103
+ } catch {
104
+ if (!r.ok) {
105
+ throw new Error(`HTTP ${r.status} ${r.statusText} — ${text.slice(0, 200)}`);
106
+ }
107
+ throw new Error(`HTTP ${r.status} lieferte ungültiges JSON: ${text.slice(0, 200)}`);
108
+ }
109
+ if (!r.ok) throw new Error(data.error ?? `HTTP ${r.status} ${r.statusText}`);
110
+ return data;
111
+ }
112
+
113
+ export async function listTools() {
114
+ return await rpc("tools/list", {});
115
+ }
package/src/mcp-stdio.js CHANGED
@@ -1,11 +1,18 @@
1
1
  /**
2
- * Lokaler MCP-Stdio-Server.
2
+ * Lokaler MCP-Stdio-Server — dünner Proxy auf die Knowmind-Plattform.
3
3
  *
4
- * Forwarded JSON-RPC-Requests von stdin an die Knowmind-Plattform (HTTP-MCP)
5
- * und schreibt die Antworten auf stdout. Damit kann Knowmind in jeden lokalen
6
- * MCP-fähigen Client (Claude Code, ChatGPT-Desktop, Cursor, ...) eingebunden
7
- * werden, ohne dass der Client Bearer-Token kennen muss — der CLI-Wrapper
8
- * verwaltet die Auth.
4
+ * Forwarded JSON-RPC-Requests von stdin an den Remote-MCP-Endpoint
5
+ * (POST {apiUrl}/api/mcp/v1) und schreibt die Antworten auf stdout. Damit kann
6
+ * Knowmind in jeden lokalen MCP-fähigen Client (Claude Code, Claude Desktop,
7
+ * ChatGPT, Cursor, ...) eingebunden werden, ohne dass der Client Bearer-Token
8
+ * kennen muss — der CLI-Wrapper verwaltet die Auth.
9
+ *
10
+ * DESIGN: Seit 0.1.18 ist dieser Server ein reiner Proxy. Tool-Definitionen,
11
+ * Namen (knowmind_recall, knowmind_store_memory, ...), Schemas und
12
+ * Safety-Annotations kommen direkt vom Server (tools/list wird durchgereicht).
13
+ * Dadurch können lokale Definitionen nie mehr vom Server-Stand abweichen —
14
+ * genau diese Abweichung (Punkt- vs. Unterstrich-Namen) hatte 0.1.17 unbrauchbar
15
+ * gemacht, nachdem die Plattform auf das MCP-Namensschema umgestellt wurde.
9
16
  *
10
17
  * Protokoll: stdio mit zeilenweise JSON (NDJSON-Style). Jedes Frame ist ein
11
18
  * vollständiges JSON-RPC-Objekt.
@@ -13,285 +20,37 @@
13
20
  import { loadConfig, VERSION } from "./config.js";
14
21
  import { createInterface } from "node:readline";
15
22
 
16
- // Typisierte Beziehungen zwischen Erinnerungen. Diese Liste ist die einzige
17
- // Quelle der Wahrheit für Agents. Inverse-Beziehungen werden serverseitig
18
- // automatisch materialisiert — der Agent setzt nur die Vorwärtsrichtung.
19
- const REL_TYPES = [
20
- "HAS_EMPLOYEE", "IS_EMPLOYEE_OF",
21
- "IS_LED_BY", "LEADS_ORGANIZATION",
22
- "OWNS", "OWNED_BY",
23
- "HAS_SKILL", "WORKS_ON", "FOR_CLIENT",
24
- "HAS_VERSION", "IS_VERSION_OF",
25
- "HAS_CHUNK", "CHUNK_OF",
26
- "HAS_EMBEDDING", "EMBEDDING_OF",
27
- "INDEXED_IN",
28
- "REFERENCES_ENTITY", "REFERENCED_BY",
29
- "PRODUCES", "PRODUCED_BY",
30
- "DEPENDS_ON", "ENABLES",
31
- "APPLIES_TO", "HAS_RULE",
32
- "REFERENCES", "SUPERSEDES", "SUPERSEDED_BY",
33
- "WAS_GENERATED_BY", "GENERATED",
34
- "USED", "USED_BY",
35
- "WAS_DERIVED_FROM", "DERIVATION_TARGET_OF",
36
- "WAS_ASSOCIATED_WITH",
37
- "MEASURED_METRIC",
38
- ];
23
+ /** Methoden, die lokal beantwortet werden (alles andere geht an den Server). */
24
+ const LOCAL_METHODS = new Set(["initialize", "ping"]);
39
25
 
40
- const KNOWMIND_TOOLS = [
41
- {
42
- name: "knowmind.recall",
43
- description:
44
- "Hybride Suche im Knowmind-Wissensspeicher des aktuellen Mandanten. Liefert die passendsten Treffer mit Quellenverweis und Trefferqualität.",
45
- inputSchema: {
46
- type: "object",
47
- properties: {
48
- query: { type: "string", description: "Natürlichsprachliche Frage" },
49
- k: { type: "integer", minimum: 1, maximum: 25, default: 5 },
50
- hops: { type: "integer", minimum: 0, maximum: 3, default: 2 },
51
- },
52
- required: ["query"],
53
- },
54
- },
55
- {
56
- name: "knowmind.store",
57
- description:
58
- "Speichert eine neue Erinnerung im aktuellen Mandanten. Liefert die Dokument-ID und die Anzahl der indexierten Abschnitte zurück. Sofort über knowmind.recall auffindbar.",
59
- inputSchema: {
60
- type: "object",
61
- properties: {
62
- title: {
63
- type: "string",
64
- description: "Kurzer Titel für die Erinnerung (max. 500 Zeichen)",
65
- },
66
- content: {
67
- type: "string",
68
- description: "Inhalt der Erinnerung als Text oder Markdown (max. 1 MB)",
69
- },
70
- },
71
- required: ["title", "content"],
72
- },
73
- },
74
- {
75
- name: "knowmind.link",
76
- description:
77
- "Legt eine typisierte Beziehung zwischen zwei Erinnerungen an. Die Gegen-Beziehung wird automatisch mit angelegt (zum Beispiel HAS_EMPLOYEE → IS_EMPLOYEE_OF). Der Agent setzt also nur die Vorwärtsrichtung. Verwende knowmind.recall, um zuvor die IDs zu finden.",
78
- inputSchema: {
79
- type: "object",
80
- properties: {
81
- fromId: { type: "string", description: "ID der Quell-Erinnerung" },
82
- toId: { type: "string", description: "ID der Ziel-Erinnerung" },
83
- relType: {
84
- type: "string",
85
- enum: REL_TYPES,
86
- description: "Beziehungstyp aus der zulässigen Liste",
87
- },
88
- },
89
- required: ["fromId", "toId", "relType"],
90
- },
91
- },
92
- {
93
- name: "knowmind.unlink",
94
- description:
95
- "Entfernt eine typisierte Beziehung. Die Gegen-Beziehung wird ebenfalls gelöscht.",
96
- inputSchema: {
97
- type: "object",
98
- properties: {
99
- fromId: { type: "string" },
100
- toId: { type: "string" },
101
- relType: { type: "string", enum: REL_TYPES },
102
- },
103
- required: ["fromId", "toId", "relType"],
104
- },
105
- },
106
- {
107
- name: "knowmind.relations",
108
- description:
109
- "Listet alle bestehenden Beziehungen einer Erinnerung. Hilfreich bevor neue Beziehungen angelegt werden, um Duplikate zu vermeiden.",
110
- inputSchema: {
111
- type: "object",
112
- properties: {
113
- memoryId: { type: "string", description: "ID der Erinnerung" },
114
- },
115
- required: ["memoryId"],
116
- },
117
- },
118
- {
119
- name: "knowmind.health",
120
- description: "Service-Verfügbarkeit prüfen.",
121
- inputSchema: { type: "object", properties: {} },
122
- },
123
- {
124
- name: "knowmind.stats",
125
- description: "Statistik des aktuellen Mandanten (Anzahl Erinnerungen, Beziehungen).",
126
- inputSchema: { type: "object", properties: {} },
127
- },
128
- {
129
- name: "knowmind.update_fact",
130
- description:
131
- "Bi-temporales Update: ersetzt eine bestehende Erinnerung durch eine neue. Die alte Erinnerung bleibt im Audit-Log mit validTo=now und wird per SUPERSEDES-Beziehung mit der neuen verbunden — so bleibt die Historie nachvollziehbar. Verwende dies, wenn sich Fakten ändern (Adresse, Vertragsstatus, Personen).",
132
- inputSchema: {
133
- type: "object",
134
- properties: {
135
- targetId: { type: "string", description: "ID der zu aktualisierenden Erinnerung" },
136
- newTitle: { type: "string", description: "Titel der neuen, gültigen Version" },
137
- newContent: { type: "string", description: "Inhalt der neuen Version" },
138
- updateReason: {
139
- type: "string",
140
- description: "Warum hat sich der Fakt geändert (z. B. 'Umzug', 'Vertrag erneuert')",
141
- },
142
- },
143
- required: ["targetId", "newTitle", "newContent"],
144
- },
145
- },
146
- {
147
- name: "knowmind.recall_at_time",
148
- description:
149
- "Recall mit Zeitfilter: liefert nur Erinnerungen, die zum gegebenen Zeitpunkt gültig waren. Antwort auf Fragen wie 'Was wussten wir am 14. März über den Kunden?' — der Knowmind-Vorteil gegenüber reinen Vector-Stores ohne Validity-Tracking.",
150
- inputSchema: {
151
- type: "object",
152
- properties: {
153
- query: { type: "string", description: "Natürlichsprachliche Frage" },
154
- asOf: {
155
- type: "string",
156
- description:
157
- "ISO-8601-Zeitstempel des Bezugszeitpunkts (Default: jetzt). Beispiel: '2026-03-14T00:00:00Z'",
158
- },
159
- k: { type: "integer", minimum: 1, maximum: 25, default: 5 },
160
- },
161
- required: ["query"],
162
- },
163
- },
164
- ];
26
+ async function forwardToServer(method, params) {
27
+ const { apiUrl, token } = loadConfig();
28
+ if (!token)
29
+ throw new Error("Knowmind: kein Token konfiguriert. `knowmind login` zuerst.");
165
30
 
166
- /** Hilfsfunktion: ruft einen REST-Endpunkt mit Bearer-Token auf und verpackt
167
- * die Antwort im MCP-Tool-Result-Format. */
168
- async function restCall(apiUrl, token, path, init) {
169
- const r = await fetch(`${apiUrl}${path}`, {
170
- ...init,
31
+ const r = await fetch(`${apiUrl}/api/mcp/v1`, {
32
+ method: "POST",
171
33
  headers: {
172
34
  "content-type": "application/json",
173
35
  authorization: `Bearer ${token}`,
174
- ...(init?.headers ?? {}),
175
36
  },
37
+ body: JSON.stringify({ jsonrpc: "2.0", id: 1, method, params }),
176
38
  });
177
39
  let data;
178
40
  try {
179
41
  data = await r.json();
180
42
  } catch {
181
- data = { error: `HTTP ${r.status}` };
182
- }
183
- if (!r.ok) {
43
+ // HTTP-Status ohne parsebaren JSON-Body sauber als JSON-RPC-Fehler melden.
184
44
  return {
185
45
  error: {
186
- code: -32000,
187
- message: data.error ?? `HTTP ${r.status}`,
188
- data,
46
+ code: r.ok ? -32700 : -32000,
47
+ message: r.ok
48
+ ? "Knowmind-Server lieferte kein gültiges JSON."
49
+ : `Knowmind-Server: HTTP ${r.status}`,
189
50
  },
190
51
  };
191
52
  }
192
- return {
193
- result: {
194
- content: [{ type: "text", text: JSON.stringify(data) }],
195
- },
196
- };
197
- }
198
-
199
- async function callRestTool(apiUrl, token, name, args) {
200
- switch (name) {
201
- case "knowmind.store": {
202
- const { title, content } = args;
203
- if (!title || !content) {
204
- return {
205
- error: {
206
- code: -32602,
207
- message: "knowmind.store benötigt title und content.",
208
- },
209
- };
210
- }
211
- return await restCall(apiUrl, token, "/api/documents", {
212
- method: "POST",
213
- body: JSON.stringify({ title, content }),
214
- });
215
- }
216
- case "knowmind.link": {
217
- const { fromId, toId, relType } = args;
218
- if (!fromId || !toId || !relType) {
219
- return {
220
- error: {
221
- code: -32602,
222
- message: "knowmind.link benötigt fromId, toId, relType.",
223
- },
224
- };
225
- }
226
- return await restCall(apiUrl, token, "/api/graph/relations", {
227
- method: "POST",
228
- body: JSON.stringify({ fromId, toId, relType }),
229
- });
230
- }
231
- case "knowmind.unlink": {
232
- const { fromId, toId, relType } = args;
233
- if (!fromId || !toId || !relType) {
234
- return {
235
- error: {
236
- code: -32602,
237
- message: "knowmind.unlink benötigt fromId, toId, relType.",
238
- },
239
- };
240
- }
241
- const params = new URLSearchParams({ fromId, toId, relType });
242
- return await restCall(apiUrl, token, `/api/graph/relations?${params.toString()}`, {
243
- method: "DELETE",
244
- });
245
- }
246
- case "knowmind.relations": {
247
- const { memoryId } = args;
248
- if (!memoryId) {
249
- return {
250
- error: {
251
- code: -32602,
252
- message: "knowmind.relations benötigt memoryId.",
253
- },
254
- };
255
- }
256
- const params = new URLSearchParams({ memoryId });
257
- return await restCall(apiUrl, token, `/api/graph/relations?${params.toString()}`, {
258
- method: "GET",
259
- });
260
- }
261
- default:
262
- return {
263
- error: { code: -32601, message: `Unknown tool: ${name}` },
264
- };
265
- }
266
- }
267
-
268
- async function forwardToServer(method, params) {
269
- const { apiUrl, token } = loadConfig();
270
- if (!token)
271
- throw new Error("Knowmind: kein Token konfiguriert. `knowmind login` zuerst.");
272
-
273
- // Tools, die nicht über den MCP-Endpoint, sondern direkt gegen die
274
- // REST-Schnittstelle laufen (Anlegen + Graph-Beziehungen).
275
- if (
276
- method === "tools/call" &&
277
- params &&
278
- typeof params.name === "string" &&
279
- ["knowmind.store", "knowmind.link", "knowmind.unlink", "knowmind.relations"].includes(
280
- params.name,
281
- )
282
- ) {
283
- return await callRestTool(apiUrl, token, params.name, params.arguments ?? {});
284
- }
285
-
286
- const r = await fetch(`${apiUrl}/api/mcp/v1`, {
287
- method: "POST",
288
- headers: {
289
- "content-type": "application/json",
290
- authorization: `Bearer ${token}`,
291
- },
292
- body: JSON.stringify({ jsonrpc: "2.0", id: 1, method, params }),
293
- });
294
- return await r.json();
53
+ return data;
295
54
  }
296
55
 
297
56
  function write(obj) {
@@ -337,7 +96,7 @@ async function probeAuth() {
337
96
  jsonrpc: "2.0",
338
97
  id: 1,
339
98
  method: "tools/call",
340
- params: { name: "knowmind.health", arguments: {} },
99
+ params: { name: "knowmind_health", arguments: {} },
341
100
  }),
342
101
  });
343
102
  if (!r.ok) {
@@ -366,8 +125,7 @@ async function probeAuth() {
366
125
 
367
126
  export async function runStdioServer() {
368
127
  // Auth einmal am Start prüfen. Das Ergebnis cachen — der MCP-Client
369
- // soll sofort beim initialize wissen, ob die Verbindung wirklich
370
- // steht.
128
+ // soll sofort beim initialize wissen, ob die Verbindung wirklich steht.
371
129
  const auth = await probeAuth();
372
130
  if (!auth.ok) {
373
131
  process.stderr.write(`[knowmind] AUTH-FEHLER: ${auth.reason}\n`);
@@ -389,87 +147,60 @@ export async function runStdioServer() {
389
147
  continue;
390
148
  }
391
149
  try {
392
- switch (req.method) {
393
- case "initialize":
394
- if (!auth.ok) {
395
- // Initialize FEHLSCHLAGEN, damit der MCP-Client „connected"
396
- // nicht fälschlich anzeigt. Claude Code, Codex und Cursor
397
- // werten -32001 als harte Connection-Failure.
398
- write({
399
- jsonrpc: "2.0",
400
- id: req.id ?? null,
401
- error: {
402
- code: -32001,
403
- message: `Knowmind nicht verbunden: ${auth.reason}`,
404
- },
405
- });
406
- break;
407
- }
408
- write({
409
- jsonrpc: "2.0",
410
- id: req.id ?? null,
411
- result: {
412
- protocolVersion: "2025-06-18",
413
- serverInfo: { name: "knowmind", version: VERSION },
414
- capabilities: { tools: {} },
415
- },
416
- });
417
- break;
418
- case "tools/list":
419
- if (!auth.ok) {
420
- write({
421
- jsonrpc: "2.0",
422
- id: req.id ?? null,
423
- error: {
424
- code: -32001,
425
- message: `Knowmind nicht verbunden: ${auth.reason}`,
426
- },
427
- });
428
- break;
429
- }
430
- write({
431
- jsonrpc: "2.0",
432
- id: req.id ?? null,
433
- result: { tools: KNOWMIND_TOOLS },
434
- });
435
- break;
436
- case "tools/call": {
437
- if (!auth.ok) {
438
- write({
439
- jsonrpc: "2.0",
440
- id: req.id ?? null,
441
- error: {
442
- code: -32001,
443
- message: `Knowmind nicht verbunden: ${auth.reason}`,
444
- },
445
- });
446
- break;
447
- }
448
- const upstream = await forwardToServer(req.method, req.params);
449
- // Upstream-Response hat eigene jsonrpc/id-Felder — die müssen
450
- // durch die Client-id ersetzt werden, damit Claude Code, Codex
451
- // und Gemini ihre Anfragen korrekt zuordnen können.
452
- const response = {
453
- jsonrpc: "2.0",
454
- id: req.id ?? null,
455
- };
456
- if (upstream && typeof upstream === "object" && "result" in upstream) {
457
- response.result = upstream.result;
458
- } else if (upstream && typeof upstream === "object" && "error" in upstream) {
459
- response.error = upstream.error;
460
- } else {
461
- response.result = upstream;
462
- }
463
- write(response);
464
- break;
150
+ // Notifications (kein id-Feld) bekommen per JSON-RPC keine Antwort.
151
+ const isNotification = req.id === undefined && typeof req.method === "string" && req.method.startsWith("notifications/");
152
+ if (isNotification) continue;
153
+
154
+ if (!auth.ok && req.method !== "ping") {
155
+ // Initialize (und alles weitere) FEHLSCHLAGEN lassen, damit der
156
+ // MCP-Client „connected" nicht fälschlich anzeigt. Claude Code,
157
+ // Codex und Cursor werten -32001 als harte Connection-Failure.
158
+ write({
159
+ jsonrpc: "2.0",
160
+ id: req.id ?? null,
161
+ error: {
162
+ code: -32001,
163
+ message: `Knowmind nicht verbunden: ${auth.reason}`,
164
+ },
165
+ });
166
+ continue;
167
+ }
168
+
169
+ if (LOCAL_METHODS.has(req.method)) {
170
+ if (req.method === "ping") {
171
+ write({ jsonrpc: "2.0", id: req.id ?? null, result: {} });
172
+ continue;
465
173
  }
466
- default:
467
- write({
468
- jsonrpc: "2.0",
469
- id: req.id ?? null,
470
- error: { code: -32601, message: `Method not found: ${req.method}` },
471
- });
174
+ // initialize
175
+ write({
176
+ jsonrpc: "2.0",
177
+ id: req.id ?? null,
178
+ result: {
179
+ protocolVersion: "2025-06-18",
180
+ serverInfo: { name: "knowmind", version: VERSION },
181
+ capabilities: { tools: {}, prompts: {} },
182
+ },
183
+ });
184
+ continue;
185
+ }
186
+
187
+ // Alles andere (tools/list, tools/call, prompts/list, prompts/get, …)
188
+ // geht 1:1 an den Server — Definitionen bleiben dadurch immer synchron.
189
+ const upstream = await forwardToServer(req.method, req.params);
190
+ // Upstream-Response hat eigene jsonrpc/id-Felder — die müssen durch
191
+ // die Client-id ersetzt werden, damit der Client korrekt zuordnet.
192
+ const response = {
193
+ jsonrpc: "2.0",
194
+ id: req.id ?? null,
195
+ };
196
+ if (upstream && typeof upstream === "object" && "result" in upstream) {
197
+ response.result = upstream.result;
198
+ } else if (upstream && typeof upstream === "object" && "error" in upstream) {
199
+ response.error = upstream.error;
200
+ } else {
201
+ response.result = upstream;
472
202
  }
203
+ write(response);
473
204
  } catch (e) {
474
205
  write({
475
206
  jsonrpc: "2.0",
package/src/sync.js CHANGED
@@ -106,16 +106,21 @@ export async function syncDirectory(dir, options = {}) {
106
106
  try {
107
107
  const result = await uploadDocument(title, content);
108
108
  uploaded += 1;
109
+ // Server antwortet bei sha-identischem Inhalt mit unchanged:true
110
+ // (historisch duplicate:true) — beide Felder akzeptieren.
111
+ const isDuplicate = Boolean(result.unchanged ?? result.duplicate);
109
112
  manifest.files[rel] = {
110
113
  sha256: hash,
111
114
  documentId: result.id ?? null,
112
115
  lastSync: new Date().toISOString(),
113
- duplicate: Boolean(result.duplicate),
116
+ duplicate: isDuplicate,
114
117
  };
115
- // Manifest regelmäßig zwischenspeichern, damit ein Abbruch mid-run
116
- // nicht alle Fortschritte verliert.
117
- if (uploaded % 10 === 0) saveManifest(manifestPath, manifest);
118
- const flag = result.duplicate ? "dup " : "new ";
118
+ // Manifest nach JEDEM erfolgreichen Upload speichern (2026-06-10):
119
+ // Der Stop-Hook killt den Sync nach 120 s — mit 10er-Batches gingen
120
+ // Manifest-Stände verloren und identischer Inhalt wurde endlos
121
+ // re-POSTet (Ursache der Ingest-500-Schleife 26.–27.05.).
122
+ saveManifest(manifestPath, manifest);
123
+ const flag = isDuplicate ? "dup " : "new ";
119
124
  process.stdout.write(` [${scanned}/${total}] ${flag} ${rel}\n`);
120
125
  } catch (e) {
121
126
  failed += 1;