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
fix(mcp): uvx starts on Windows, and a missing uv says so
purple53735f908d1b
diff --git a/src-tauri/capabilities/default.json b/src-tauri/capabilities/default.jsonindex 122093e8..7cbb7c66 100644--- a/src-tauri/capabilities/default.json+++ b/src-tauri/capabilities/default.json@@ -1,7 +1,7 @@{"$schema": "../gen/schemas/desktop-schema.json","identifier": "default",- "description": "Main-window capability. shell:allow-spawn is the only permission here that can start a process, and it is scoped to the two package runners external MCP servers are actually launched with (npx, uvx). Every general-purpose interpreter and container runtime was removed: node, deno, bun, python and py all take a one-shot eval flag (node -e, python -c), npm/pnpm/yarn run whatever a package.json in the cwd defines, and docker run -v /:/host hands out the whole disk. With those in the allow-list, any script-execution bug in the WebView (a PDF viewer, a markdown renderer, a dependency) was code execution on the user's machine rather than defacement inside the app.",+ "description": "Main-window capability. shell:allow-spawn is the only permission here that can start a process, and it is scoped to the two package runners external MCP servers are actually launched with (npx, uvx). Every general-purpose interpreter and container runtime was removed: node, deno, bun, python and py all take a one-shot eval flag (node -e, python -c), npm/pnpm/yarn run whatever a package.json in the cwd defines, and docker run -v /:/host hands out the whole disk. With those in the allow-list, any script-execution bug in the WebView (a PDF viewer, a markdown renderer, a dependency) was code execution on the user's machine rather than defacement inside the app. The three uvx entries are one program, not three: uv ships uvx.exe on Windows (docs.astral.sh/uv), which the bare name finds; uvx.cmd covers a shim a version manager or wrapper put on the PATH, the same way npx.cmd covers npm's shim; and $HOME/.local/bin/uvx.exe is the official installer's fixed location, for an LU that was started before the installer added that folder to the PATH. None of them takes an eval flag or starts anything but uvx.","platforms": ["linux", "macOS", "windows"],"windows": ["main"],"permissions": [@@ -20,7 +20,9 @@"allow": [{ "name": "npx", "cmd": "npx", "args": true },{ "name": "npx.cmd", "cmd": "npx.cmd", "args": true },- { "name": "uvx", "cmd": "uvx", "args": true }+ { "name": "uvx", "cmd": "uvx", "args": true },+ { "name": "uvx.cmd", "cmd": "uvx.cmd", "args": true },+ { "name": "uvx-local-bin", "cmd": "$HOME/.local/bin/uvx.exe", "args": true }]},"shell:allow-stdin-write",diff --git a/src/api/mcp/__tests__/nur-zwei-starter.test.ts b/src/api/mcp/__tests__/nur-zwei-starter.test.tsindex 354b6d16..c2d7efa1 100644--- a/src/api/mcp/__tests__/nur-zwei-starter.test.ts+++ b/src/api/mcp/__tests__/nur-zwei-starter.test.ts@@ -65,7 +65,14 @@ describe('was das Hauptfenster starten darf', () => {// 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'])+ //+ // uvx steht dreimal da, als ein Programm: der blanke Name (uv liefert+ // unter Windows uvx.exe), ein Shim, wo jemand einen gebaut hat, und der+ // feste Ort des offiziellen Installers fuer ein LU mit altem PATH+ // (Discord 27.10.2026, siehe uvx-unter-windows.test.ts).+ expect(erlaubteBefehle().sort()).toEqual(+ ['$HOME/.local/bin/uvx.exe', 'npx', 'npx.cmd', 'uvx', 'uvx.cmd'],+ )})it('kein allgemeiner Interpreter und keine Containerlaufzeit', () => {@@ -81,7 +88,9 @@ describe('was das Hauptfenster starten darf', () => {// 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()+ const ohneShim = [...new Set(erlaubteBefehle().map(+ (c) => c.replace(/^.*[\\/]/, '').replace(/\.(cmd|exe)$/, ''),+ ))].sort()expect([...MCP_STARTER].sort()).toEqual(ohneShim)})})diff --git a/src/api/mcp/__tests__/uvx-unter-windows.test.ts b/src/api/mcp/__tests__/uvx-unter-windows.test.tsnew file mode 100644index 00000000..aebb2447--- /dev/null+++ b/src/api/mcp/__tests__/uvx-unter-windows.test.ts@@ -0,0 +1,119 @@+/**+ * MCP-Server mit uvx unter Windows (Discord help-chat, kjraidse32, 27.10.2026:+ * "program not allowed on the configured shell scope: uvx.cmd").+ *+ * Zwei Fehler steckten darin. Der Startweg probierte nach `uvx` den Namen+ * `uvx.cmd`, den `shell:allow-spawn` nicht kannte. Und weil nur der LETZTE+ * Fehlversuch geworfen wurde, sah der Nutzer diese Bereichsablehnung statt des+ * echten Grundes: uvx wurde unter dem PATH, mit dem LU lief, nicht gefunden.+ *+ * uv liefert unter Windows `uvx.exe` (docs.astral.sh/uv, Installation:+ * `rm $HOME\.local\bin\uvx.exe`), nie ein `.cmd`. Der blanke Name genuegt also,+ * sobald der Ordner im PATH steht; der Shim und der feste Installer-Ort sind+ * Rueckfaelle fuer denselben uvx.+ *+ * Run: npx vitest run src/api/mcp/__tests__/uvx-unter-windows.test.ts+ */+import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest'+import { readFileSync } from 'node:fs'+import { resolve } from 'node:path'++/** Die Scope-Namen, die die Capability kennt, mit ihrem Programm. */+const CAP = JSON.parse(+ readFileSync(resolve(__dirname, '../../../../src-tauri/capabilities/default.json'), 'utf8'),+) as { permissions: unknown[] }+const SCOPE: { name: string; cmd: string }[] = (CAP.permissions.find(+ (p) => typeof p === 'object' && p !== null && (p as { identifier?: string }).identifier === 'shell:allow-spawn',+) as { allow: { name: string; cmd: string }[] }).allow++/** Welche Scope-Namen auf diesem gespielten Rechner wirklich ein Programm finden. */+let vorhanden = new Set<string>()+const versucht: string[] = []++vi.mock('@tauri-apps/plugin-shell', () => ({+ Command: {+ // So verhaelt sich tauri-plugin-shell 2.3: ein Name ausserhalb des Scopes+ // wird abgelehnt, ein erlaubter, dessen Programm fehlt, scheitert in Rusts+ // spawn mit "program not found".+ create: (name: string) => {+ const leer = { on: () => {} }+ return {+ stdout: leer,+ stderr: leer,+ on: () => {},+ spawn: async () => {+ versucht.push(name)+ if (!SCOPE.some((e) => e.name === name)) {+ throw `program not allowed on the configured shell scope: ${name}`+ }+ if (!vorhanden.has(name)) throw 'program not found'+ // Gestartet. Der Handshake danach ist nicht Gegenstand dieses Tests:+ // write scheitert, und der Fall endet mit einem anderen Fehler.+ return { pid: 1, write: async () => { throw new Error('handshake not played here') }, kill: async () => {} }+ },+ }+ },+ },+}))++import { MCPExternalClient, commandCandidatesForPlatform, spawnFailureMessage } from '../external-client'++const klient = () =>+ new MCPExternalClient({ id: 'time', name: 'time', command: 'uvx', args: ['mcp-server-time==2026.8.18'], enabled: true })++beforeEach(() => {+ versucht.length = 0+ vorhanden = new Set()+ vi.stubGlobal('navigator', { platform: 'Win32' })+})+afterEach(() => { vi.unstubAllGlobals() })++describe('jeder Name, den der Startweg probiert, steht im Scope', () => {+ it.each(['uvx', 'npx'])('%s unter Windows', (cmd) => {+ for (const name of commandCandidatesForPlatform(cmd, 'Win32')) {+ expect(SCOPE.map((e) => e.name), `${name} fehlt in shell:allow-spawn`).toContain(name)+ }+ })++ it('und jeder uvx-Eintrag startet uvx, nichts anderes', () => {+ // Die Erlaubnisliste wird breiter, nicht weicher: drei Eintraege, ein+ // Programm. Ein vierter mit anderem Programmnamen faellt hier auf.+ for (const e of SCOPE.filter((x) => x.name.startsWith('uvx'))) {+ expect(e.cmd.replace(/^.*[\\/]/, '').replace(/\.(cmd|exe)$/, ''), e.name).toBe('uvx')+ }+ expect(SCOPE.find((e) => e.name === 'uvx-local-bin')?.cmd).toBe('$HOME/.local/bin/uvx.exe')+ })+})++describe('was der Nutzer liest', () => {+ it('fehlt uv ganz, steht da, wie man es bekommt, und keine Bereichsmeldung', async () => {+ const err = await klient().connect().catch((e: Error) => e)+ expect(versucht).toEqual(['uvx', 'uvx.cmd', 'uvx-local-bin'])+ expect(String(err)).not.toMatch(/shell scope/)+ expect(String(err)).toMatch(/`uvx` was not found/)+ expect(String(err)).toContain('docs.astral.sh/uv')+ })++ it('der offizielle Installer-Ort wird gefunden, wenn der PATH alt ist', async () => {+ vorhanden = new Set(['uvx-local-bin'])+ const err = await klient().connect().catch((e: Error) => e)+ expect(versucht.at(-1)).toBe('uvx-local-bin')+ expect(String(err)).toMatch(/handshake not played here/)+ })++ it('ein uvx.cmd-Shim startet auch', async () => {+ vorhanden = new Set(['uvx.cmd'])+ const err = await klient().connect().catch((e: Error) => e)+ expect(versucht).toEqual(['uvx', 'uvx.cmd'])+ expect(String(err)).toMatch(/handshake not played here/)+ })++ it('ein anderer echter Fehler wird nicht zur Installationsanleitung', () => {+ const satz = spawnFailureMessage('uvx', ['Access is denied. (os error 5)', 'program not found'])+ expect(satz).toBe('Access is denied. (os error 5)')+ })++ it('auf dem Mac bleibt es beim blanken Namen', () => {+ expect(commandCandidatesForPlatform('uvx', 'MacIntel')).toEqual(['uvx'])+ })+})diff --git a/src/api/mcp/external-client.ts b/src/api/mcp/external-client.tsindex 8148edf4..1ecdc04b 100644--- a/src/api/mcp/external-client.ts+++ b/src/api/mcp/external-client.ts@@ -231,7 +231,12 @@ export class MCPExternalClient {throw new Error(notStartableMessage(this.config.name, this.config.command))}const candidates = commandCandidatesForPlatform(this.config.command)- let spawnError: unknown = null+ // Every failed attempt is kept, not just the last one. The last one used+ // to be the only one thrown, and on Windows that was the `.cmd`+ // fallback: a uvx that was simply not installed (or not yet on the PATH+ // LU was started with) reached the user as Tauri's scope refusal for+ // `uvx.cmd` (Discord, 27.10.2026), which says nothing about uv.+ const spawnErrors: unknown[] = []for (const program of candidates) {const command = Command.create(program, this.config.args, {env: this.config.env,@@ -266,13 +271,12 @@ export class MCPExternalClient {try {this.child = await command.spawn()- spawnError = nullbreak} catch (err) {- spawnError = err+ spawnErrors.push(err)}}- if (!this.child) throw spawnError+ if (!this.child) throw new Error(spawnFailureMessage(this.config.command, spawnErrors))this.connected = true// Enrolled the moment a process exists, not once the handshake is// through: a server that spawns and then hangs in `initialize` is@@ -588,6 +592,18 @@ export function notStartableMessage(name: string, command: string): string {)}+/**+ * Scope-Name des Eintrags, der uvx an seinem offiziellen Windows-Ort startet.+ *+ * Astrals Installer legt `uvx.exe` nach `%USERPROFILE%\.local\bin` und traegt+ * den Ordner in den Benutzer-PATH ein (docs.astral.sh/uv, Installation und+ * Deinstallation, Stand 26.10.2026). Ein LU, das vor der Installation lief,+ * erbt den alten PATH und findet den blanken Namen trotzdem nicht. Der Eintrag+ * in `capabilities/default.json` ist derselbe uvx an einem festen Ort, kein+ * weiteres Programm.+ */+export const UVX_LOCAL_BIN_SCOPE = 'uvx-local-bin'+export function commandCandidatesForPlatform(command: string,platform: string = typeof navigator !== 'undefined' ? navigator.platform : ''@@ -597,5 +613,39 @@ export function commandCandidatesForPlatform(if (/[\\/]|\.(cmd|bat|exe)$/i.test(command)) return [command]const CMD_SHIM_FIRST = new Set(['npx', 'npm', 'pnpm', 'yarn', 'corepack'])if (CMD_SHIM_FIRST.has(command)) return [`${command}.cmd`, command]+ // uv liefert unter Windows `uvx.exe`, nie ein `.cmd`. Den Shim gibt es nur,+ // wo jemand einen gebaut hat (ein Versionsmanager, ein eigener Wrapper),+ // deshalb kommt er nach dem echten Programm und vor dem festen Ort.+ if (command.toLowerCase() === 'uvx') return ['uvx', 'uvx.cmd', UVX_LOCAL_BIN_SCOPE]return [command, `${command}.cmd`]}++/** Tauris Ablehnung eines Programms, das nicht in `shell:allow-spawn` steht. */+const SCOPE_REFUSAL = /not allowed on the configured shell scope/i+/** Was Rust sagt, wenn es das Programm nicht findet: Windows bzw. macOS/Linux. */+const NOT_FOUND = /program not found|cannot find the file|no such file or directory|os error 2\b/i++/**+ * Der Satz, wenn kein Startversuch einen Prozess ergeben hat.+ *+ * Eine Bereichsablehnung ist hier nie die Ursache: was gar nicht starten darf,+ * hat `isStartableMcpCommand` vorher abgefangen, und eine Ablehnung kann nur+ * noch einen Rueckfall-Namen treffen. Gezeigt wird darum der erste echte+ * Fehler, und wenn das Programm schlicht fehlt, wie man es bekommt.+ */+export function spawnFailureMessage(command: string, errors: unknown[]): string {+ const texte = errors.map((e) => (e instanceof Error ? e.message : String(e)))+ const echt = texte.filter((t) => !SCOPE_REFUSAL.test(t))+ if (echt.length === 0) return texte[0] ?? `could not start \`${command}\``+ if (!echt.every((t) => NOT_FOUND.test(t))) return echt[0]+ const nackt = command.trim().toLowerCase().replace(/\.(cmd|exe)$/, '')+ if (nackt === 'uvx') {+ return '`uvx` was not found. Install uv from https://docs.astral.sh/uv/getting-started/installation/ '+ + '(on Windows: winget install --id=astral-sh.uv -e), then quit and reopen LU so it sees the new PATH.'+ }+ if (nackt === 'npx') {+ return '`npx` was not found. Install Node.js from https://nodejs.org, '+ + 'then quit and reopen LU so it sees the new PATH.'+ }+ return echt[0]+}