Skip to content

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.

fix(mcp): a first uvx/npx start waits while it downloads, and says so

purpleb8c9e249e4a1
diff --git a/docs/guide/agent/index.html b/docs/guide/agent/index.html
index 20262f2c..cb80f66f 100644
--- a/docs/guide/agent/index.html
+++ b/docs/guide/agent/index.html
@@ -15,7 +15,7 @@
<meta property="og:image" content="https://locallyuncensored.com/social-preview.png">
<meta name="twitter:card" content="summary_large_image">
<script type="application/ld+json">
-{"@context":"https://schema.org","@type":"TechArticle","headline":"Agent Mode in Locally Uncensored: Tools, Workspace Folder, Approvals, Stop","description":"How agent mode works in Locally Uncensored: the tools, the workspace folder and the sandbox, permissions and approvals, Stop, background agents and loops.","url":"https://locallyuncensored.com/guide/agent/","dateModified":"2026-10-28","inLanguage":"en","author":{"@type":"Person","name":"PurpleDoubleD","url":"https://github.com/PurpleDoubleD"},"publisher":{"@type":"Organization","name":"Locally Uncensored","url":"https://locallyuncensored.com/"},"mainEntityOfPage":{"@type":"WebPage","@id":"https://locallyuncensored.com/guide/agent/"},"isPartOf":{"@type":"WebPage","name":"Locally Uncensored Handbook: Install, Chat, Agent, Code, Create, Cloud","url":"https://locallyuncensored.com/guide/"},"about":{"@type":"SoftwareApplication","name":"Locally Uncensored","operatingSystem":"Windows, Linux, macOS","applicationCategory":"UtilitiesApplication"}}
+{"@context":"https://schema.org","@type":"TechArticle","headline":"Agent Mode in Locally Uncensored: Tools, Workspace Folder, Approvals, Stop","description":"How agent mode works in Locally Uncensored: the tools, the workspace folder and the sandbox, permissions and approvals, Stop, background agents and loops.","url":"https://locallyuncensored.com/guide/agent/","dateModified":"2026-10-31","inLanguage":"en","author":{"@type":"Person","name":"PurpleDoubleD","url":"https://github.com/PurpleDoubleD"},"publisher":{"@type":"Organization","name":"Locally Uncensored","url":"https://locallyuncensored.com/"},"mainEntityOfPage":{"@type":"WebPage","@id":"https://locallyuncensored.com/guide/agent/"},"isPartOf":{"@type":"WebPage","name":"Locally Uncensored Handbook: Install, Chat, Agent, Code, Create, Cloud","url":"https://locallyuncensored.com/guide/"},"about":{"@type":"SoftwareApplication","name":"Locally Uncensored","operatingSystem":"Windows, Linux, macOS","applicationCategory":"UtilitiesApplication"}}
</script>
<link rel="icon" href="/favicon.png">
<script type="application/ld+json">
@@ -147,7 +147,7 @@
<p>MCP is a standard that lets you plug an outside tool server into the agent. Settings, Agent, MCP Servers adds one with a name and a command; the field is labelled "Command (only npx or uvx)", because the app starts servers only through those two launchers. The server's tools then appear next to the built in ones.</p>
-<p>A server started with uvx needs uv, Astral's Python tool runner. Install it from the official instructions at <a href="https://docs.astral.sh/uv/getting-started/installation/">docs.astral.sh/uv</a>; on Windows the quickest is <code>winget install --id=astral-sh.uv -e</code>, on a Mac <code>brew install uv</code>. uv puts <code>uvx</code> into <code>~/.local/bin</code> (Windows: <code>%USERPROFILE%\.local\bin\uvx.exe</code>). Quit and reopen LU afterwards so it sees the new PATH; on Windows LU also finds uvx in that folder without it. To try it, add a server with the command <code>uvx</code> and the argument <code>mcp-server-time==2026.8.18</code>: it answers with two tools, get_current_time and convert_time. If uv is missing, the server row says "`uvx` was not found" and links the installation page.</p>
+<p>A server started with uvx needs uv, Astral's Python tool runner. Install it from the official instructions at <a href="https://docs.astral.sh/uv/getting-started/installation/">docs.astral.sh/uv</a>; on Windows the quickest is <code>winget install --id=astral-sh.uv -e</code>, on a Mac <code>brew install uv</code>. uv puts <code>uvx</code> into <code>~/.local/bin</code> (Windows: <code>%USERPROFILE%\.local\bin\uvx.exe</code>). Quit and reopen LU afterwards so it sees the new PATH; on Windows LU also finds uvx in that folder without it. To try it, add a server with the command <code>uvx</code> and the argument <code>mcp-server-time==2026.8.18</code>: it answers with two tools, get_current_time and convert_time. If uv is missing, the server row says "`uvx` was not found" and links the installation page. The first Connect of a server can take a few minutes, because uvx or npx downloads it and its dependencies first; the row then says "Installing server dependencies", and LU keeps waiting as long as the download makes progress (up to ten minutes). Later starts come from the cache and are quick.</p>
<p>Agent Workflows, under the same settings tab, are saved sequences the agent can run with run_workflow.</p>
diff --git a/src/api/mcp/__tests__/external-client.test.ts b/src/api/mcp/__tests__/external-client.test.ts
index 02e001c7..915920b7 100644
--- a/src/api/mcp/__tests__/external-client.test.ts
+++ b/src/api/mcp/__tests__/external-client.test.ts
@@ -10,7 +10,7 @@
* makes that a hard failure again: touching `stdin` throws.
*/
import { describe, it, expect, vi, beforeEach } from 'vitest'
-import { MCPExternalClient } from '../external-client'
+import { MCPExternalClient, HANDSHAKE_CAP_MS, HANDSHAKE_QUIET_MS, INSTALLING_NOTE, handshakeWaitLeft } from '../external-client'
import type { MCPServerConfig } from '../types'
class Emitter {
@@ -147,7 +147,14 @@ describe('connecting to an external server', () => {
// d307-k (19.10.2026): an npx server answers `initialize` only once its
// packages are installed. REA's first start on the Windows box took about
// two minutes and ended at the general 30 s every time.
- async function slowHandshake(initializeTimeoutMs: number | undefined, answerAfterMs: number) {
+ // `printEveryMs`: the server writes a progress line to stderr that often
+ // while it is not answering, as uvx and npm do while they download.
+ async function slowHandshake(
+ initializeTimeoutMs: number | undefined,
+ answerAfterMs: number,
+ printEveryMs = 0,
+ notes: (string | null)[] = [],
+ ) {
vi.useFakeTimers()
try {
let held: FakeRequest | null = null
@@ -155,11 +162,18 @@ describe('connecting to an external server', () => {
if (req.method === 'initialize') { held = req; return null }
return goodServer(req)
}
- const client = new MCPExternalClient({ ...config, initializeTimeoutMs })
+ const client = new MCPExternalClient({ ...config, initializeTimeoutMs }, { onProgress: (n) => notes.push(n) })
const done = client.connect().then(() => 'connected', (e: unknown) => String(e))
for (let i = 0; i < 100 && !held; i++) await vi.advanceTimersByTimeAsync(1)
expect(held).not.toBeNull()
- await vi.advanceTimersByTimeAsync(answerAfterMs)
+ if (printEveryMs > 0) {
+ for (let t = 0; t < answerAfterMs; t += printEveryMs) {
+ lastServer!.stderr.emit('data', 'Downloading cryptography (3.2MiB)\n')
+ await vi.advanceTimersByTimeAsync(Math.min(printEveryMs, answerAfterMs - t))
+ }
+ } else {
+ await vi.advanceTimersByTimeAsync(answerAfterMs)
+ }
lastServer!.stdout.emit('data', JSON.stringify({ jsonrpc: '2.0', id: held!.id, result: { protocolVersion: '2024-11-05' } }) + '\n')
await vi.advanceTimersByTimeAsync(1)
return await done
@@ -172,8 +186,36 @@ describe('connecting to an external server', () => {
expect(await slowHandshake(10 * 60_000, 120_000)).toBe('connected')
})
- it('without a handshake time of its own a server still gets the general 30 s', async () => {
- expect(await slowHandshake(undefined, 31_000)).toMatch(/Request initialize timed out/)
+ // Box test 31.10.2026: uvx's first start downloads cryptography, pywin32
+ // and pydantic-core; at 30 s LU stopped it mid-download three times in a row.
+ it('without a handshake time of its own a quiet server gets two minutes, not 30 s', async () => {
+ expect(HANDSHAKE_QUIET_MS).toBe(120_000)
+ expect(await slowHandshake(undefined, 90_000)).toBe('connected')
+ })
+
+ it('a server that stays quiet past the two minutes times out and says why', async () => {
+ expect(await slowHandshake(undefined, 121_000)).toMatch(/Request initialize timed out \(no answer and no progress for 2 min\)/)
+ })
+
+ it('a server still printing download progress gets more time with every line', async () => {
+ const notes: (string | null)[] = []
+ expect(await slowHandshake(undefined, 6 * 60_000, 60_000, notes)).toBe('connected')
+ // The panel was told what is going on, and told again once it was over.
+ expect(notes[0]).toBe(INSTALLING_NOTE)
+ expect(notes.at(-1)).toBeNull()
+ })
+
+ it('even a server that keeps printing is given up at the ten-minute cap', async () => {
+ expect(HANDSHAKE_CAP_MS).toBe(10 * 60_000)
+ expect(await slowHandshake(undefined, 11 * 60_000, 60_000)).toMatch(/Request initialize timed out/)
+ })
+
+ it('the wait left is the quiet window since the last line, never past the cap', () => {
+ expect(handshakeWaitLeft(0, 0, 0, 120_000, 600_000)).toBe(120_000)
+ expect(handshakeWaitLeft(150_000, 0, 100_000, 120_000, 600_000)).toBe(70_000)
+ expect(handshakeWaitLeft(121_000, 0, 0, 120_000, 600_000)).toBeNull()
+ expect(handshakeWaitLeft(590_000, 0, 580_000, 120_000, 600_000)).toBe(10_000)
+ expect(handshakeWaitLeft(600_000, 0, 599_000, 120_000, 600_000)).toBeNull()
})
it('completes the handshake and returns the discovered tools', async () => {
diff --git a/src/api/mcp/external-client.ts b/src/api/mcp/external-client.ts
index 192cf570..17fe7e87 100644
--- a/src/api/mcp/external-client.ts
+++ b/src/api/mcp/external-client.ts
@@ -110,6 +110,36 @@ function isToolInputSchema(v: unknown): v is MCPToolDefinition['inputSchema'] {
* otherwise (the handshake can, see MCPServerConfig.initializeTimeoutMs). */
export const REQUEST_TIMEOUT_MS = 30_000
+/**
+ * The handshake of an external server waits as long as the server is still
+ * busy. Every server LU starts is a uvx or npx package, and its first start
+ * downloads that package and its dependencies before it answers `initialize`.
+ * On a slow line that took longer than the old fixed wait; LU then stopped
+ * uvx in the middle of the download and the next Connect started it over
+ * (box test, 31.10.2026: three failures in a row, instant once the cache was
+ * warm). uv and npm report each download on stderr, so every stderr line buys
+ * the handshake another HANDSHAKE_QUIET_MS, up to HANDSHAKE_CAP_MS in all.
+ */
+export const HANDSHAKE_QUIET_MS = 120_000
+export const HANDSHAKE_CAP_MS = 10 * 60_000
+
+/** What the panel shows while a connecting server prints to stderr, i.e.
+ * while uvx or npx is still fetching the server. */
+export const INSTALLING_NOTE = 'Installing server dependencies … the first start can take a few minutes.'
+
+/**
+ * How much longer the handshake waits, or null when it gives up: the server
+ * has been quiet for `quietMs`, or the whole handshake reached `capMs`.
+ */
+export function handshakeWaitLeft(
+ now: number, startedAt: number, lastOutputAt: number, quietMs: number, capMs: number,
+): number | null {
+ const capLeft = startedAt + capMs - now
+ const quietLeft = Math.max(startedAt, lastOutputAt) + quietMs - now
+ if (capLeft <= 0 || quietLeft <= 0) return null
+ return Math.min(capLeft, quietLeft)
+}
+
const EMPTY_INPUT_SCHEMA: MCPToolDefinition['inputSchema'] = {
type: 'object',
properties: {},
@@ -203,11 +233,21 @@ export class MCPExternalClient {
*/
private onExit?: (serverId: string) => void
+ /** Told INSTALLING_NOTE once the connecting server prints to stderr, and
+ * null when the connect is over, whichever way. */
+ private onProgress?: (note: string | null) => void
+ /** When the server last printed to stderr; the handshake waits on it. */
+ private lastOutputAt = 0
+
private readonly config: MCPServerConfig
- constructor(config: MCPServerConfig, opts?: { onExit?: (serverId: string) => void }) {
+ constructor(config: MCPServerConfig, opts?: {
+ onExit?: (serverId: string) => void
+ onProgress?: (note: string | null) => void
+ }) {
this.config = config
this.onExit = opts?.onExit
+ this.onProgress = opts?.onProgress
}
async connect(): Promise<MCPToolDefinition[]> {
@@ -252,6 +292,8 @@ export class MCPExternalClient {
command.stderr.on('data', (data: string) => {
log.warn(`[MCP:${this.config.name}] stderr`, { data })
+ this.lastOutputAt = Date.now()
+ if (!this.registered) this.onProgress?.(INSTALLING_NOTE)
})
command.on('close', () => {
@@ -285,14 +327,18 @@ export class MCPExternalClient {
// removes it again if the handshake fails outright.
liveClients.add(this)
- // Initialize the MCP connection. The server's own config may give the
- // handshake longer: an npx server installs its packages before it
- // answers (d307-k, 19.10.2026: REA's first start on a slow line).
+ // Initialize the MCP connection. It waits while the server still
+ // prints (HANDSHAKE_QUIET_MS); the server's own config may give it
+ // longer still (d307-k, 19.10.2026: REA's first start on a slow line).
+ const quietMs = Math.max(this.config.initializeTimeoutMs ?? 0, HANDSHAKE_QUIET_MS)
+ const capMs = Math.max(quietMs, HANDSHAKE_CAP_MS)
+ const startedAt = Date.now()
await this.sendRequest('initialize', {
protocolVersion: '2024-11-05',
capabilities: {},
clientInfo: { name: 'locally-uncensored', version: APP_VERSION },
- }, this.config.initializeTimeoutMs)
+ }, quietMs, () => handshakeWaitLeft(Date.now(), startedAt, this.lastOutputAt, quietMs, capMs),
+ `no answer and no progress for ${Math.round(quietMs / 60_000)} min`)
// Discover tools
const toolsResult = await this.sendRequest('tools/list', {})
@@ -318,8 +364,10 @@ export class MCPExternalClient {
}
this.registered = true
+ this.onProgress?.(null)
return tools
} catch (err) {
+ this.onProgress?.(null)
this.connected = false
// A failure after spawn (handshake refused, tools/list timed out) leaves
// the server process running with nobody holding a handle to it — the
@@ -444,7 +492,17 @@ export class MCPExternalClient {
// ── Private ─────────────────────────────────────────────────
- private sendRequest(method: string, params?: unknown, timeoutMs: number = REQUEST_TIMEOUT_MS): Promise<unknown> {
+ /**
+ * `waitMore`, when given, is asked each time the wait runs out: a number is
+ * how much longer to wait, null ends the request with a timeout.
+ */
+ private sendRequest(
+ method: string,
+ params?: unknown,
+ timeoutMs: number = REQUEST_TIMEOUT_MS,
+ waitMore?: () => number | null,
+ timeoutWhy?: string,
+ ): Promise<unknown> {
return new Promise((resolve, reject) => {
if (!this.child) {
reject(new Error('Not connected'))
@@ -458,11 +516,18 @@ export class MCPExternalClient {
params,
}
- const timer = setTimeout(() => {
- if (this.pendingRequests.delete(id)) {
- reject(new Error(`Request ${method} timed out`))
+ const expire = () => {
+ const entry = this.pendingRequests.get(id)
+ if (!entry) return
+ const more = waitMore?.() ?? null
+ if (more !== null) {
+ entry.timer = setTimeout(expire, more)
+ return
}
- }, timeoutMs > 0 ? timeoutMs : REQUEST_TIMEOUT_MS)
+ this.pendingRequests.delete(id)
+ reject(new Error(`Request ${method} timed out${timeoutWhy ? ` (${timeoutWhy})` : ''}`))
+ }
+ const timer = setTimeout(expire, timeoutMs > 0 ? timeoutMs : REQUEST_TIMEOUT_MS)
this.pendingRequests.set(id, { resolve, reject, timer })
@@ -470,8 +535,9 @@ export class MCPExternalClient {
// of becoming an unhandled rejection and letting it sit for 30 s.
const msg = JSON.stringify(request) + '\n'
Promise.resolve(this.child.write(msg)).catch((err: unknown) => {
- if (this.pendingRequests.delete(id)) {
- clearTimeout(timer)
+ const entry = this.pendingRequests.get(id)
+ if (entry && this.pendingRequests.delete(id)) {
+ clearTimeout(entry.timer)
reject(err instanceof Error ? err : new Error(String(err)))
}
})
diff --git a/src/components/settings/MCPServerSettings.tsx b/src/components/settings/MCPServerSettings.tsx
index 6abef27e..731f5a97 100644
--- a/src/components/settings/MCPServerSettings.tsx
+++ b/src/components/settings/MCPServerSettings.tsx
@@ -5,6 +5,7 @@ import { useMCPStore } from '../../stores/mcpStore'
import { toolRegistry } from '../../api/mcp'
import type { MCPServerConfig } from '../../api/mcp/types'
import { joinArgs, parseArgs } from '../../lib/mcp-args'
+import { HINWEIS_TEXT } from '../../lib/hinweis'
// `import type` und nicht `import`: die Klasse wird unten bewusst dynamisch
// geladen, damit der Tauri-Import im Dev-Modus nicht mitkommt. Ein Typ-Import
// wird beim Uebersetzen geloescht und erzeugt keine Laufzeit-Abhaengigkeit —
@@ -38,6 +39,15 @@ export function MCPServerSettings() {
const [connecting, setConnecting] = useState<string[]>(() => [...inFlight.keys()])
const markConnecting = (id: string, on: boolean) =>
setConnecting((ids) => (on ? [...ids.filter((x) => x !== id), id] : ids.filter((x) => x !== id)))
+ // What a connecting server is busy with (uvx/npx fetching it), per server.
+ const [progress, setProgress] = useState<Record<string, string>>({})
+ const markProgress = (id: string, note: string | null) =>
+ setProgress((all) => {
+ const next = { ...all }
+ if (note) next[id] = note
+ else delete next[id]
+ return next
+ })
const [error, setError] = useState<string | null>(null)
// Add form state. `editingId` entscheidet, ob Speichern anlegt oder aendert.
@@ -117,6 +127,7 @@ export function MCPServerSettings() {
clearServerTools(id)
clients.delete(id)
},
+ onProgress: (note) => markProgress(server.id, note),
})
attempt.client = client
let tools: Awaited<ReturnType<MCPExternalClient['connect']>>
@@ -151,6 +162,7 @@ export function MCPServerSettings() {
} finally {
if (inFlight.get(server.id) === attempt) inFlight.delete(server.id)
markConnecting(server.id, false)
+ markProgress(server.id, null)
}
}
@@ -259,6 +271,12 @@ export function MCPServerSettings() {
</button>
</div>
+ {isLoading && progress[server.id] && (
+ <p data-testid="mcp-installing-note" className={`mt-1 t-micro leading-snug ${HINWEIS_TEXT.ruhig}`}>
+ {progress[server.id]}
+ </p>
+ )}
+
{/* Expanded tool list */}
{isConnected && tools.length > 0 && (
<div className="mt-1.5 pt-1.5 border-t border-white/5 space-y-0.5">
diff --git a/src/components/settings/__tests__/mcp-says-it-is-installing.test.tsx b/src/components/settings/__tests__/mcp-says-it-is-installing.test.tsx
new file mode 100644
index 00000000..53be976b
--- /dev/null
+++ b/src/components/settings/__tests__/mcp-says-it-is-installing.test.tsx
@@ -0,0 +1,80 @@
+/**
+ * @vitest-environment jsdom
+ *
+ * Settings, Agent, MCP Servers (box test 31.10.2026, Befund 10): the first
+ * Connect of a uvx server downloads its dependencies first. The row showed
+ * only a spinner until "Request initialize timed out". While the server is
+ * still fetching, the row now says so, and the line goes once the connect
+ * is over.
+ *
+ * Run: npx vitest run src/components/settings/__tests__/mcp-says-it-is-installing.test.tsx
+ */
+import { describe, it, expect, beforeEach, afterEach, vi } from 'vitest'
+import { createElement } from 'react'
+import { render, screen, cleanup, fireEvent, act } from '@testing-library/react'
+import type { MCPServerConfig, MCPToolDefinition } from '../../../api/mcp/types'
+
+const NOTE = 'Installing server dependencies … the first start can take a few minutes.'
+let progress: ((note: string | null) => void) | undefined
+let finish: () => void = () => {}
+
+vi.mock('../../../api/mcp/external-client', () => ({
+ MCPExternalClient: class {
+ private config: MCPServerConfig
+ private onProgress?: (note: string | null) => void
+ constructor(config: MCPServerConfig, opts?: { onProgress?: (note: string | null) => void }) {
+ this.config = config
+ this.onProgress = opts?.onProgress
+ progress = opts?.onProgress
+ }
+ connect(): Promise<MCPToolDefinition[]> {
+ return new Promise((resolve) => {
+ finish = () => {
+ this.onProgress?.(null)
+ resolve([{
+ name: 'get_current_time', description: 'time', inputSchema: { type: 'object', properties: {} },
+ category: 'mcp', source: 'external', serverId: this.config.id,
+ } as MCPToolDefinition])
+ }
+ })
+ }
+ async disconnect() {}
+ async callTool() { return '' }
+ },
+}))
+
+const { MCPServerSettings } = await import('../MCPServerSettings')
+const { useMCPStore } = await import('../../../stores/mcpStore')
+const { toolRegistry } = await import('../../../api/mcp')
+
+const flush = () => act(async () => { for (let i = 0; i < 10; i++) await Promise.resolve() })
+
+beforeEach(() => {
+ progress = undefined
+ useMCPStore.setState({
+ servers: [{ id: 's21', name: 'time', command: 'uvx', args: ['mcp-server-time==2026.8.18'], enabled: true }],
+ connectedServers: [],
+ serverTools: {},
+ })
+})
+afterEach(() => {
+ cleanup()
+ toolRegistry.unregisterServer('s21')
+})
+
+describe('a uvx server that is still installing', () => {
+ it('says so on its row while it connects, and not after', async () => {
+ render(createElement(MCPServerSettings))
+ fireEvent.click(screen.getByTitle('Connect'))
+ await flush()
+ expect(screen.queryByTestId('mcp-installing-note')).toBeNull()
+
+ act(() => progress?.(NOTE))
+ expect(screen.getByTestId('mcp-installing-note').textContent).toBe(NOTE)
+
+ finish()
+ await flush()
+ expect(screen.queryByTestId('mcp-installing-note')).toBeNull()
+ expect(screen.getByText('1 tools')).toBeTruthy()
+ })
+})