This document describes the current installation and configuration paths for version 0.2.2 of the project.
It replaces older exploratory setup notes and reflects the repository as it exists now.
The server supports three runtime modes.
Use this when Docker is available and you want the server to manage persistence automatically.
Behavior:
- starts a project-scoped Neo4j container automatically;
- persists data in
./.data/neo4j/; - reuses the same database on the next session in the same project;
- does not require Neo4j credentials in the MCP client configuration.
Use this when you already have a Neo4j service you want to control yourself.
Use this when you want the simplest local setup and do not want Neo4j at all.
Required:
- Python 3.10+
uv- Git
Required only for managed Neo4j:
- Docker daemon available and running
Optional:
- Neo4j server, if you choose external Neo4j mode
Install uv if necessary:
curl -LsSf https://astral.sh/uv/install.sh | shgit clone <repository-url>
cd codebase_state_manager_mcp
./scripts/setup.shThe setup script:
- creates
.venv/with uv; - installs the package in editable mode;
- installs dev dependencies by default.
Alternative direct install:
uv sync --extra devActivate the virtual environment if desired:
source .venv/bin/activatepython run_mcp_server.pypython -m src.mcp_serverpython init_neo4j_and_mcp.pyThe alias still works, but the canonical launcher is now run_mcp_server.py.
{
"mcp": {
"codebase-state-manager": {
"type": "local",
"command": [
"uv",
"run",
"--project",
"/absolute/path/to/codebase_state_manager_mcp",
"python",
"run_mcp_server.py"
],
"enabled": true
}
}
}Nothing else is required for Neo4j in this mode.
The --project flag passed to uv run controls which Python project/environment
is used to resolve and install dependencies for the MCP server process.
It is not the codebase being managed.
- Use
--project /absolute/path/to/codebase_state_manager_mcpso the server runs with its own dependencies installed. - Configure the managed codebase explicitly via
MANAGED_PROJECT_PATH(below), or by starting the server with the managed codebase as the current working directory.
{
"mcp": {
"codebase-state-manager": {
"type": "local",
"command": [
"uv",
"run",
"--project",
"/absolute/path/to/codebase_state_manager_mcp",
"python",
"run_mcp_server.py"
],
"environment": {
"DB_MODE": "sqlite"
},
"enabled": true
}
}
}{
"mcp": {
"codebase-state-manager": {
"type": "local",
"command": [
"uv",
"run",
"--project",
"/absolute/path/to/codebase_state_manager_mcp",
"python",
"run_mcp_server.py"
],
"environment": {
"DB_MODE": "neo4j",
"NEO4J_BOOTSTRAP_MODE": "external",
"NEO4J_URI": "bolt://localhost:7687",
"NEO4J_USER": "neo4j",
"NEO4J_PASSWORD": "your_password"
},
"enabled": true
}
}
}EVM mode anchors state hashes on-chain and serves reads from a local SQLite mirror. Status: proof of concept.
Prerequisites beyond §2:
- Foundry (
forge+anvil) for the local devnet and contract deploy - kubo (IPFS) running locally (
ipfs daemon, API on127.0.0.1:5001) - Deployed
CodebaseStateRegistrycontract (contracts/src/CodebaseStateRegistry.sol)
Local devnet flow (Anvil, zero cost):
anvil # terminal 1
ipfs daemon # terminal 2
cd contracts && forge create \
--rpc-url http://127.0.0.1:8545 \
--private-key 0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80 \
--broadcast \
src/CodebaseStateRegistry.sol:CodebaseStateRegistry # note the deployed address{
"mcp": {
"codebase-state-manager": {
"type": "local",
"command": [
"uv",
"run",
"--project",
"/absolute/path/to/codebase_state_manager_mcp",
"python",
"run_mcp_server.py"
],
"environment": {
"DB_MODE": "evm",
"EVM_RPC_URL": "http://127.0.0.1:8545",
"EVM_CHAIN_ID": "31337",
"EVM_CONTRACT_ADDRESS": "0x<deployed-address>",
"EVM_PRIVATE_KEY": "0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80",
"EVM_IPFS_API_URL": "http://127.0.0.1:5001",
"EVM_MIRROR_PATH": "./data/evm_mirror.db"
},
"enabled": true
}
}
}Notes:
DB_MODE=evmfails fast on startup if the chain or contract is unreachable — there is no silent fallback to another backend.- The private key above is the Anvil well-known dev key #0 (public, local-only). Never use it with real funds.
- All EVM tests run against a local Anvil instance. A one-time live Base Sepolia run that closed AC-11-OPT on 2026-07-21 is preserved at
docs/measurements/archive/sepolia_2026-07/for reference only; the live-testnet code path is no longer maintained.
The application reads .env automatically when present.
DB_MODE=neo4j
LOG_LEVEL=INFO
RATE_LIMIT_ENABLED=true
AUDIT_ENABLED=true
VOLUME_PATH=/opt/codebase-state-manager/volumes/<current-project-dir-name>
SQLITE_PATH=./data/state_manager.dbIf VOLUME_PATH is omitted, the server automatically falls back to /opt/codebase-state-manager/volumes/<current-project-dir-name> so the managed snapshot stays outside the project tree.
The server needs to know which codebase directory it is managing. It resolves the managed project path in this order:
MANAGED_PROJECT_PATH(environment variable)- persisted metadata in the repository backend (when available)
- tool-provided project path (for tool calls that accept it)
- the service's current in-memory project path
To force the managed project to be a specific directory (recommended for editor integrations), set:
MANAGED_PROJECT_PATH=/absolute/path/to/your/codebaseImportant: in managed Neo4j mode the same MANAGED_PROJECT_PATH anchors the
project-scoped Neo4j container identity (container name, data volumes, and runtime
ports). It must stay stable across launches; otherwise the server starts a new Neo4j
instance per run and orphaned containers accumulate. When unset, the bootstrap falls
back to the process working directory at startup.
NEO4J_BOOTSTRAP_MODE=auto
NEO4J_AUTO_IMAGE=neo4j:5.24
NEO4J_AUTO_HOME=./.data/neo4j
NEO4J_CONNECTION_TIMEOUT=90NEO4J_BOOTSTRAP_MODE=external
NEO4J_URI=bolt://localhost:7687
NEO4J_USER=neo4j
NEO4J_PASSWORD=your_passwordDB_MODE=evm
EVM_RPC_URL=http://127.0.0.1:8545
EVM_CHAIN_ID=31337
EVM_CONTRACT_ADDRESS=0x<deployed-address>
EVM_PRIVATE_KEY=0x<signing-key> # Anvil dev key #0 for local; never a real-funds key
EVM_IPFS_API_URL=http://127.0.0.1:5001
EVM_MIRROR_PATH=./data/evm_mirror.dbDefaults target the local Anvil devnet, so DB_MODE=evm works with zero configuration once Anvil, kubo, and the contract deploy exist. See §5.4.
docker ps | grep codebase-state-manager-neo4j
ls ./.data/neo4j/python -m pytest tests -q
uv run mypy src/
uv run bandit -r src/ -qCurrent validation status on the repository:
- tests:
568 passed - mypy: pass
- bandit: clean
./scripts/dev.sh./scripts/run_tests.sh
./scripts/run_tests.sh unit
./scripts/run_tests.sh integration
./scripts/run_tests.sh security
./scripts/run_tests.sh e2eThe canonical and most direct command remains:
python -m pytest tests -qThe following tools accept state_representation:
genesis_toolget_genesis_result_toolnew_state_transition_toolarbitrary_state_transition_toolget_current_state_info_toolget_state_info_tool
Accepted values:
rawcompactboth
The server also exposes:
get_current_state_compact_context_tool
This generates an SCC-E (State Compression Code — Embedding) preview for the current workspace without creating a new state.
If DB_MODE=neo4j and the server cannot connect to Neo4j, it falls back to SQLite.
Check:
- Docker is running for managed Neo4j mode
- your external credentials are correct for external mode
NEO4J_BOOTSTRAP_MODEmatches the intended mode
Check:
docker ps -a | grep codebase-state-manager-neo4j
ls -R ./.data/neo4j/Default SQLite path:
./data/state_manager.dbOverride with:
SQLITE_PATH=/custom/path/state_manager.dbUse managed Neo4j when:
- you want graph persistence;
- Docker is available;
- you want the project to carry its own persistent graph database.
- Docker is unavailable;
- you prefer a single local file database;
- operational simplicity is more important than graph-native storage.
- your infrastructure already provides Neo4j;
- authentication and backup policies are handled outside the project.