{"record":{"id":"a59d412ca33c0dec","repo":"moeru-ai/airi","slug":"issue-path-join-root-issue-messa","errorCode":null,"errorMessage":"${issue.path.join('.') || '<root>'}: ${issue.message}","messagePattern":"\\$\\{issue\\.path\\.join\\('\\.'\\) \\|\\| '<root>'\\}: \\$\\{issue\\.message\\}","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"apps/stage-tamagotchi/src/shared/mcp-config.ts","lineNumber":94,"sourceCode":"}\n\n/**\n * Parses a plain object into a validated MCP config file.\n *\n * Use when:\n * - JSON text has already been parsed\n * - Main and renderer need one shared validation entrypoint\n *\n * Expects:\n * - `value` is the result of `JSON.parse` or another plain object source\n *\n * Returns:\n * - A validated `ElectronMcpStdioConfigFile`\n */\nexport function parseElectronMcpConfig(value: unknown): ElectronMcpStdioConfigFile {\n  const validated = electronMcpConfigSchema.safeParse(value)\n  if (!validated.success) {\n    throw new Error(formatElectronMcpConfigIssues(validated.error.issues))\n  }\n\n  return validated.data\n}\n\n/**\n * Parses JSON text into a validated MCP config file.\n *\n * Use when:\n * - Reading `mcp.json` from disk\n * - Applying raw JSON drafts in the renderer\n *\n * Expects:\n * - `text` contains JSON text for an MCP config file\n *\n * Returns:\n * - A validated `ElectronMcpStdioConfigFile`\n */","sourceCodeStart":76,"sourceCodeEnd":112,"githubUrl":"https://github.com/moeru-ai/airi/blob/27111382b4a79a7e983289d6e983a06af185ed0f/apps/stage-tamagotchi/src/shared/mcp-config.ts#L76-L112","documentation":"Thrown by parseElectronMcpConfig when the parsed object fails the strict Zod schema electronMcpConfigSchema. The message is a semicolon-delimited list produced by formatElectronMcpConfigIssues, each entry shaped '<dotted.path | <root>>: <zod message>'. The schema requires exactly { mcpServers: Record<string, { command: non-empty string, args?, env?, cwd?, enabled? }> } and is .strict(), so unknown keys and missing/invalid command values are rejected.","triggerScenarios":"Passing an object whose mcpServers entry has an empty or missing command; including unknown top-level keys (strict mode rejects them); nesting servers under a wrong key (e.g. 'servers' instead of 'mcpServers'); providing env as a non Record<string,string>.","commonSituations":"Hand-editing mcp.json and using a different schema than the Claude/Cursor 'mcpServers' convention; a provider config draft with a typo in the key name; migrating from a looser config format that allowed extra fields; forgetting the command field for a server that only sets args.","solutions":["Read the full issue list in the thrown message — each 'path: reason' pinpoints the offending field.","Ensure the root has only 'mcpServers' and each server has a non-empty 'command' string.","Remove unknown keys (strict mode) or move them under a permitted optional field.","Validate drafts with electronMcpConfigSchema.safeParse in the settings UI before saving, surfacing issues inline instead of at load time."],"exampleFix":"// before\n{ \"mcpServers\": { \"fs\": { \"args\": [\"--stdio\"] } } }  // missing command -> 'mcpServers.fs.command: Too small'\n// after\n{ \"mcpServers\": { \"fs\": { \"command\": \"npx\", \"args\": [\"--stdio\"] } } }","handlingStrategy":"validation","validationCode":"import { electronMcpConfigSchema } from 'mcp-config'\nconst result = electronMcpConfigSchema.safeParse(value)\nif (!result.success)\n  console.error(result.error.issues)  // fix before calling parseElectronMcpConfig","typeGuard":"function isMcpConfig(value) {\n  return electronMcpConfigSchema.safeParse(value).success\n}","tryCatchPattern":"try {\n  const cfg = parseElectronMcpConfig(value)\n} catch (e) {\n  // e.message is semicolon-delimited 'path: reason' list; surface each to the settings UI\n}","preventionTips":["Use safeParse in the settings editor to show inline issues before save.","Keep mcp.json under the strict { mcpServers: { [name]: { command, args?, env?, cwd?, enabled? } } } shape.","Run a JSON+schema linter on mcp.json in CI."],"tags":["mcp","config","validation","zod","electron","shared"],"backgroundTag":null,"analyzedSha":"27111382b4a79a7e983289d6e983a06af185ed0f","analyzedAt":"2026-08-12T18:33:34.132Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}