codebase-memory-mcp icon indicating copy to clipboard operation
codebase-memory-mcp copied to clipboard

Add config key to disable file watcher

Open nguiaSoren opened this issue 6 months ago • 4 comments

Context: codebase-memory-mcp 0.6.0 has a background watcher that auto-reindexes on filesystem mtime updates. This is documented behavior, but there's no documented config key to disable it.

Use case: For projects with frequent doc edits unrelated to code structure (e.g., audit documentation), every save triggers a reindex that mutates graph node/edge counts. This makes "graph health" indicators less useful since baseline counts drift on routine edits.

Suggested config: watcher_enabled = false to fully disable. Users would then trigger index_repository manually when they want fresh state.

Workaround currently used: kill the codebase-memory-mcp process when quiesce is needed; reconnect via /mcp when ready to resume.

nguiaSoren avatar May 11 '26 04:05 nguiaSoren

Thanks for the clear use case, @nguiaSoren 🙏 A doc heavy repo where every save churns the graph baseline is exactly where this bites. A documented watcher_enabled = false key (so you trigger index_repository manually) is reasonable and low risk. It pairs nicely with #500 and #497, the same theme of giving the operator control over indexing behavior. We'll add a documented config key. Thanks!

DeusData avatar Jun 18 '26 18:06 DeusData

Happy to put up a PR for this one if it'd help take it off your plate — it's a small change (a documented watcher_enabled config key + gating the watcher init on it, defaulting to current behavior). Just say the word and I'll open it. Thanks!

nguiaSoren avatar Jun 18 '26 21:06 nguiaSoren

Yes, please go ahead with a focused PR. The contract should be: watcher_enabled defaults to true, false prevents the watcher thread from starting or registering projects, and manual index_repository calls continue to work normally. Please include config parsing/persistence coverage, a test proving no watcher initialization when disabled, and the user-facing config documentation. Keep it limited to this switch rather than broader watcher policy changes.

DeusData avatar Jul 15 '26 20:07 DeusData

Thanks for the green light, @DeusData — I've opened #1105 with the focused switch, built to your contract:

  • watcher_enabled defaults to true; false prevents the watcher thread from starting and from registering projects, while manual index_repository keeps working normally.
  • Config parse/persistence coverage + a test proving the watcher isn't initialized when disabled (cli_config_watcher_enabled_default_and_persist), plus the user-facing docs. Kept limited to this one switch.

One thing I surfaced in the PR description: since watcher_enabled (master kill-switch) sits next to the existing auto_watch (per-session registration), I documented both in CONFIGURATION.md — auto_watch was previously undocumented there — so the two knobs are clearly distinguished. No behavior change to auto_watch.

Full suite is green (6329 passed, clean ASan/UBSan) and I verified the on/off behavior on the built binary. Whenever you have a moment to review/approve — thanks!

nguiaSoren avatar Jul 15 '26 21:07 nguiaSoren