0171: hz installs itself into coding harnesses, at user level by default¶
- Implementation partial
Context and Problem Statement¶
A person who wants Claude Code, Codex or Cursor to use Heinzelmännchen copies a claude mcp add line from MCP
Settings or runs hz system serve mcp-install-project, which only creates a new project file. Nothing installs at user
level, nothing removes hz again without touching the person's other servers, and the web app can't do either. ADRs
0019, 0062,
0142 and 0162 cover serving, finding and tokens, not writing
into another vendor's configuration. Where may hz write, what may it change, and how does it take only its own entry
out again?
Decision Drivers¶
- The owner's answer: hz installs into coding harnesses at user level by default.
- The files belong to other vendors and hold the person's other servers, history and settings: hz may add and remove its one entry, never anything else.
- Every write is shown first and confirmed for that exact file state.
- Head parity (0019): what the CLI can do, the web app can do, and the other way round.
- A token must never land in a file a project commits.
Considered Options¶
- A library per client and scope with a shown, digest-confirmed change and a receipt (chosen)
- Shell out to each client's own
mcp add/mcp remove: runs foreign code, output and behaviour differ per vendor and version, and removal can't tell hz's entry from one the person wrote. - Project files by default, user level only on request: the recommendation the owner did not take.
- A marker key inside the entry: clients validate their entries; an unknown key may be refused or dropped.
- Web-only: breaks head parity.
Decision Outcome¶
Chosen option: a library per client and scope with a shown, digest-confirmed change and a receipt, because it writes only what the person saw, keeps every other entry and can take exactly its own entry out again.
- Targets: Claude Code
~/.claude.json, Codex$CODEX_HOME/config.toml(default~/.codex), Cursor~/.cursor/mcp.jsonat user level (the default);.mcp.json,.codex/config.toml,.cursor/mcp.jsonin a project only when named. A project that is the home folder, a link or replaced since it was chosen is refused. - The entry: server
heinzel, this interpreter with-m heinzel system serve mcpover stdio; no environment and no token: stdio runs as the person, and a token in a file a project commits would leak. An HTTP entry with its own read or write token (0142) is a later amendment. - Status:
missing,matching(exactly the entry above) orconflicting; reading follows no final link, stops at 8 MB and never reports the file's contents. - Install:
plannames the file, the action (create,add,none) and the entry, with a digest over client, scope, path, action and the file's current SHA-256.installwrites only with that digest. At user level it backs the file up to<name>.hz-backup, writes beside it and replaces it in one step after checking it did not change meanwhile, and keeps the file's mode; a new file is 0600 in a 0700 folder. Anotherheinzelserver is never overwritten, a file that does not parse is never rewritten, and a project file is only ever created. - Receipt:
harness-installs.json(0600) in hz's configuration folder records, per file, the client and the digest of the entry hz wrote; never file contents. - Uninstall: a file that is byte for byte what hz writes is removed; from a shared user file hz removes its entry only when the receipt names that file and the entry is still exactly what hz wrote. Anything else is the person's edit, and the answer names the file.
- Surfaces:
hz system serve mcp-install(shows the change;--confirm DIGESTwrites it),mcp-check-projectandmcp-uninstall-project(--scope userby default), and the same three in MCP Settings, where a dialog shows the file and the entry before the person confirms. - Heinzels as tools and MCP/CLI parity: what hz offers a harness is its operations over MCP (0019); a Heinzel is reachable as a tool only through those operations, so a harness never gets more than the CLI offers.
Consequences¶
- Good: one confirmed step puts hz into the harness the person uses everywhere, and one step takes it out again without losing anything else.
- Good: a harness that rewrote its file between the plan and the write loses nothing: hz refuses and shows it again.
- Bad: hz rewrites a vendor's file. JSON is written back with two-space indents and may change the person's formatting; TOML keeps its formatting (tomlkit). The backup holds the file as it was.
- Bad: a harness that writes its file in the instant between hz's check and its replace can lose that write; the window is one rename, and the backup holds the earlier state.
Confirmation¶
Unit tests in a fictional home prove for all three clients: user level is the default, other entries and settings
survive install and uninstall, the backup holds the original, a stale or missing digest writes nothing, another
heinzel server and an unparsable or linked file are refused untouched, removal without the receipt or after a
change leaves the file alone, and the receipt holds no file contents. A Vitest proves MCP Settings shows the change
before it writes. Tests never touch the machine's own harness files.
More Information¶
Built in 0.9.59 (4pih.1): status, install, receipt-bound uninstall, the CLI commands and MCP Settings. Still to come: the HTTP entry with its own token, the desktop folder picker for project scope, and an end-to-end run against real Claude Code and Codex in an isolated home on macOS CI (4pih.4).