{"record":{"id":"eed22ce3a2a413ef","repo":"ruvnet/ruflo","slug":"mcp-failed-to-parse-mcp-servers-env","errorCode":null,"errorMessage":"[mcp] failed to parse MCP_SERVERS env","messagePattern":"\\[mcp\\] failed to parse MCP_SERVERS env","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"ruflo/src/ruvocal/src/lib/server/mcp/registry.ts","lineNumber":37,"sourceCode":"\t\t\t\tconst name = (entry as Record<string, unknown>).name;\n\t\t\t\tconst url = (entry as Record<string, unknown>).url;\n\t\t\t\tif (typeof name !== \"string\" || !name.trim()) return undefined;\n\t\t\t\tif (typeof url !== \"string\" || !url.trim()) return undefined;\n\n\t\t\t\tconst headersRaw = (entry as Record<string, unknown>).headers;\n\t\t\t\tlet headers: Record<string, string> | undefined;\n\t\t\t\tif (headersRaw && typeof headersRaw === \"object\" && !Array.isArray(headersRaw)) {\n\t\t\t\t\tconst headerEntries = Object.entries(headersRaw as Record<string, unknown>).filter(\n\t\t\t\t\t\t(entry): entry is [string, string] => typeof entry[1] === \"string\"\n\t\t\t\t\t);\n\t\t\t\t\theaders = Object.fromEntries(headerEntries);\n\t\t\t\t}\n\n\t\t\t\treturn headers ? { name, url, headers } : { name, url };\n\t\t\t})\n\t\t\t.filter((server): server is McpServerConfig => Boolean(server));\n\t} catch (error) {\n\t\tlogger.warn({ err: error }, \"[mcp] failed to parse MCP_SERVERS env\");\n\t\treturn [];\n\t}\n}\n\nfunction setServers(raw: string) {\n\tcachedServers = parseServers(raw);\n\tcachedRaw = raw;\n\tresetMcpToolsCache();\n\tlogger.debug({ count: cachedServers.length }, \"[mcp] loaded server configuration\");\n\tconsole.log(\n\t\t`[MCP] Loaded ${cachedServers.length} server(s):`,\n\t\tcachedServers.map((s) => s.name).join(\", \") || \"none\"\n\t);\n}\n\nexport function loadMcpServersOnStartup(): McpServerConfig[] {\n\tconst raw = config.MCP_SERVERS || \"[]\";\n\tsetServers(raw);","sourceCodeStart":19,"sourceCodeEnd":55,"githubUrl":"https://github.com/ruvnet/ruflo/blob/fa13ee4ad60ac2090b1480656eb233521790d640/ruflo/src/ruvocal/src/lib/server/mcp/registry.ts#L19-L55","documentation":"Log warning from parseServers: the MCP_SERVERS environment variable could not be parsed into valid server entries (invalid JSON structure, missing/blank name or url fields), so malformed entries are skipped or the whole set ignored when building the MCP server registry.","triggerScenarios":"Thrown at ruflo/src/ruvocal/src/lib/server/mcp/registry.ts:37 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Fix the MCP_SERVERS environment variable to contain valid JSON matching the expected schema.","Unset MCP_SERVERS to use the default configuration, then reintroduce entries incrementally to find the malformed one."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"fa13ee4ad60ac2090b1480656eb233521790d640","analyzedAt":"2026-08-18T21:34:22.708Z","contentChangedAt":"2026-08-18T21:34:22.708Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}