Regenerate safely after editing
Regeneration is the normal way to apply config changes (transport, protocol, features, new specs). It is safe by construction: see the ownership model for the decision table. This page is the practical recipe.
Recipe
Section titled “Recipe”# 1. Preview the plan. Writes nothing.mcpgen new ./weather --force --dry-run --json
# 2. Apply. Only flags you pass override the existing mcpgen.json.mcpgen new ./weather --transport http --force --no-check --json
# 3. Verify.mcpgen check ./weather --jsonThe dry-run envelope contains plan.files[] with path, action (create / overwrite / skip), owner, and reason for every file. Real example after editing an mcpgen-owned file:
{ "path": "internal/mcpapp/instructions.go", "action": "skip", "owner": "mcpgen", "reason": "modified since generation (hash mismatch)" }{ "path": "internal/mcpapp/tools/handlers/greet.go", "action": "skip", "owner": "user", "reason": "user-owned file already exists" }What to expect
Section titled “What to expect”- Your handler code is never touched. User-owned files always skip.
- mcpgen-owned files you edited also skip. The reason is
modified since generation (hash mismatch). Your edit wins; regen does not overwrite it. If you want the fresh generated version, delete the file and regen, or revert your edit first. - Untracked files are never clobbered (
exists and is not managed by mcpgen). mcpgen.jsonand.mcpgen/manifest.jsonare always rewritten. Only explicitly passed flags override the existing config; everything else is preserved.--featuresis additive — remove a feature by editingmcpgen.json.- One nuance: the
tidystage ofcheckrunsgo mod tidy, which can rewritego.mod. After acheck,go.modoften hashes differently than the manifest entry, so a later regen skips it withmodified since generation (hash mismatch). This is expected and harmless — the file keeps the tidy result.
Restore a generated file
Section titled “Restore a generated file”If you edited an mcpgen-owned file and want the generated version back:
rm weather/internal/mcpapp/instructions.gomcpgen new ./weather --force --no-check --json # recreates it (action: create)Next steps
Section titled “Next steps”- Ownership model and regeneration — the full decision table and diagram.
- Add tools, prompts, resources — removal procedure.
- FAQ — recovering from a broken
mcpgen.json.