{"record":{"id":"88ccb184d3977dcd","repo":"ruvnet/ruflo","slug":"mcp-initialization-failed-initresponse-error-me","errorCode":null,"errorMessage":"MCP initialization failed: ${initResponse.error.message}","messagePattern":"MCP initialization failed: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"ruflo/src/ruvocal/src/lib/stores/wasmMcp.ts","lineNumber":98,"sourceCode":"\ttry {\n\t\t// Load WASM module\n\t\tconst wasm = await loadWasm();\n\t\tif (!wasm) {\n\t\t\tthrow new Error(\"Failed to load WASM module\");\n\t\t}\n\n\t\t// Create MCP server and gallery instances\n\t\tconst mcpServer = new wasm.WasmMcpServer();\n\t\tconst gallery = new wasm.WasmGallery();\n\n\t\t// Initialize the MCP server\n\t\tconst initResponse = callMcpInternal(mcpServer, \"initialize\", {\n\t\t\tprotocolVersion: \"2024-11-05\",\n\t\t\tclientInfo: { name: \"ruvocal-ui\", version: \"1.0.0\" },\n\t\t});\n\n\t\tif (initResponse.error) {\n\t\t\tthrow new Error(`MCP initialization failed: ${initResponse.error.message}`);\n\t\t}\n\n\t\t// Load persisted filesystem state from IndexedDB\n\t\tawait syncFromIndexedDB(mcpServer);\n\n\t\t// Check for persisted active template\n\t\tconst savedTemplateId = await idb.getSetting<string>(\"activeTemplateId\");\n\t\tlet templateName: string | null = null;\n\n\t\tif (savedTemplateId) {\n\t\t\ttry {\n\t\t\t\tconst template = gallery.get(savedTemplateId);\n\t\t\t\tgallery.setActive(savedTemplateId);\n\t\t\t\ttemplateName = template.name;\n\t\t\t} catch {\n\t\t\t\t// Template not found, ignore\n\t\t\t}\n\t\t}","sourceCodeStart":80,"sourceCodeEnd":116,"githubUrl":"https://github.com/ruvnet/ruflo/blob/fa13ee4ad60ac2090b1480656eb233521790d640/ruflo/src/ruvocal/src/lib/stores/wasmMcp.ts#L80-L116","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","solutions":["Read the embedded error message — it is the module's own reason and usually names the unsupported field or version.","Clear browser cache / unregister the service worker so JS glue and WASM binary come from the same build.","Redeploy to guarantee the .wasm artifact and the initializing JS ship together from one build.","If you control the protocol constant, align protocolVersion in initWasmMcp with the version the WASM build advertises."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"const probe = callMcpInternal(mcpServer, \"ping\", {});\nif (probe.error) {\n\tthrow new Error(`MCP server unhealthy: ${probe.error.message}`);\n}","typeGuard":"function isMcpErrorResult(\n\tr: { error?: { message: string } } | { result: unknown }\n): r is { error: { message: string } } {\n\treturn \"error\" in r && r.error != null;\n}","tryCatchPattern":"try {\n\tawait initWasmMcp();\n} catch (err) {\n\tif (String(err).startsWith(\"MCP initialization failed\")) {\n\t\t// handshake mismatch: clear cached wasm assets and reload once\n\t\tawait clearCachesAndReloadOnce();\n\t\treturn;\n\t}\n\tthrow err;\n}","preventionTips":["Deploy the JS caller and WASM binary atomically from one build.","Version-bust cached WASM assets so protocol mismatches self-heal on reload.","Log the embedded initialize error message verbatim — it pinpoints the mismatched field."],"tags":["mcp","wasm","protocol","initialization"],"backgroundTag":"mcp-initialization-failed","analyzedSha":"fa13ee4ad60ac2090b1480656eb233521790d640","analyzedAt":"2026-08-18T21:34:22.708Z","contentChangedAt":"2026-08-18T21:34:22.708Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}