How to Set Up the Codebase-Memory-MCP Store Module for Local Development
To set up the store module for local development, clone the repository, build the static binary using ./scripts/build.sh, optionally configure the CBM_CACHE_DIR environment variable, and launch the MCP server with codebase-memory-mcp.
The store module is the SQLite-backed graph storage engine that powers the DeusData/codebase-memory-mcp repository. Located under src/store/, this module compiles into a single static binary requiring only a C compiler and zlib as dependencies. Setting it up locally involves three main phases: building the binary, configuring the database location, and starting the server.
Clone and Build the Repository
Begin by cloning the repository and compiling the store implementation into an executable. The store code lives under src/store/ and is linked into the final binary during the build process.
# Clone the repository
git clone https://github.com/DeusData/codebase-memory-mcp.git
cd codebase-memory-mcp
# Build the core binary (no UI)
./scripts/build.sh
# Or build with the optional 3D UI
./scripts/build.sh --with-ui
The build process outputs build/c/codebase-memory-mcp, a static executable containing the store implementation. No external libraries are required beyond a C compiler and zlib, as documented in the Build from Source section of the repository.
Configure the Store Directory
The store writes its SQLite database to graph.db.zst using zstd compression. You can control where this file resides using three different approaches:
Default location – If you do nothing, the binary automatically creates and uses $HOME/.cache/codebase-memory-mcp/graph.db.zst. This works out-of-the-box for single-user setups.
Custom path via CBM_CACHE_DIR – Export this environment variable before launching the server to redirect all project databases to a specific directory. For example, export CBM_CACHE_DIR=/my/custom/path causes the store to write to /my/custom/path/graph.db.zst.
Per-project snapshot – Place a .codebase-memory/graph.db.zst file in your repository root. The server imports this snapshot on first run, allowing teammates to share pre-indexed graphs without re-indexing. This is documented in the Team-Shared Graph Artifact section of the repository.
Tip: When running inside containers, mount the directory referenced by
CBM_CACHE_DIRas a volume to persist data across rebuilds.
Launch the MCP Server
The store initializes automatically when you start the MCP server. The server binary handles both the graph storage and the optional web interface.
# Simple launch (no UI)
codebase-memory-mcp
# Launch with the optional UI (runs on http://localhost:9749)
codebase-memory-mcp --ui=true --port=9749
Upon startup, you will see a log line confirming the store location:
level=info msg="store opened at /home/you/.cache/codebase-memory-mcp/graph.db.zst"
The server automatically registers with supported coding agents including Claude Code, Codex CLI, and Gemini CLI.
Configure Store Settings
Use the built-in configuration commands to persist settings without manually exporting environment variables:
# List current settings
codebase-memory-mcp config list
# Set a custom cache directory (persisted globally)
codebase-memory-mcp config set CBM_CACHE_DIR=/tmp/cbm-data
# Enable automatic indexing on every session start
codebase-memory-mcp config set auto_index true
These commands update the underlying SQLite store and in-memory cache directly.
Verify the Store Is Working
Confirm the store is operational by indexing a repository and querying the graph schema:
# Index a repository (replace <path> with your actual repo)
codebase-memory-mcp cli index_repository '{"repo_path":"<path>"}'
# Query the store for schema statistics
codebase-memory-mcp cli get_graph_schema
You should receive JSON output containing node and edge counts, confirming that src/store/ successfully created and populated the database.
Enable Diagnostics (Optional)
For debugging performance issues related to the store, enable the diagnostics collector:
export CBM_DIAGNOSTICS=1
codebase-memory-mcp
The server will write cbm-diagnostics-<pid>.json and .ndjson files to /tmp, containing detailed metrics about store operations and query performance.
Summary
- The store module lives in
src/store/and compiles into thebuild/c/codebase-memory-mcpbinary. - Use
./scripts/build.shto compile; add--with-uifor the optional 3D interface. - Control the database location with the
CBM_CACHE_DIRenvironment variable or by placing.codebase-memory/graph.db.zstin your project root. - Start the server with
codebase-memory-mcpand verify functionality usingcli index_repositoryandcli get_graph_schema. - Enable
CBM_DIAGNOSTICS=1to troubleshoot store performance issues.
Frequently Asked Questions
What file format does the store module use?
The store module uses SQLite with zstd compression, writing files named graph.db.zst. This format supports the full knowledge graph including node/edge tables and Louvain clustering logic implemented in src/store/.
Can I use a custom directory for the SQLite database?
Yes. Set the CBM_CACHE_DIR environment variable to any writable path before launching the server. Alternatively, run codebase-memory-mcp config set CBM_CACHE_DIR=/your/path to persist this setting globally.
How do I share the graph database with teammates?
Place a pre-indexed .codebase-memory/graph.db.zst file in your repository root. When teammates clone the repo and start the server, it automatically imports this snapshot, allowing them to skip the initial indexing phase entirely.
What dependencies are required to build the store module?
You only need a C compiler and zlib. The build script ./scripts/build.sh compiles the store module into a static binary with no external library dependencies, making it portable across macOS, Linux, and Windows systems.
Have a question about this repo?
These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:
curl -s "https://instagit.com/install.md" Maintain an open-source project? Get it listed too →