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

Trying to exclude a directory in my project so that it is never included in the index_repository

Open ffscz opened this issue 8 months ago • 5 comments

I’m using VSCode Insider and I’m trying to exclude a directory in my project so that it is never included in the index_repository. I also created a file: .cgrignore with the following contents:

backup_old_reference/** /backup_old_reference/ backup_old_reference

After running index_repository, it’s still in the index and I just can’t exclude it.

Can you advise how to do this?

ffscz avatar Mar 11 '26 16:03 ffscz

Maybe this could fix it for you when it's merged? https://github.com/DeusData/codebase-memory-mcp/issues/31

shyney7 avatar Mar 11 '26 16:03 shyney7

I think you can workaround this issue as follows:

  1. Remove the MCP server temporarily from the agent's MCP config
  2. close your IDE/agent process and check if codebase-memory-mcp is not running in task manager anymore. If it's still running: kill the process.
  3. navigate to the codebase-memory-mcp .cache folder, e.g. C:\Users\{user}\.cache\codebase-memory-mcp on Windows
  4. delete all files in this folder and keep the folder open so you can check if nothing is recreated when you restart your IDE/code agent.
  5. Restart your IDE/code agent and check if no files are created in the .cache folder at this time. If nothing appears you're good.
  6. re-add the MCP server to the config and save it. Depending on your IDE/code agent it might instantly connect to the MCP server and trigger an index in which case you'll see new files created in the .cache folder. If nothing happens > restart IDE/code agent and check again.

If the .cgrignore file is correct it won't index the excluded folder. If this still doesn't work you can try another workaround and add a cwd parameter to the codebase_memory command to another folder that's 1 down in the tree from your root like:

command = "D:\\Dev\\MCP\\codebase-memory-mcp\\codebase-memory-mcp.exe" cwd = "D:\\Project-Root\\src"

So if your backup folder is in root with a bunch of other config stuff and .gitignore and build artifact folders you can exclude them like this and set the cwd to the folder where your actual app files live.

SlippyDong avatar Mar 11 '26 17:03 SlippyDong

I am working on this, comes today in a new release. Just need to test everything. Sorry for the wait

DeusData avatar Mar 12 '26 11:03 DeusData

I am working on this, comes today in a new release. Just need to test everything. Sorry for the wait

Okay, thx.

ffscz avatar Mar 12 '26 11:03 ffscz

This is resolved in v0.4.7 which introduces layered ignore file support:

  1. .gitignore support — the indexer now respects your existing .gitignore patterns. If backup_old_reference/ is in your .gitignore, it will be excluded from indexing automatically.

  2. .cbmignore (new) — a dedicated ignore file that stacks on top of .gitignore. Place a .cbmignore at your repo root with gitignore-style patterns to exclude directories specifically from codebase-memory-mcp indexing without affecting your git config:

    backup_old_reference/
    
  3. .cgrignore still works for backwards compatibility, but .cbmignore is the recommended approach going forward as it supports the full gitignore syntax (globstar, negation, directory-only patterns).

After upgrading to v0.4.7, reindex your project and the excluded directories will be removed from the graph automatically.

Release: https://github.com/DeusData/codebase-memory-mcp/releases/tag/v0.4.7

DeusData avatar Mar 12 '26 13:03 DeusData