{"record":{"id":"924d223b2dda794b","repo":"JuliusBrussee/caveman","slug":"a-display-name-mcp-changes-require-the-ownershi","errorCode":null,"errorMessage":"${a.display_name} MCP changes require the ownership transaction","messagePattern":"(.+?) MCP changes require the ownership transaction","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/cli/src/index.ts","lineNumber":10678,"sourceCode":"function uninstallMcpForAgent(a: AgentProfile, serverName = \"caveman\"): boolean {\n  switch (a.id) {\n    case \"claude\": {\n      const claude = which(\"claude\");\n      if (!claude) return true; // agent itself is gone; dropping the marker is all that's left\n      try {\n        execPortableIgnore(claude, [\"mcp\", \"remove\", serverName]);\n      } catch {\n        // not registered — fine, still a successful uninstall.\n      }\n      return true;\n    }\n    case \"codex\":\n      return removeMcpCodexToml(serverName);\n    case \"opencode\":\n      return removeMcpJson(join(homedir(), \".config\", \"opencode\", \"opencode.json\"), [\"mcp\", serverName]);\n    case \"kilo\":\n    case \"qwen\":\n      throw new Error(`${a.display_name} MCP changes require the ownership transaction`);\n    case \"gemini\":\n      return removeMcpJson(join(homedir(), \".gemini\", \"settings.json\"), [\"mcpServers\", serverName]);\n    case \"hermes\":\n      return removeMcpHermesYaml(serverName);\n    case \"openclaw\":\n      return uninstallMcpOpenClaw(serverName);\n    default:\n      return false;\n  }\n}\n\n// removeMcpCodexToml drops the exact [mcp_servers.<name>] block mcpInstall wrote\n// (header + its command/args lines, up to the next section or EOF).\nfunction removeMcpCodexToml(serverName = \"caveman\"): boolean {\n  const path = join(homedir(), \".codex\", \"config.toml\");\n  let existing = \"\";\n  try {\n    existing = readFileSync(path, \"utf8\");","sourceCodeStart":10660,"sourceCodeEnd":10696,"githubUrl":"https://github.com/JuliusBrussee/caveman/blob/5184b3d11ac6a1acb7d44b9bfaa31698157cff97/packages/cli/src/index.ts#L10660-L10696","documentation":"Consistency guard in the MCP uninstall/install flow: the named agent's MCP config cannot be modified through the requested code path because the change must go through the owned-config transaction (journal + atomic replace). It fires when a code path attempts a direct mutation that would bypass ownership tracking.","triggerScenarios":"Thrown at packages/cli/src/index.ts:10678 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Route the change through transactOwnedMcpConfig so the config write and ownership journal commit atomically","If calling programmatically, use the install/uninstall API that performs the transaction instead of raw config edits","Manually restore a consistent state (remove both the registration and its ownership marker) before re-running the managed install"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"5184b3d11ac6a1acb7d44b9bfaa31698157cff97","analyzedAt":"2026-09-06T12:00:26.372Z","contentChangedAt":"2026-09-06T12:00:26.372Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}