{"record":{"id":"528246b888948013","repo":"JuliusBrussee/caveman","slug":"claude-caveman-cloud-mcp-exists-but-is-not-caveman","errorCode":null,"errorMessage":"Claude caveman-cloud MCP exists but is not Caveman-journaled; refusing overwrite","messagePattern":"Claude caveman-cloud MCP exists but is not Caveman-journaled; refusing overwrite","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/cli/src/index.ts","lineNumber":2877,"sourceCode":"  const previousSkills = new Map(existingBundle?.skills.map((skill) => [skill.file, skill]) ?? []);\n  for (const { file, body } of agentNativeSkillFiles(agent)) {\n    const current = fileBytes(file);\n    if (!existingBundle) {\n      if (current && !current.equals(Buffer.from(body))) {\n        throw new Error(`${file} already exists with non-canonical content; refusing to overwrite an unjournaled skill`);\n      }\n      continue;\n    }\n    const previous = previousSkills.get(file);\n    if (current && !current.equals(Buffer.from(body)) && (!previous || bytesHash(current) !== previous.after_sha256)) {\n      throw new Error(`${file} changed after setup; refusing to overwrite user skill edits`);\n    }\n  }\n  if (agent === \"claude\") {\n    const actual = claudeMcpRegistration(\"caveman-cloud\");\n    const marker = readMcpServerMarker(\"claude\", \"caveman-cloud\");\n    if (actual.present && !marker) {\n      throw new Error(\"Claude caveman-cloud MCP exists but is not Caveman-journaled; refusing overwrite\");\n    }\n    if (actual.present && marker && !agentNativeCloudMcpMatches(\"claude\", marker)) {\n      throw new Error(\"Claude caveman-cloud MCP changed after setup; refusing to overwrite user fields\");\n    }\n    return;\n  }\n  const config = fileBytes(join(codexHomeDir(), \"config.toml\"))?.toString(\"utf8\") ?? \"\";\n  if (!config.includes(\"[mcp_servers.caveman-cloud]\")) return;\n  if (!readMcpServerMarker(\"codex\", \"caveman-cloud\")) {\n    throw new Error(\"[mcp_servers.caveman-cloud] exists but is not Caveman-journaled; refusing overwrite\");\n  }\n}\n\nfunction installAgentNativeBundleSkills(agent: \"claude\" | \"codex\", journal: AgentNativeBundleJournal): void {\n  const originals = new Map(journal.skills.map((skill) => [skill.file, skill.before_base64]));\n  journal.skills = agentNativeSkillFiles(agent).map(({ file, body }) => {\n    mkdirSync(dirname(file), { recursive: true });\n    atomicWriteFile(file, Buffer.from(body));","sourceCodeStart":2859,"sourceCodeEnd":2895,"githubUrl":"https://github.com/JuliusBrussee/caveman/blob/3ee70a102609e550bd2e68004bf5990a9341c851/packages/cli/src/index.ts#L2859-L2895","documentation":"For Claude specifically, setup checks whether a caveman-cloud MCP registration already exists in Claude's config. If it exists but there is no Caveman journal marker proving Caveman created it, the entry may belong to the user or another tool, so the CLI refuses to overwrite it.","triggerScenarios":"Running setup for claude when claudeMcpRegistration('caveman-cloud').present is true but readMcpServerMarker('claude','caveman-cloud') returns null (marker file missing or never written).","commonSituations":"User manually added a caveman-cloud MCP entry to Claude config; the marker file was deleted by a cleanup tool; upgrading from an unjournaled install method.","solutions":["Restore or recreate the Caveman marker file for the claude caveman-cloud server","Remove the manually-added caveman-cloud MCP entry from Claude's config and let setup install it journaled","Rename your manual entry (e.g. different server name) so it does not collide"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"const reg = claudeMcpRegistration('caveman-cloud');\nconst marker = readMcpServerMarker('claude', 'caveman-cloud');\nif (reg.present && !marker) console.error('caveman-cloud entry exists without a Caveman marker; remove it or restore the marker before setup.');","typeGuard":null,"tryCatchPattern":"try {\n  runSetup('claude');\n} catch (e) {\n  if (String(e.message).includes('not Caveman-journaled')) {\n    // delete the manual entry from Claude config (or restore the marker) and re-run\n  }\n}","preventionTips":["Add MCP servers only through the Caveman CLI so markers are written","Do not delete marker/journal files during disk cleanup","If adding a manual MCP server, use a different name than caveman-cloud"],"tags":["mcp-config","marker","overwrite-protection","claude"],"backgroundTag":"file-already-exists","analyzedSha":"3ee70a102609e550bd2e68004bf5990a9341c851","analyzedAt":"2026-09-20T15:53:39.229Z","contentChangedAt":"2026-09-20T15:53:39.229Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}