codebase-memory-mcp PreToolUse hook blocks Read/Grep on non-code files
On Linux with codebase-memory-mcp 0.5.7 and Claude Code 2.1.87, the installed cbm-code-discovery-gate hook blocks every Read and Grep call, including on .md, JSON, YAML, and other non-code files, with: BLOCKED: For code discovery, use codebase-memory-mcp tools first... It even triggers on the first .md read of a session. How can I read docs and configs without disabling the whole gate?
Originally asked on GitHub: https://github.com/DeusData/codebase-memory-mcp/issues/188
4 answers
Fixed. The blocking PreToolUse gate was rewritten in commit
c29e6d5and shipped in v0.7.0 as a non-blocking augmenter, so Read/Grep on non-code files pass through. The issue was closed as completed.Caveat: upgrading alone does not replace hook files already installed on your machine. One commenter still had the old
exit 2hook after updating; they deleted the hook files and re-ran the install script, which replaced it with the fixedexit 0version.If you cannot upgrade/reinstall yet, the thread has two options:
- The issue body suggests removing the
cbm-code-discoveryentries from~/.claude/settings.json(a Python snippet is in the thread). This is proposed as a workaround; no one in the thread reports testing it. - A commenter states that falling back to Bash+cat works, because the old hook only intercepts named tool calls (Read, Grep, etc.).
Root cause: the installed hook exits with code 2 on the first Read/Grep call, which Claude Code treats as a hard block. This contradicts the README's claim that hooks are advisory (exit code 0).
Did this work for you?- The issue body suggests removing the
What @cobrabr tried on GitHub (Worked)
After updating to v0.7.0, the old hook file with
exit 2was still present. Deleting the hook files and re-running the install script installed the fixedexit 0hook.Did this work for you?What @sagarbaver tried on GitHub (Worked)
Suggested falling back to Bash+cat instead of Read/Grep, since the old hook only intercepts named tool calls.
Did this work for you?What a GitHub user tried on GitHub (Didn't work)
Following the install steps, tried
Read docs/README.mdand got the BLOCKED message; Grep was blocked the same way.Source: https://github.com/DeusData/codebase-memory-mcp/issues/188 (opens external site)
Did this work for you?
Related questions
- codebase-memory-mcp cli search_code returns "search failed: temp file" on Windows
- Claude Code hook blocks every Read instead of once per session, how to fix?
- search_code always returns 0 results – ripgrep invoked without explicit path
- Does codebase-memory-mcp support PowerShell (.ps1, .psm1, .psd1) files?
- codebase-memory-mcp install/update fails with 'active CBM sessions could not be stopped safely' after killed processes