Provide a step-by-step setup path for running codex-mem locally and connecting it as an MCP server in Codex clients.
- Git
- Node.js 20+
- npm
- SQLite 3 (optional CLI, DB engine is bundled through dependency)
Run one command to install dependencies, prepare DB path, run migrations, and attempt Codex MCP registration:
npm run mcp:installOptional usage:
bash scripts/install-mcp.sh --help
bash scripts/install-mcp.sh --dry-run --no-register
bash scripts/install-mcp.sh --name codex-mem --db-path .memory/codex-mem.dbUse helper workflows to reduce manual save/search steps:
npm run auto:mode -- start --ingest --project codex-mem
npm run auto:mode -- end --summary "Session handoff summary here."
npm run auto:mode -- commitInstall optional git post-commit hook for automatic commit capture:
npm run auto:install-hooks -- --project codex-memDry-run preview:
npm run auto:mode -- start --dry-run --ingest --project codex-mem --limit 5
npm run auto:mode -- end --dry-run --summary "Draft handoff"
npm run auto:mode -- commit --dry-run
npm run auto:install-hooks -- --dry-runnpm installSet the DB path for this repo.
You can copy from .env.example:
cp .env.example .env.localThen export values in your shell if needed:
export MEMORY_DB_PATH=.memory/codex-mem.dbOptional compatibility variable:
CODEX_MEM_DB_PATH
Optional project label:
export MEMORY_PROJECT_NAME=codex-memnpm run migrateExpected output includes:
Migrations applied successfully for ...
npm run ingestDefault ingestion sources:
docs/session-log.mddocs/decisions.mddocs/requirements.md
npm run mcp:startUse this mode for quick terminal debugging.
Use the Connect to a custom MCP form with:
- Name:
codex-mem - Transport:
STDIO - Command to launch:
npm - Arguments:
runmcp:start--silent
- Environment variables:
- Key:
MEMORY_DB_PATH - Value:
.memory/codex-mem.db
- Key:
- Working directory:
- Absolute path to this repo (example:
/Users/hgeorge/Downloads/DEVELOPMENT/codex-mem)
- Absolute path to this repo (example:
Important:
- Relative DB paths resolve from the selected working directory.
- If you use a different working directory, provide an absolute DB path.
After saving MCP config, ask Codex to list or use tools and confirm these are available:
save_memorysearchtimelineget_entriesingest_docsretention_dry_run
Use these steps in Codex:
- Save memory with unique marker text.
- Search by marker text.
- Fetch details by returned ID.
- Request timeline around the returned ID.
If all four succeed, setup is correct.
RETENTION_MAX_AGE_DAYS=30 RETENTION_MAX_ENTRIES_PER_PROJECT=200 npm run retention:dry-runThis is analysis-only and does not delete data.
- Runtime is TypeScript + Node.js (
docs/runtime-decision.md). - For common failure modes, see
docs/troubleshooting.md.