# How to Set Up the Codebase-Memory-MCP Store Module for Local Development

> Learn how to set up the codebase-memory-mcp store module for local development. Follow simple steps to clone, build, configure, and launch the MCP server quickly.

- Repository: [Martin Vogel/codebase-memory-mcp](https://github.com/DeusData/codebase-memory-mcp)
- Tags: how-to-guide
- Published: 2026-07-05

---

**To set up the store module for local development, clone the repository, build the static binary using [`./scripts/build.sh`](https://github.com/DeusData/codebase-memory-mcp/blob/main/./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.

```bash

# 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_DIR` as 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.

```bash

# 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:

```bash

# 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:

```bash

# 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:

```bash
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 the `build/c/codebase-memory-mcp` binary.
- Use [`./scripts/build.sh`](https://github.com/DeusData/codebase-memory-mcp/blob/main/./scripts/build.sh) to compile; add `--with-ui` for the optional 3D interface.
- Control the database location with the `CBM_CACHE_DIR` environment variable or by placing `.codebase-memory/graph.db.zst` in your project root.
- Start the server with `codebase-memory-mcp` and verify functionality using `cli index_repository` and `cli get_graph_schema`.
- Enable `CBM_DIAGNOSTICS=1` to 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`](https://github.com/DeusData/codebase-memory-mcp/blob/main/./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.