Omni-Mem MCP Server
README.md
# Omni-Mem v2.0
**Autonomous, cross-agent persistent memory for [Antigravity](https://antigravity.google), [Claude Code](https://code.claude.com), and [OpenAI Codex](https://openai.com/codex).**
> **Zero daemon. Zero OAuth. Zero SaaS. Zero `npm` dependencies.**
> Powered by Node.js built-in `node:sqlite` (WAL + FTS5 + BM25) with bounded $O(1)$ growth forever.
---
## Why Omni-Mem?
Most coding-agent memory plugins fail in one of three ways:
1. **Fragile daemons & proprietary OAuth** (`claude-mem` breaks whenever you switch proxies/providers or lack an Anthropic OAuth token, while running an HTTP server on `:37777`).
2. **Passive MCP-only tools** (`server-memory`) that models forget to query at session start and forget to update at session end.
3. **Snowball rot** — raw chat logs accumulate indefinitely, polluting prompts with false positives and outdated fixes.
**Omni-Mem** solves all three via a single local SQLite database (`~/.omni-mem/memory.db`) wired natively into the lifecycle hooks **and** MCP layers of all three coding agents.
| Capability | `claude-mem` | `server-memory` (MCP) | **Omni-Mem v2.0** |
| :--- | :---: | :---: | :---: |
| Antigravity + Claude Code + Codex shared brain | ❌ | Manual | **✅ Autonomous** |
| Works with custom proxies / any model / offline | ❌ (requires Anthropic OAuth) | ✅ | **✅ 100% local** |
| Zero background daemon / zero open HTTP ports | ❌ (`:37777`) | ✅ | **✅ Zero daemon** |
| Zero external npm dependencies | ❌ | ❌ | **✅ Pure Node.js `node:sqlite`** |
| Strict lexical-gated JIT recall + typo rescue | ❌ | ❌ | **✅ FTS5 + synonyms + 3-gram** |
| Self-resolving Open Loops (`todo`) + File Drift | ❌ | ❌ | **✅ Built-in** |
| Bounded $O(1)$ growth (Hard Caps + 24h Auto-GC) | ❌ | ❌ | **✅ Built-in** |
| Automatic secret redaction firewall | ⚠️ | ❌ | **✅ Built-in** |
---
## Architecture
```text
[Antigravity] ──┐
[Claude Code] ──┼──► Lifecycle Hooks (SessionStart · PreInvocation/UserPromptSubmit · Stop · PreCompact)
[OpenAI Codex] ─┘ │
▼
~/.omni-mem/memory.db (SQLite WAL + FTS5)
├── Git-branch & file-drift aware boot context (<omni-mem>)
├── Strict lexical + synonym + 3-gram typo JIT recall (<omni-mem-recall>)
├── Incremental JSONL transcript harvester (Antigravity + Claude + Codex)
├── Self-resolving Open Loops (todo) + entity superseding
├── O(1) Hard Caps + lazy 24h Auto-GC + WAL autocheckpoint
├── Optional detached LLM distiller (Ollama / OpenAI / Anthropic)
└── Zero-dependency stdio MCP Server (9 tools) + On-demand HTML Dashboard
```
### Key Features
* **4-Layer Autonomous Lifecycle:**
1. **`SessionStart`**: Injects `<omni-mem>` with open loops (`todo`), pinned rules, top project decisions/bugfixes (with real-time `[drift: <file> movido/removido]` alerts), cross-agent handoffs, and global preferences — hard-capped to `3400` chars.
2. **`PreInvocation` / `UserPromptSubmit`**: Captures inline user directives immediately (*"sempre..."*, *"nunca..."*, *"lembra que..."*, *"always..."*, *"never..."*) and injects `<omni-mem-recall>` **only** when the prompt passes a strict lexical + bilingual synonym + 3-gram Dice typo gate. Short-circuits repeated tool-loop invocations with `{}` to protect prompt caching.
3. **`Stop` / `PreCompact`**: Incrementally reads transcript deltas by `byte_offset` across Antigravity (`transcript_full.jsonl`), Claude Code (`.claude/projects/*.jsonl`), and Codex (`rollout-*.jsonl`, ignoring `guardian_review` and internal subagents). Auto-resolves open `todo`s when a later turn fixes or ships them.
4. **Stdio MCP Server + CLI + On-Demand HTML Dashboard**: 9 lazy-loaded MCP tools (opening and closing SQLite per call so WAL checkpoints never block) plus `omnimem report --open` for an interactive dark-mode local dashboard (`~/.omni-mem/dashboard.html`).
* **Anti-Snowball $O(1)$ Engine:**
* Per-project hard caps: `80` non-pinned core memories, `12` session handoffs, `8` open todos (pinned rules/preferences are immortal).
* Entity/topic superseding (`status = 'superseded'`, `superseded_by = new_id`) prevents conflicting legacy bugfixes from piling up.
* Lazy 24h / 50-write Auto-GC: TTL archive (`session` > 14d, `todo` > 7d, unaccessed > 45d), physical `DELETE` purge (> 60d), FTS5 `optimize`, `wal_checkpoint(TRUNCATE)`, and `incremental_vacuum`.
* **Secret Redaction Firewall:** Automatically scrubs `sk-*`, `tpk_*`, `ghp_*`, `AIza*`, JWTs, `Bearer` tokens, private key blocks, and `api_key`/`token`/`password` assignments before anything touches disk.
---
## Quick Start (1 Command)
**Requirements:** Node.js `>= 22.5` (tested on Node.js `v24.14.1` with built-in `node:sqlite`).
```bash
git clone https://github.com/brunorainha-commits/omni-mem.git
cd omni-mem
node --no-warnings src/install.mjs
```
The installer backs up your existing configs (`*.pre-omnimem-*.bak`) and wires:
* **Antigravity:** `~/.gemini/config/plugins/omni-mem/` (auto-discovered live)
* **Claude Code:** `~/.claude/settings.json` (hooks) + `~/.claude.json` (MCP server)
* **OpenAI Codex:** `~/.codex/hooks.json` (strict `HooksFile` schema) + `~/.codex/config.toml` (`[features] hooks = true` + `[mcp_servers.omni-mem]`)
> **Codex Hook Trust (required once):** Codex loads `~/.codex/hooks.json` with `trustStatus: "untrusted"` by default and skips untrusted handlers silently (even though the `omni-mem` MCP server connects immediately). After restarting Codex Desktop, open **Settings → Hooks** and click **Trust** on the 4 Omni-Mem hooks (`SessionStart`, `UserPromptSubmit`, `Stop`, `PreCompact`). For non-interactive Codex CLI automation, `--dangerously-bypass-hook-trust` is also supported by Codex.
Verify installation and optionally backfill existing history from all 3 agents:
```bash
node --no-warnings ~/.gemini/config/plugins/omni-mem/src/cli.mjs doctor
node --no-warnings ~/.gemini/config/plugins/omni-mem/src/cli.mjs ingest-history 30
node --no-warnings ~/.gemini/config/plugins/omni-mem/src/cli.mjs report --open
```
---
## CLI Reference
```bash
omnimem doctor # Verify DB, FTS5, and all 3 agent integrations
omnimem status # Counts by agent, kind, project, DB & WAL size
omnimem audit [dir] # Cap utilization, noise candidates, last Auto-GC
omnimem gc # Run full garbage collection & WAL truncate now
omnimem report [--open] # Generate self-contained ~/.omni-mem/dashboard.html
omnimem preview [dir] # Preview exact SessionStart injection (branch + drift)
omnimem search "<query>" # Hybrid FTS5 + synonym + typo search
omnimem save <kind> <t> <c> # Manually store/pin a memory
omnimem forget <id|query> # Archive stale/wrong memory
omnimem restore <id...> # Restore an archived memory
omnimem timeline [dir] # Chronological cross-agent history
omnimem ingest-history [N] # Backfill last N transcripts per agent
omnimem sync-agents-md [dir] # Optional managed <!-- OMNI-MEM:START --> block in AGENTS.md
omnimem distill [dir] --force # Run optional LLM distiller on demand
```
## MCP Tools (Exposed to Antigravity, Claude Code & Codex)
`mem_search` · `mem_save` · `mem_timeline` · `mem_forget` · `mem_stats` · `mem_audit` · `mem_gc` · `mem_report` · `mem_sync_agents_md`
---
## Optional Detached LLM Distiller
Disabled by default (`0 ms` overhead, zero API keys required). To enable periodic background synthesis with local **Ollama** or any OpenAI/Anthropic-compatible endpoint, create `~/.omni-mem/config.json`:
```json
{
"distiller": {
"enabled": true,
"provider": "openai",
"baseUrl": "http://127.0.0.1:11434/v1",
"model": "qwen2.5-coder:7b",
"apiKeyEnv": "",
"minRawMemories": 6,
"cooldownMinutes": 60
}
}
```
---
## License
[MIT](./LICENSE) © 2026 Bruno Rainha
This server cannot be deployed
Maintenance
ActivityMaintained
ResponsivenessNo recent community issues