codex-lcm
Provides local, lossless context management for OpenAI Codex CLI sessions, capturing conversation events, compacting older context into hierarchical summaries, and exposing MCP tools for lexical recall and source expansion.
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@codex-lcmsearch my Codex session history for the term 'flaky test'"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
codex-lcm
Local, lossless context management for OpenAI Codex CLI.
codex-lcm captures Codex conversation events in SQLite, compacts older context into a hierarchy of summaries without deleting the source messages, restores relevant context when a session starts, and exposes lexical recall through a local MCP server.
Meaning of “lossless”: source content is retained after configured secret redaction. Searchable tool previews are bounded, while complete redacted tool input and output remain available through paged expansion.
Status and platform
codex-lcm is beta software for macOS. It relies on Codex hooks and POSIX flock; Windows and Linux are not currently supported or claimed.
Related MCP server: ClaudeX
Features
Live capture: user prompts, assistant responses, and tool activity are captured through Codex hooks.
Durable local storage: SQLite in WAL mode stores raw messages, structured message parts, summaries, and FTS5 indexes.
Hierarchical compaction: older messages become leaf summaries; eligible summary runs can be condensed into deeper DAG nodes. Source rows are never deleted automatically.
Context restore: active summaries and the newest unsummarized messages are injected at session start within a strict size bound.
Local recall: six stdio MCP tools provide lexical search, recent-session lookup, metadata inspection, and paged source expansion.
Fail-open hooks: capture or compaction failures do not block a Codex turn.
Safety controls: secret redaction, per-session compaction locks, atomic message/FTS writes, provider-call reservations, progress checks, and private default file permissions.
Install from a repository checkout
python3 -m venv ~/.codex-lcm/venv
~/.codex-lcm/venv/bin/python -m pip install .
~/.codex-lcm/venv/bin/codex-lcm install
~/.codex-lcm/venv/bin/codex-lcm doctorRestart Codex after installation. Use /hooks in Codex to inspect and trust the installed hooks.
The installer merges codex-lcm entries into ~/.codex/hooks.json and ~/.codex/config.toml. It creates timestamped backups before changing existing files. Running the installer again is idempotent.
A source checkout also includes scripts/install.sh, which performs the same isolated installation and verification.
Optional LLM summarization
On Python 3.11+, the core package has no third-party runtime dependencies. Python 3.10 installs the tomli compatibility backport for safe TOML configuration handling. Without an LLM client, compaction uses deterministic head/tail truncation.
To enable OpenAI-compatible summarization, install the optional extra and configure credentials:
~/.codex-lcm/venv/bin/python -m pip install ".[llm]"
export CODEX_LCM_API_KEY="..."OPENAI_API_KEY is also recognized. Use CODEX_LCM_BASE_URL or OPENAI_BASE_URL for an OpenAI-compatible endpoint. The CODEX_LCM_* provider settings are treated as a pair and take precedence as a pair, so a global key is never sent to a scoped endpoint. When CODEX_LCM_BASE_URL is set, configure CODEX_LCM_API_KEY too.
CLI
codex-lcm install Wire hooks and the MCP server into Codex
codex-lcm uninstall Remove codex-lcm wiring and keep stored data
codex-lcm status Show database statistics
codex-lcm doctor Verify package, database, hooks, and MCP wiring
codex-lcm compact --session <id> Compact one session synchronously
codex-lcm compact --all Compact every recorded session synchronouslyUninstalling does not delete ~/.codex-lcm/ or its database.
MCP tools
Tool | Purpose |
| Database and active-session statistics |
| Literal and FTS5 lexical search over messages and summaries |
| Ranked lexical recall with bounded result counts |
| Summary-source inspection or paged raw-message recovery |
| Sessions updated inside a UTC look-back window |
| Session or summary metadata |
Recall is lexical, not semantic: there are no embeddings or vector-similarity claims in this release.
Configuration
Configuration is read from environment variables.
Variable | Default | Purpose |
|
| SQLite database path |
|
| Newest raw messages protected from compaction |
|
| Maximum estimated tokens in a leaf chunk |
|
| Active leaf summaries required for condensation |
|
| Active deeper summaries required for condensation |
|
| Compaction rounds per worker run |
|
| Provider attempts allowed per session and call window |
|
| Provider-attempt accounting window |
|
| Provider request timeout |
|
| Marks a compaction run stalled below this savings ratio |
|
| Restore-context budget in estimated tokens |
|
| Extra unsummarized messages allowed before |
|
| Leaf summarization model |
|
| Condensation model |
| — | Optional provider credential |
| — | Optional OpenAI-compatible endpoint |
|
| Set to |
|
| Searchable tool-input preview length |
|
| Searchable tool-output preview length |
The default data directory is mode 0700; the database, WAL sidecars, lock files, and compaction log are mode 0600 on POSIX systems.
Data and security boundaries
Redaction occurs before persistence for known API keys, tokens, authorization headers, password/secret assignments, JWTs, and PEM private keys.
Credential-bearing Git remote URLs are stored without user information, query parameters, or fragments.
Redaction is defence in depth, not a guarantee that every possible secret format will be recognized.
Complete redacted tool payloads can still contain private conversation or project data. Protect the local account and database backups accordingly.
No data is sent to an LLM provider unless the optional client is installed and provider credentials or a base URL are configured.
Automatic retention and deletion are intentionally absent. The application does not silently discard source history.
Development
Use a project-local environment; tests never need the live Codex profile or database.
python3 -m venv .venv
.venv/bin/python -m pip install -e ".[dev]"
.venv/bin/python -m pytest -q
.venv/bin/python tests/smoke_test.py
.venv/bin/python tests/reliability_test.py
.venv/bin/python tests/package_test.py
.venv/bin/ruff check .
.venv/bin/bandit -q -r codex_lcmThe package test builds and installs into a throwaway home directory and virtual environment. The smoke and reliability scripts also use temporary databases.
See DESIGN.md for the storage model, invariants, hook flow, and failure behaviour.
License
MIT
This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Servers
- AlicenseNot gradedqualityAmaintenanceEnables AI coding agents to maintain persistent, cross-session memory of codebase architecture, naming conventions, and decisions through MCP tools. Eliminates repetitive project re-explanation by automatically injecting stored context into every session with local-first SQLite storage and optional team sharing capabilities.4MIT
- AlicenseAqualityBmaintenancePersistent memory + FTS5 full-text search for Claude Code conversation history. Indexes ~/.claude/projects/ JSONL into SQLite, exposes 10 MCP tools (store/recall/search memories, browse sessions, get summaries) plus prompts. Includes a web UI for visual exploration108992MIT
- AlicenseBqualityAmaintenanceProvides local cross-session memory for Codex by importing transcripts, indexing in SQLite, and exposing search, context, and memory management through MCP tools.13MIT
Related MCP Connectors
A paid remote MCP for OpenAI Codex context compressor, built to return verdicts, receipts, usage log
Persistent memory and cross-session learning for AI coding assistants (hosted remote MCP).
Hosted MCP memory: save sessions/decisions once, search from Claude, Cursor, ChatGPT. EU-hosted FTS.
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/Mallet-Dev/codex-lcm'
If you have feedback or need assistance with the MCP directory API, please join our Discord server