ruvnet/ruflo · error

MCP initialization failed

Error message

MCP initialization failed: ${initResponse.error.message}

What it means

Thrown by initWasmMcp() right after constructing wasm.WasmMcpServer: it sends the MCP 'initialize' handshake (protocolVersion 2024-11-05, clientInfo ruvocal-ui/1.0.0) and the server answered with a JSON-RPC error object instead of a result. The thrown message embeds the upstream error text from inside the WASM module.

Solutions

  1. Read the embedded error message — it is the module's own reason and usually names the unsupported field or version.
  2. Clear browser cache / unregister the service worker so JS glue and WASM binary come from the same build.
  3. Redeploy to guarantee the .wasm artifact and the initializing JS ship together from one build.
  4. If you control the protocol constant, align protocolVersion in initWasmMcp with the version the WASM build advertises.
Defensive patterns

Strategy: try-catch

Validate before calling

const probe = callMcpInternal(mcpServer, "ping", {});
if (probe.error) {
	throw new Error(`MCP server unhealthy: ${probe.error.message}`);
}

Type guard

function isMcpErrorResult(
	r: { error?: { message: string } } | { result: unknown }
): r is { error: { message: string } } {
	return "error" in r && r.error != null;
}

Try / catch

try {
	await initWasmMcp();
} catch (err) {
	if (String(err).startsWith("MCP initialization failed")) {
		// handshake mismatch: clear cached wasm assets and reload once
		await clearCachesAndReloadOnce();
		return;
	}
	throw err;
}

Prevention

When it happens

Trigger: The embedded MCP server rejects the initialize call — protocol-version mismatch between the WASM build and the caller, an incompatible/older wasm artifact deployed, or internal initialization failure inside the module (e.g., corrupt persisted state passed in later steps).

Common situations: Upgrading the app where the new handshake version no longer matches the served (cached) WASM module; a partially updated deploy mixing old glue JS with a new .wasm; browser cache serving mismatched artifact versions.

Related errors


AI-assisted analysis of ruvnet/ruflo@fa13ee4ad6 (2026-08-18). Data as JSON: /api/errors/88ccb184d3977dcd. Report an issue: GitHub.

Appendix: source

Thrown at ruflo/src/ruvocal/src/lib/stores/wasmMcp.ts:98

	try {
		// Load WASM module
		const wasm = await loadWasm();
		if (!wasm) {
			throw new Error("Failed to load WASM module");
		}

		// Create MCP server and gallery instances
		const mcpServer = new wasm.WasmMcpServer();
		const gallery = new wasm.WasmGallery();

		// Initialize the MCP server
		const initResponse = callMcpInternal(mcpServer, "initialize", {
			protocolVersion: "2024-11-05",
			clientInfo: { name: "ruvocal-ui", version: "1.0.0" },
		});

		if (initResponse.error) {
			throw new Error(`MCP initialization failed: ${initResponse.error.message}`);
		}

		// Load persisted filesystem state from IndexedDB
		await syncFromIndexedDB(mcpServer);

		// Check for persisted active template
		const savedTemplateId = await idb.getSetting<string>("activeTemplateId");
		let templateName: string | null = null;

		if (savedTemplateId) {
			try {
				const template = gallery.get(savedTemplateId);
				gallery.setActive(savedTemplateId);
				templateName = template.name;
			} catch {
				// Template not found, ignore
			}
		}

View on GitHub (pinned to fa13ee4ad6)