What Database Technology Is Used for Graph Storage in codebase-memory-mcp?
The graph storage in codebase-memory-mcp uses an embedded SQLite database, utilizing a vendored copy of SQLite to provide a lightweight, file-based graph store without requiring an external server.
The DeusData/codebase-memory-mcp module persists graph data using an embedded SQLite database rather than external graph databases. This architectural choice embeds a complete SQLite engine directly into the package through vendored source files, enabling zero-configuration deployment while maintaining ACID compliance for graph operations. Understanding what database technology is used for graph storage in this module reveals a design optimized for local development and CI/CD environments.
Embedded SQLite as the Graph Storage Engine
The module implements graph persistence through an embedded SQLite database shipped as a vendored dependency. Unlike client-server architectures requiring separate database installations, the repository includes complete SQLite source code in the vendored/sqlite3/ directory.
Specifically, the vendored/sqlite3/sqlite3.h header file and vendored/sqlite3/sqlite3.c implementation file compile directly into the package. This bundling strategy eliminates external dependencies while providing full SQL capabilities for graph storage operations.
How the Graph Database Path Is Configured
Graph data storage location is controlled through the CBM_CACHE_DIR environment variable. When set, this variable designates the directory where the SQLite database file is created and accessed.
In tests/windows/mcp_stdio.py at line 30, test code demonstrates this configuration by isolating the graph database to a specific cache directory. The library uses this path to initialize the SQLite connection, treating the designated folder as the container for the graph storage file.
Working with the SQLite-Backed Graph Store
You can interact with the graph storage by configuring the cache directory and invoking the CLI. The following example demonstrates how to isolate the graph database and execute Cypher-like queries against the embedded SQLite store:
import os
import subprocess
# 1️⃣ Isolate the graph database directory for a test run
cache_dir = "/tmp/graph-cache"
env = os.environ.copy()
env["CBM_CACHE_DIR"] = cache_dir # ← points the module to a SQLite file in this folder
# 2️⃣ Run the CLI that accesses the graph (the CLI internally opens the SQLite DB)
result = subprocess.run(
["codebase-mcp", "query_graph", "--query", "MATCH (n) RETURN n LIMIT 5"],
env=env,
capture_output=True,
text=True,
)
print(result.stdout) # → JSON-encoded rows from the embedded SQLite graph DB
This workflow illustrates how the module uses the CBM_CACHE_DIR environment variable to locate the SQLite file, with the codebase-mcp CLI entry point handling the database connection internally via the bundled SQLite library.
Key Source Files Confirming SQLite Implementation
Several critical files in the DeusData/codebase-memory-mcp repository confirm the SQLite-based architecture:
vendored/sqlite3/sqlite3.h– The header file defining the SQLite C API used for graph storage operations.vendored/sqlite3/sqlite3.c– The complete SQLite engine implementation compiled into the module.pkg/pypi/src/codebase_memory_mcp/_cli.py– The CLI entry point that initializes connections to the SQLite-backed graph store.tests/windows/mcp_stdio.py– Contains test utilities demonstrating theCBM_CACHE_DIRenvironment variable configuration at line 30.
These files collectively establish that SQLite serves as the underlying database technology for graph storage, implemented as an embedded, zero-dependency solution.
Summary
- SQLite is the database technology used for graph storage in codebase-memory-mcp, implemented as an embedded engine rather than a client-server architecture.
- The repository includes a vendored copy of SQLite in
vendored/sqlite3/, compiling the database engine directly into the package. - Graph storage location is configured via the
CBM_CACHE_DIRenvironment variable, which specifies the SQLite file path. - The CLI interface in
_cli.pyhandles database connections automatically, allowing querying via standard subprocess calls without manual connection management. - This architecture provides a lightweight, file-based graph store suitable for local development and automated testing environments.
Frequently Asked Questions
Does codebase-memory-mcp require an external database server?
No, codebase-memory-mcp does not require an external database server. The module uses an embedded SQLite database that compiles directly into the package from the vendored source files in vendored/sqlite3/. This design provides self-contained graph storage using local files, eliminating the need for separate database installation or network configuration.
How do I specify where the graph database is stored?
Set the CBM_CACHE_DIR environment variable to designate the directory for the SQLite database file. As shown in tests/windows/mcp_stdio.py at line 30, this variable points the module to the specific filesystem location where graph data persists. The CLI and library internals automatically create and manage the SQLite file within this directory.
What type of queries can I run against the graph storage?
The codebase-memory-mcp CLI supports Cypher-like graph queries executed against the embedded SQLite backend. As demonstrated in the code example, you can invoke codebase-mcp query_graph with --query parameters containing pattern matching syntax such as MATCH (n) RETURN n LIMIT 5. The query processor translates these graph operations into SQLite operations while maintaining the property graph model.
Why does the repository include SQLite source code instead of using a dependency?
The repository includes SQLite as a vendored dependency in vendored/sqlite3/ to ensure consistent behavior across platforms and eliminate external build requirements. By compiling sqlite3.c directly into the package, the module guarantees that the specific SQLite version supporting its graph storage features is always available, regardless of system-level package managers or installation constraints.
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 →