knowmind 0.3.4 → 0.3.5
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/package.json +1 -1
- package/src/install.js +37 -2
- package/src/mcp-starter.py +99 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "knowmind",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.5",
|
|
4
4
|
"mcpName": "io.github.Schubeler-Consulting/knowmind",
|
|
5
5
|
"description": "Knowmind — das Agentengehirn aus Deutschland: CLI + MCP-Server (Langzeitgedächtnis & Wissensgraph für Ihre KI, Server in Deutschland).",
|
|
6
6
|
"type": "module",
|
package/src/install.js
CHANGED
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
import { mkdirSync, readFileSync, writeFileSync, existsSync } from "node:fs";
|
|
16
16
|
import { homedir, platform } from "node:os";
|
|
17
17
|
import { dirname, join } from "node:path";
|
|
18
|
+
import { fileURLToPath } from "node:url";
|
|
18
19
|
|
|
19
20
|
const DEFAULT_API = "https://knowmind.de";
|
|
20
21
|
const NPX = "npx";
|
|
@@ -126,17 +127,51 @@ function tokenRef(secretStyle, literalToken) {
|
|
|
126
127
|
}
|
|
127
128
|
}
|
|
128
129
|
|
|
130
|
+
/**
|
|
131
|
+
* Startbefehl für den MCP-Server.
|
|
132
|
+
*
|
|
133
|
+
* Unter Windows nicht direkt `npx`: Das ist ein Konsolenprogramm, und hat der
|
|
134
|
+
* KI-Client keine eigene Konsole (Desktop-Anwendung, IDE-Erweiterung), gibt
|
|
135
|
+
* Windows dem Kind bei JEDEM Werkzeugaufruf ein eigenes Fenster. Das blitzt
|
|
136
|
+
* nicht nur, es stiehlt den Tastaturfokus mitten im Tippen. Johann am
|
|
137
|
+
* 10.08.2026: „Viele werden es deshalb deinstallieren." — und er hat recht.
|
|
138
|
+
*
|
|
139
|
+
* Deshalb dazwischen `pythonw.exe` (GUI-Programm, öffnet selbst kein Fenster),
|
|
140
|
+
* das npx mit CREATE_NO_WINDOW startet und die Datenströme durchreicht. Ohne
|
|
141
|
+
* Python auf dem Rechner bleibt es beim direkten npx-Aufruf — eine ehrliche
|
|
142
|
+
* Grenze ist besser als eine halbe Lösung.
|
|
143
|
+
*/
|
|
144
|
+
function startBefehl() {
|
|
145
|
+
const pythonw = findePythonwFuerMcp();
|
|
146
|
+
if (!pythonw) return { command: NPX, args: NPX_ARGS };
|
|
147
|
+
const starter = join(dirname(fileURLToPath(import.meta.url)), "mcp-starter.py");
|
|
148
|
+
return { command: pythonw, args: [starter, NPX, ...NPX_ARGS] };
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
/** Vollständiger Pfad zu pythonw.exe, oder null. */
|
|
152
|
+
function findePythonwFuerMcp() {
|
|
153
|
+
if (platform() !== "win32") return null;
|
|
154
|
+
const kandidaten = [];
|
|
155
|
+
const lokal = process.env.LOCALAPPDATA;
|
|
156
|
+
for (const v of ["313", "312", "311", "310"]) {
|
|
157
|
+
if (lokal) kandidaten.push(join(lokal, "Programs", "Python", `Python${v}`, "pythonw.exe"));
|
|
158
|
+
kandidaten.push(join("C:\\", `Python${v}`, "pythonw.exe"));
|
|
159
|
+
}
|
|
160
|
+
return kandidaten.find((p) => existsSync(p)) ?? null;
|
|
161
|
+
}
|
|
162
|
+
|
|
129
163
|
// Server-Eintrag im Schema der Familie.
|
|
130
164
|
function serverEntry(ide, { apiUrl, literalToken }) {
|
|
131
165
|
const env = {
|
|
132
166
|
KNOWMIND_TOKEN: tokenRef(ide.secret, literalToken),
|
|
133
167
|
KNOWMIND_API_URL: apiUrl,
|
|
134
168
|
};
|
|
169
|
+
const { command, args } = startBefehl();
|
|
135
170
|
if (ide.family === "servers") {
|
|
136
171
|
// VS Code verlangt einen Transport-Typ.
|
|
137
|
-
return { type: "stdio", command
|
|
172
|
+
return { type: "stdio", command, args, env };
|
|
138
173
|
}
|
|
139
|
-
return { command
|
|
174
|
+
return { command, args, env };
|
|
140
175
|
}
|
|
141
176
|
|
|
142
177
|
// Vollständiges Snippet (für --print / GUI-IDEs).
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
"""Startet den knowmind-MCP-Server unter Windows ohne Konsolenfenster.
|
|
3
|
+
|
|
4
|
+
WARUM (10.08.2026, Johann): „Mein Fenster öffnet sich noch immer, wenn knowmind
|
|
5
|
+
gecalled wird. Viele werden es deshalb deinstallieren." — und nachgeschoben:
|
|
6
|
+
„Du kannst währenddessen auch nicht tippen. Sehr nervig." Das Fenster stiehlt
|
|
7
|
+
den Tastaturfokus, es ist also kein Schönheitsfehler, sondern eine Unterbrechung
|
|
8
|
+
mitten im Satz.
|
|
9
|
+
|
|
10
|
+
Ein MCP-Server wird als `node …/knowmind.js mcp` gestartet. `node.exe` ist ein
|
|
11
|
+
Konsolenprogramm; hat der startende KI-Client keine eigene Konsole — Desktop-
|
|
12
|
+
Anwendung, IDE-Erweiterung —, gibt Windows dem Kind ein eigenes Fenster. Bei
|
|
13
|
+
jedem Werkzeugaufruf blitzt es auf. Ein Gedächtnis, das bei jeder Nutzung den
|
|
14
|
+
Fokus klaut, fliegt wieder runter, egal wie gut es ist.
|
|
15
|
+
|
|
16
|
+
`node.exe` hat kein fensterloses Gegenstück. `pythonw.exe` ist ein GUI-Programm
|
|
17
|
+
und öffnet selbst keins — es startet node mit CREATE_NO_WINDOW.
|
|
18
|
+
|
|
19
|
+
WARUM DURCHREICHEN STATT VERERBEN: Die naheliegende Fassung startet node ohne
|
|
20
|
+
stdin/stdout-Umleitung, damit es die Handles des Elternprozesses erbt. Unter
|
|
21
|
+
`pythonw.exe` schlägt das fehl — als GUI-Programm hat es keine verlässlichen
|
|
22
|
+
Standard-Handles, node erbt ins Leere und die Antwort kommt nie beim Client an
|
|
23
|
+
(gemessen 10.08.2026: initialize blieb unbeantwortet). Deshalb werden die
|
|
24
|
+
Datenströme über Pipes geführt und in beide Richtungen durchgepumpt. Roh, ohne
|
|
25
|
+
Zeilenpufferung — MCP-Nachrichten dürfen nicht verzögert oder zerschnitten
|
|
26
|
+
werden.
|
|
27
|
+
|
|
28
|
+
Aufruf: pythonw.exe mcp-starter.py <befehl> [argumente]
|
|
29
|
+
z. B. … mcp-starter.py npx -y knowmind mcp
|
|
30
|
+
oder … mcp-starter.py node C:/…/knowmind.js mcp
|
|
31
|
+
"""
|
|
32
|
+
import shutil
|
|
33
|
+
import subprocess
|
|
34
|
+
import sys
|
|
35
|
+
import threading
|
|
36
|
+
|
|
37
|
+
CREATE_NO_WINDOW = 0x08000000
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
def pumpe(quelle, ziel) -> None:
|
|
41
|
+
"""Schiebt Bytes weiter, sobald sie da sind, und schliesst am Ende sauber."""
|
|
42
|
+
try:
|
|
43
|
+
while True:
|
|
44
|
+
brocken = quelle.read(1)
|
|
45
|
+
if not brocken:
|
|
46
|
+
break
|
|
47
|
+
ziel.write(brocken)
|
|
48
|
+
ziel.flush()
|
|
49
|
+
except Exception: # noqa: BLE001 — Abbruch beim Beenden ist normal
|
|
50
|
+
pass
|
|
51
|
+
finally:
|
|
52
|
+
try:
|
|
53
|
+
ziel.close()
|
|
54
|
+
except Exception: # noqa: BLE001
|
|
55
|
+
pass
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
def main() -> int:
|
|
59
|
+
if len(sys.argv) < 2:
|
|
60
|
+
sys.stderr.write("Aufruf: mcp-starter.py <knowmind.js> [args...]\n")
|
|
61
|
+
return 2
|
|
62
|
+
|
|
63
|
+
# Erstes Argument ist der zu startende Befehl (node, npx, …), Rest sind
|
|
64
|
+
# dessen Argumente. Unter Windows liegt npx als .cmd vor; subprocess findet
|
|
65
|
+
# es nur über den vollen Pfad, deshalb erst auflösen.
|
|
66
|
+
befehl = list(sys.argv[1:])
|
|
67
|
+
aufgeloest = shutil.which(befehl[0])
|
|
68
|
+
if aufgeloest:
|
|
69
|
+
befehl[0] = aufgeloest
|
|
70
|
+
|
|
71
|
+
try:
|
|
72
|
+
prozess = subprocess.Popen(
|
|
73
|
+
befehl,
|
|
74
|
+
stdin=subprocess.PIPE,
|
|
75
|
+
stdout=subprocess.PIPE,
|
|
76
|
+
stderr=sys.stderr,
|
|
77
|
+
creationflags=CREATE_NO_WINDOW if sys.platform == "win32" else 0,
|
|
78
|
+
bufsize=0,
|
|
79
|
+
)
|
|
80
|
+
except FileNotFoundError:
|
|
81
|
+
sys.stderr.write(f"node nicht gefunden: {node}\n")
|
|
82
|
+
return 127
|
|
83
|
+
|
|
84
|
+
faeden = [
|
|
85
|
+
threading.Thread(target=pumpe, args=(sys.stdin.buffer, prozess.stdin), daemon=True),
|
|
86
|
+
threading.Thread(target=pumpe, args=(prozess.stdout, sys.stdout.buffer), daemon=True),
|
|
87
|
+
]
|
|
88
|
+
for f in faeden:
|
|
89
|
+
f.start()
|
|
90
|
+
|
|
91
|
+
try:
|
|
92
|
+
return prozess.wait()
|
|
93
|
+
except KeyboardInterrupt:
|
|
94
|
+
prozess.terminate()
|
|
95
|
+
return 0
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
if __name__ == "__main__":
|
|
99
|
+
raise SystemExit(main())
|