JuliusBrussee/caveman · error
OpenCode caveman MCP entry changed after enable; refusing…
Error message
OpenCode caveman MCP entry changed after enable; refusing destructive disable
What it means
The disable path checks that the mcp.caveman entry in the OpenCode config is byte-identical (JSON.stringify comparison) to what was installed during enable. If it differs, the tool throws rather than deleting an entry the user may have customized. This prevents destroying user modifications to the MCP registration.
Solutions
- Revert the mcp.caveman entry to match the originally installed value (operation.owned.installed_mcp), then re-run disable.
- Manually delete the mcp.caveman key from the OpenCode config file.
- Re-run enable to refresh the journal snapshot, then disable.
Example fix
// before: hand-edited entry
"mcp": { "caveman": { "command": "npx", "args": ["caveman", "mcp", "--verbose"] } }
// after: restore installed form before disabling
"mcp": { "caveman": { "command": "npx", "args": ["caveman", "mcp"] } } Defensive patterns
Strategy: validation
Validate before calling
const cfg = JSON.parse(fs.readFileSync(opencodeConfig, 'utf8'));
const installed = journal.owned?.installed_mcp;
if (cfg?.mcp?.caveman && JSON.stringify(cfg.mcp.caveman) !== JSON.stringify(installed)) {
throw new Error('mcp.caveman differs from installed snapshot; resolve before disable');
} Type guard
const mcpUnchanged = (cfg, installed) => cfg?.mcp?.caveman === undefined || JSON.stringify(cfg.mcp.caveman) === JSON.stringify(installed);
Try / catch
try {
await caveman.disable(['opencode']);
} catch (err) {
if (err.message.includes('caveman MCP entry changed')) {
console.error('Revert or hand-delete the mcp.caveman entry, then retry.');
} else throw err;
} Prevention
- Treat mcp.caveman as tool-managed; don't add args/env to it manually.
- Register additional MCP servers under their own keys, not inside caveman.
- Keep the config under version control to spot unintended rewrites.
- Re-run enable after intentional edits so the journal snapshot is fresh.
When it happens
Trigger: Running disable when root.mcp.caveman exists but JSON.stringify(mcp.caveman) !== JSON.stringify(operation.owned.installed_mcp) — i.e. the caveman MCP entry was edited, reformatted with different field order/values, or overwritten by another tool.
Common situations: User manually added args/env to the caveman MCP server entry; another extension rewrote the mcp map; JSON was re-serialized with different key ordering or added fields after enable.
Understand the failure class
Background: Conflicting config options: "cannot be used together" — configuration validation errors across open-source libraries — this error's family across 162 libraries.
Related errors
- : MCP ownership journal failed; native config may already…
- MCP transaction failed and rolled back
- MCP transaction failed and safe recovery was blocked: …
- MCP transaction state kept changing; refusing mutation
- Aider Caveman config block changed after enable; refusing…
AI-assisted analysis of JuliusBrussee/caveman@3ee70a1026 (2026-09-20).
Data as JSON: /api/errors/fa42eacb985ef99a.
Report an issue: GitHub.
Appendix: source
Thrown at packages/cli/src/index.ts:8372
const previousRoutes = operation.owned?.previous_routes && typeof operation.owned.previous_routes === "object" && !Array.isArray(operation.owned.previous_routes) ? operation.owned.previous_routes as Record<string, unknown> : {};
for (const providerID of ["openai", "anthropic"]) {
const provider = providers[providerID] && typeof providers[providerID] === "object" && !Array.isArray(providers[providerID]) ? providers[providerID] as Record<string, unknown> : {};
const options = provider.options && typeof provider.options === "object" && !Array.isArray(provider.options) ? provider.options as Record<string, unknown> : {};
if (options.baseURL !== undefined && options.baseURL !== routes[providerID]) {
throw new Error(`OpenCode ${providerID} baseURL changed after enable; refusing destructive disable`);
}
if (previousRoutes[providerID] === null || previousRoutes[providerID] === undefined) delete options.baseURL;
else options.baseURL = previousRoutes[providerID];
if (Object.keys(options).length > 0) provider.options = options;
else delete provider.options;
if (Object.keys(provider).length > 0) providers[providerID] = provider;
else delete providers[providerID];
}
if (Object.keys(providers).length > 0) root.provider = providers;
else delete root.provider;
const mcp = root.mcp && typeof root.mcp === "object" && !Array.isArray(root.mcp) ? root.mcp as Record<string, unknown> : {};
if (mcp.caveman !== undefined && JSON.stringify(mcp.caveman) !== JSON.stringify(operation.owned?.installed_mcp)) {
throw new Error("OpenCode caveman MCP entry changed after enable; refusing destructive disable");
}
if (mcp.caveman !== undefined) {
if (operation.owned?.previous_mcp === null || operation.owned?.previous_mcp === undefined) delete mcp.caveman;
else mcp.caveman = operation.owned.previous_mcp;
}
if (Object.keys(mcp).length > 0) root.mcp = mcp;
else delete root.mcp;
return jsonBytes(root);
}
if (operation.kind === "aider-config") {
let text = current.toString("utf8");
const routeBlock = operation.owned?.route_block;
const readBlock = operation.owned?.read_block;
const previousRouteLine = operation.owned?.previous_route_line;
if (typeof routeBlock !== "string" || typeof readBlock !== "string") {
throw new Error("Aider integration journal lacks owned blocks");
}
if (!text.includes(routeBlock) || !text.includes(readBlock)) {View on GitHub (pinned to 3ee70a1026)