hledger_rewrite
runs hledger rewrite on a temporary copy, letting you specify one or more addPostings instructions for matching transactions. Use dryRun for a diff-only preview or diff: true to include the patch output alongside the applied change.
How to use it
hledger_rewrite is exposed by the Hledger MCP MCP server. Add the server to your MCP client (Claude Desktop, Cursor, Windsurf and others), and the hledger_rewrite tool becomes available to the model automatically. See the full listing for setup details and every tool this server provides.
Install Hledger MCP
npx @iiatlas/hledger-mcp /path/to/your/master.journalOther tools in Hledger MCP (8)
accepts structured postings and appends a new transaction after validating with hledger check. Enable dryRun to preview the entry without writing.
produces closing/opening assertions, retain-earnings, or clopen transactions via hledger close. Preview the generated entries with dryRun, then append them atomically (with optional backups) once you’re satisfied.
wraps hledger import, running the command against a temporary copy of the journal. Provide one or more dataFiles (journal, csv, etc.) and an optional rulesFile; set dryRun to inspect the diff before committing. Successful imports create timestamped .bak files unless --skip-backup is active.
deletes a transaction by exact text and location, re-validating with hledger check and respecting optional backups.
swaps an existing entry for new content, keeping spacing tidy and performing a validation pass before committing.
launches the hledger web UI/API on a free port unless a specific port/socket is supplied. The response includes an instanceId that can be used to track or terminate the server later.
returns metadata for each active web instance started by this MCP session (PID, command, base URL, access mode, etc.).
stops a selected instance by instanceId, pid, or port, or stops everything with all=true. You can optionally choose the shutdown signal (SIGTERM by default) and timeout.