The all-in-one local AI studio for your desktop: chat, image and video generation and a coding agent in one free, open source app. Windows and Linux. No Docker, no terminal, no cloud required.
TypeScript agentai-chatai-studioall-in-onecoding-agentdesktop-appfluximage-generationlinuxllmlocal-ailocal-llmopen-sourceprivacyself-hostedstable-diffusionuncensoreduncensored-aivideo-generationwindows
feat(mcp): ein Server, den LU nicht starten darf, sagt das mit Namen
purple91be9ffc5590
diff --git a/src/api/mcp/__tests__/nur-zwei-starter.test.ts b/src/api/mcp/__tests__/nur-zwei-starter.test.tsnew file mode 100644index 00000000..72dc5b4f--- /dev/null+++ b/src/api/mcp/__tests__/nur-zwei-starter.test.ts@@ -0,0 +1,144 @@+/**+ * Welche Programme dieses Fenster starten darf, und dass die App es sagt.+ *+ * Der Design-Strom hat die `shell:allow-spawn`-Liste des Hauptfensters von+ * zwanzig Eintraegen auf zwei geschrumpft (Audit, 2026-09). Das ist richtig:+ * node, deno, bun, python und py nehmen alle einen Einzeiler entgegen+ * (`node -e`, `python -c`), npm/pnpm/yarn fuehren aus, was eine package.json+ * im Arbeitsverzeichnis definiert, und `docker run -v /:/host` haendigt die+ * ganze Platte aus. Mit denen in der Liste war jeder Skriptfehler in der+ * WebView Codeausfuehrung auf dem Rechner des Nutzers.+ *+ * Es hat aber eine Folge, die niemand ausgesprochen hat: wer seinen+ * MCP-Server bisher mit `node meinserver.js` oder `python -m server`+ * eingetragen hatte, dessen Server startet nach dem Update nicht mehr. Ohne+ * eigenen Satz sieht er Tauris Bereichsmeldung und sucht den Fehler bei sich.+ *+ * Hier wird beides festgehalten: dass die Liste klein bleibt, und dass die+ * Kopie im Frontend der Wahrheit in der Capability folgt.+ *+ * Run: npx vitest run src/api/mcp/__tests__/nur-zwei-starter.test.ts+ */+import { describe, it, expect, vi, beforeEach } from 'vitest'+import { readFileSync } from 'node:fs'+import { resolve } from 'node:path'+import {+ MCP_STARTER, isStartableMcpCommand, notStartableMessage, MCPExternalClient,+} from '../external-client'++/** Was `Command.create` zu sehen bekam. Leer heisst: es wurde nie gerufen. */+const erzeugt: string[] = []++vi.mock('@tauri-apps/plugin-shell', () => ({+ Command: {+ create: (cmd: string) => {+ erzeugt.push(cmd)+ const leer = { on: () => {} }+ return {+ stdout: leer,+ stderr: leer,+ on: () => {},+ // Ein Start, der scheitert, damit der Fall hier endet und nicht in+ // einen Handshake laeuft, den diese Attrappe nicht spielt.+ spawn: async () => { throw new Error('spawn in the test harness') },+ }+ },+ },+}))++const CAP = JSON.parse(+ readFileSync(resolve(__dirname, '../../../../src-tauri/capabilities/default.json'), 'utf8'),+) as { permissions: unknown[] }++/** Die Befehle, die `shell:allow-spawn` im Hauptfenster wirklich erlaubt. */+function erlaubteBefehle(): string[] {+ const eintrag = CAP.permissions.find(+ (p): p is { identifier: string; allow: { cmd: string }[] } =>+ typeof p === 'object' && p !== null && (p as { identifier?: string }).identifier === 'shell:allow-spawn',+ )+ expect(eintrag, 'shell:allow-spawn fehlt in der Capability').toBeDefined()+ return eintrag!.allow.map((a) => a.cmd)+}++describe('was das Hauptfenster starten darf', () => {+ it('genau zwei Programme, plus den Windows-Shim', () => {+ // Der Shim gehoert dazu, nicht als dritter Starter: unter Windows gibt es+ // npx nur als npx.cmd, und Rusts spawn findet .exe vom blanken Namen, aber+ // nie .cmd.+ expect(erlaubteBefehle().sort()).toEqual(['npx', 'npx.cmd', 'uvx'])+ })++ it('kein allgemeiner Interpreter und keine Containerlaufzeit', () => {+ // Die Negativkontrolle zur Haertung. Waechst die Liste wieder, faellt hier+ // genau der Name auf, der zurueckgekommen ist.+ const gefaehrlich = ['node', 'deno', 'bun', 'python', 'python3', 'py', 'docker', 'npm', 'pnpm', 'yarn', 'sh', 'bash', 'cmd', 'powershell']+ for (const g of gefaehrlich) {+ expect(erlaubteBefehle(), `${g} darf nicht wieder in der Liste stehen`).not.toContain(g)+ }+ })++ it('die Kopie im Frontend nennt dieselben Programme', () => {+ // Zwei Listen fuer dieselbe Sache sind das teuerste Muster im Haus. Die+ // Capability ist die Wahrheit, MCP_STARTER die Kopie fuer die Meldung, und+ // dieser Fall ist die Klammer dazwischen.+ const ohneShim = [...new Set(erlaubteBefehle().map((c) => c.replace(/\.cmd$/, '')))].sort()+ expect([...MCP_STARTER].sort()).toEqual(ohneShim)+ })+})++describe('was ein Nutzer liest, dessen Server nicht mehr startet', () => {+ it('npx und uvx gehen, mit und ohne Windows-Shim', () => {+ expect(isStartableMcpCommand('npx')).toBe(true)+ expect(isStartableMcpCommand('uvx')).toBe(true)+ expect(isStartableMcpCommand('npx.cmd')).toBe(true)+ expect(isStartableMcpCommand('NPX')).toBe(true)+ expect(isStartableMcpCommand(' npx ')).toBe(true)+ })++ it('alles andere geht nicht, und zwar vorher und nicht im Fehlschlag', () => {+ for (const c of ['node', 'python', 'docker', 'bash', '/usr/local/bin/node']) {+ expect(isStartableMcpCommand(c), c).toBe(false)+ }+ })++ it('die Meldung nennt den eigenen Eintrag und beide Auswege', () => {+ const satz = notStartableMessage('Meine Werkzeuge', 'node server.js')+ expect(satz).toContain('Meine Werkzeuge')+ expect(satz).toContain('node server.js')+ for (const s of MCP_STARTER) expect(satz).toContain(s)+ // Und sie sagt, was man stattdessen tun kann, statt nur Nein.+ expect(satz.toLowerCase()).toContain('connect over its url')+ })++ it('sie ist Englisch', () => {+ // Hausregel: Fehlermeldungen sind Englisch, egal welches System darunter+ // liegt.+ expect(notStartableMessage('x', 'y')).not.toMatch(/[äöüß]/i)+ })+})+++describe('der Start wird vorher abgelehnt, nicht im Fehlschlag', () => {+ beforeEach(() => { erzeugt.length = 0 })++ const klient = (command: string) =>+ new MCPExternalClient({ id: 'x', name: 'Meine Werkzeuge', command, args: [], enabled: true })++ it('ein verbotener Befehl kommt gar nicht erst bis zum Start', async () => {+ // DIE VERDRAHTUNG. Ohne diesen Fall waren die Helfer oben gruen, waehrend+ // die App sie nie fragte, und der Nutzer sah weiter Tauris Bereichsmeldung.+ await expect(klient('node').connect()).rejects.toThrow(/only starts MCP servers/)+ expect(erzeugt, 'es wurde trotzdem ein Prozess gebaut').toEqual([])+ })++ it('und die Meldung nennt seinen eigenen Eintrag', async () => {+ await expect(klient('docker').connect()).rejects.toThrow(/docker/)+ })++ // POSITIVKONTROLLE: npx laeuft in den echten Startweg. Ohne sie ginge der+ // Fall oben auch auf einer Fassung durch, die JEDEN Server ablehnt.+ it('npx erreicht den Startweg', async () => {+ await expect(klient('npx').connect()).rejects.not.toThrow(/only starts MCP servers/)+ expect(erzeugt.length, 'npx kam nicht bis Command.create').toBeGreaterThan(0)+ })+})diff --git a/src/api/mcp/external-client.ts b/src/api/mcp/external-client.tsindex 9ba7e400..4d5a522b 100644--- a/src/api/mcp/external-client.ts+++ b/src/api/mcp/external-client.ts@@ -217,6 +217,12 @@ export class MCPExternalClient {// finds .exe from the bare name but never resolves .cmd, so neither a// blanket rewrite nor the bare name alone works for every install.// Try the likelier candidate first and fall back to the other.+ // Vor dem Versuch, nicht danach: ein Start, den dieses Fenster gar nicht+ // darf, scheitert mit Tauris Bereichsmeldung, und die erklaert dem+ // Nutzer nichts ueber seinen eigenen Eintrag.+ if (!isStartableMcpCommand(this.config.command)) {+ throw new Error(notStartableMessage(this.config.name, this.config.command))+ }const candidates = commandCandidatesForPlatform(this.config.command)let spawnError: unknown = nullfor (const program of candidates) {@@ -501,6 +507,51 @@ export class MCPExternalClient {* both spellings are returned with the likelier one first. Commands with* an extension or a path separator are returned as-is.*/+/**+ * Die Programme, mit denen dieses Fenster ueberhaupt einen Prozess starten+ * darf.+ *+ * Die Wahrheit steht in `src-tauri/capabilities/default.json` unter+ * `shell:allow-spawn`, und nur dort: die Liste HIER ist eine Kopie, damit die+ * App vor dem Start sagen kann, warum ein Server nicht laeuft. Dass beide+ * gleich sind, haelt ein Test fest+ * (`__tests__/nur-zwei-starter.test.ts`), sonst waere es das teuerste Muster+ * im Haus.+ *+ * Warum nur diese zwei: bis 2.6.8 standen hier zwanzig Eintraege, darunter+ * node, python, deno, bun und docker. Jedes davon nimmt einen Einzeiler+ * entgegen (`node -e`, `python -c`) oder haendigt gleich die ganze Platte aus+ * (`docker run -v /:/host`). Mit denen in der Liste war jeder Skriptfehler in+ * der WebView, auch einer in einer Abhaengigkeit, Codeausfuehrung auf dem+ * Rechner des Nutzers statt Unfug innerhalb der App.+ */+export const MCP_STARTER = ['npx', 'uvx'] as const++/**+ * Kann dieses Fenster den Server mit diesem Befehl ueberhaupt starten.+ *+ * Der `.cmd`-Anhang gehoert dazu: unter Windows gibt es npx nur als Shim.+ */+export function isStartableMcpCommand(command: string): boolean {+ const nackt = command.trim().toLowerCase().replace(/\.cmd$/, '')+ return (MCP_STARTER as readonly string[]).includes(nackt)+}++/**+ * Der Satz, den ein Nutzer liest, dessen MCP-Server nicht mehr startet.+ *+ * Er nennt den Befehl, den er eingetragen hat, und die zwei, die gehen. Ohne+ * ihn kam Tauris eigene Meldung durch, die von einem Bereich spricht, den+ * niemand konfiguriert hat, und der Nutzer sucht den Fehler bei seinem Server.+ */+export function notStartableMessage(name: string, command: string): string {+ return (+ `LU cannot start "${name}": it is set to run \`${command}\`, and LU only starts `+ + `MCP servers through ${MCP_STARTER.join(' or ')}. Point the server at one of those, `+ + `or run it yourself and connect over its URL.`+ )+}+export function commandCandidatesForPlatform(command: string,platform: string = typeof navigator !== 'undefined' ? navigator.platform : ''diff --git a/src/lib/release-notes.ts b/src/lib/release-notes.tsindex 33f21b3c..2ec8351a 100644--- a/src/lib/release-notes.ts+++ b/src/lib/release-notes.ts@@ -67,6 +67,7 @@ export const RELEASE_NOTES: ReleaseNote[] = ['Settings shows the port the LU Engine actually runs on, and the Model Storage folder says when it could not be read or was too big to scan. A ComfyUI install or repair can be cancelled from Settings, and it keeps showing its progress while you look at other settings.','On the Mac, LU stopped searching your whole home folder for a ComfyUI it never runs there. That search touched the Desktop and Music folders, so macOS asked for access to Apple Music and to the Desktop at first launch, and the window sat on LOADING while the search ran. On Windows and Linux the same search moved off the main thread, so a slow disk no longer freezes the window.','Error messages from Windows arrive in English, and a ComfyUI requirements.txt that cannot be used is named instead of silently skipped.',+ 'LU starts MCP servers through npx and uvx only. The app window used to be allowed to launch node, python, deno, bun, docker and the package managers as well. Each of those takes a one line script (node -e, python -c) or hands out the whole disk (docker run -v /:/host), so any scripting bug anywhere in the window was code execution on your machine. If a server of yours is set to run one of them, LU names it and says what it can run instead.','A ComfyUI that will not start names the cause. A missing Visual C++ runtime, or a graphics driver older than the PyTorch that was installed, used to arrive as "the Python environment looks broken" next to a Repair button, and neither of those lives in the folder Repair rebuilds. The message now says which of the two it is, and LU no longer starts a repair that cannot fix it.','Every Python step LU starts now runs with UTF-8 output. One step out of eight did before, so on a Windows account whose name falls outside the English alphabet, a single character in a path could end an install or a probe partway through.','AMD cards on Linux report their memory size without ROCm installed. LU read AMD memory only through rocm-smi, which comes with the ROCm developer packages rather than with the driver, so the card was found and its size was not. The size comes from the kernel now. An integrated AMD chip is deliberately left out, because the number it reports there is the fixed carve-out rather than what it can actually use. This reading has now been measured on a rented AMD Instinct card, where the kernel number and the number ComfyUI reports for itself are the same number.',