codex
@ghostpaw/codex
Local, evidence-backed memory for AI agents. One SQLite file, zero runtime dependencies.
Codex stores what an agent believes as claims with a source, a certainty, evidence counts, decay and an honest revision history. Agents search before they remember, confirm or correct instead of appending, and see which beliefs are stale, fading or weakly evidenced. It runs as a TypeScript library, an MCP server, a CLI and an Agent Skill, all generated from the same seven tools.
Website: ghostpaw.anonyfox.com/codex
Requires Node.js 24+ (uses the built-in node:sqlite).
30-second quickstart
MCP server
Every client below starts the same stdio server: npx -y @ghostpaw/codex mcp.
Beliefs live in ~/.ghostpaw/codex.db unless the GHOSTPAW_CODEX_DB
environment variable (absolute path) or --db <path> says otherwise.
Claude Code
claude mcp add ghostpaw-codex -- npx -y @ghostpaw/codex mcpor as a plugin, which also installs the skill:
/plugin marketplace add GhostPawJS/codex
/plugin install ghostpaw-codex@ghostpaw-codexCodex CLI (~/.codex/config.toml)
[mcp_servers.ghostpaw-codex]
command = "npx"
args = ["-y", "@ghostpaw/codex", "mcp"]Cursor (.cursor/mcp.json), Claude Desktop (claude_desktop_config.json)
or a project .mcp.json:
{
"mcpServers": {
"ghostpaw-codex": {
"command": "npx",
"args": ["-y", "@ghostpaw/codex", "mcp"]
}
}
}Claude Desktop users can also install server.mcpb from the
latest GitHub release.
A Dockerfile is included for container hosts:
docker build -t ghostpaw-codex . && docker run -i --rm -v codex:/data ghostpaw-codex.
The server speaks MCP 2026-07-28 (stateless, server/discover) and the
initialize-based revisions 2025-11-25, 2025-06-18, 2025-03-26 and 2024-11-05.
CLI
npx -y @ghostpaw/codex remember_belief --claim "Deploys go out on Tuesdays" --source explicit --category procedure
npx -y @ghostpaw/codex search_codex --query "when do we deploy"
npx -y @ghostpaw/codex tools # list tools
npx -y @ghostpaw/codex describe revise_beliefInstall globally for the ghostpaw-codex binary: npm i -g @ghostpaw/codex.
ghostpaw-codex mcp starts the stdio server.
Agent Skill
SKILL.md (repo root) and skills/codex/SKILL.md follow the
Agent Skills format and ship in the npm package.
Copy skills/codex/ into your agent's skills folder, or print it:
npx -y @ghostpaw/codex skill > SKILL.mdLibrary
npm install @ghostpaw/codeximport { DatabaseSync } from 'node:sqlite';
import { initCodexTables, read, write } from '@ghostpaw/codex';
const db = new DatabaseSync('codex.db');
initCodexTables(db);
const { id } = write.remember(db, {
claim: 'The API uses GraphQL with a REST fallback.',
source: 'explicit',
category: 'fact',
});
write.confirmBelief(db, id);
write.correctBelief(db, id, {
claim: 'The API uses GraphQL exclusively; REST was retired.',
source: 'observed',
category: 'fact',
});
read.recall(db, 'graphql api'); // ranked, lineage-aware
read.listFlags(db); // stale, fading, low-trust, single-evidenceWire the same tools into any LLM SDK. Each tool carries a JSON Schema:
import { tools } from '@ghostpaw/codex';
for (const tool of tools.codexTools) {
// tool.name, tool.description, tool.inputSchema, tool.handler(db, input)
}Or embed the MCP server in your own process:
import { createCodexMcpServer } from '@ghostpaw/codex/mcp';
const server = createCodexMcpServer({ dbPath: './codex.db' });Related MCP server: alaya
Why not MEMORY.md?
A markdown memory file works until it doesn't:
It only grows. Agents append, rarely delete, and the file ends up in every prompt. Codex returns the few beliefs that match a query (FTS5 plus local embeddings, fused by rank).
Contradictions pile up. "We use REST" and "REST was retired" sit side by side. Codex detects near-duplicates on every write, and corrections supersede the old belief while keeping the lineage.
Everything looks equally true. A guess and a confirmed fact read the same in prose. Codex tracks source (explicit, observed, distilled, inferred), certainty and evidence count, and flags what is stale or weakly supported.
No time. Codex decays freshness, so old beliefs surface for review instead of quietly steering behaviour.
Concurrent edits. Two agents writing one file clobber each other. Codex is a SQLite database in WAL mode.
It stays local: one file you can copy, back up or inspect with any SQLite tool. No server, no API key, no network.
Tools
Tool | What it does |
| Hybrid lexical and semantic recall across active beliefs |
| Dashboards: flags, status, trends, log |
| One belief in full: metrics, lineage, nearby beliefs |
| Capture a claim with source, category and provenance |
| Confirm, correct, forget, defer or merge |
| Hard-delete for privacy or cleanup |
| Mark two nearby beliefs as intentionally distinct |
Results are structured (outcome: success | no_op | needs_clarification | error) with entities, next-step hints and recovery advice. The MCP server,
CLI, SKILL.md and plugin manifests are generated from this registry
(npm run surfaces) and drift-checked in CI.
Performance
Measured with npm run bench on Node 24.14.0, Linux, Intel Xeon (shared
cloud vCPU), 10,000 beliefs in a file-backed database:
Operation | p50 | p95 |
| 4.0 ms | 4.6 ms |
MCP | 4.2 ms | 4.7 ms |
| 4.0 ms | 7.3 ms |
| 14.9 ms | 30.2 ms |
| 17.1 ms | 34.4 ms |
| 32.2 ms | 53.1 ms |
Cold start (process spawn to first response, median): --version 29 ms,
MCP server/discover 26 ms, first search against the 10,000-belief file
57 ms. Seeding 10,000 beliefs takes 2.2 s on disk.
Gzip sizes and cold-start medians are budgeted in budgets.json and enforced
by npm run check.
The model
Concept | Purpose |
Belief | A claim held with certainty, evidence, provenance, decay and revision lineage |
Dismissal | A record that two semantically close beliefs are intentionally distinct |
Flag | A derived attention signal: stale, fading, low-trust, single-evidence or gap |
Proximity | Semantic nearness between beliefs, detected on write |
Lineage | The revision chain from corrections and supersessions, with version diffs |
State is derived, never toggled: freshness, strength, review priority and flags are computed at read time.
Package surface
Import | Contents |
|
|
|
|
| CLI: tools, describe, call, per-tool flags, |
| Standalone stdio MCP server entry (used by the MCP Bundle and the Dockerfile) |
| Agent Skill with 17 workflow references |
ESM and CommonJS, with type declarations for both.
Documentation
Document | Audience |
Developers using the | |
Agent builders wiring | |
Architecture: model, invariants, scoring, source layout | |
Per-entity manuals with exact public API listings | |
Release history |
Development
npm install
npm run check # types, lint, zero-deps, tests, build, surfaces, size, API, consumer, startup, ratchet
npm run bench # hot-path benchmarks at 10,000 beliefs
npm run surfaces # regenerate SKILL.md, plugin manifests, server.json, mcpb manifestnpm run check is the single gate, locally and in CI. Size budgets
(budgets.json) and the public API snapshot (api-surface.json) can only
grow with an explicit approval tag in the commit message. The repo is pinned
to Node 24.14.0 via .nvmrc.
Support
If this package helps your project, consider sponsoring its maintenance:
This server cannot be deployed
Maintenance
Related MCP Connectors
Memory, reflection and safety for AI agents. Hosted or local, no vector database.
Persistent memory, hybrid search and a goal graph for AI agents, over stdio or remote HTTP.
Shared memory for AI agents, as a graph in your own Postgres. Writes never call an LLM.
Persistent memory for AI agents. Semantic search, memory graph, W3C DID identity.
Related MCP Servers
- AlicenseAqualityCmaintenancePersistent semantic memory for AI agents. SQLite-backed, local-first, zero config. Semantic search via Ollama embeddings with keyword fallback. Tools: remember, recall, history, forget, stats.1737 npm1MIT
- AlicenseNot gradedqualityDmaintenanceA local memory engine for AI agents. Stores conversation episodes, consolidates knowledge through a neuroscience-inspired lifecycle, and builds a personal knowledge graph — all in a local SQLite database.18MIT
- AlicenseAqualityBmaintenanceLocal-first memory engine for AI-agent teams: private/team/project ACL, associative recall, and federated sync across nodes. One SQLite file, no LLM required.127Apache 2.0
- AlicenseNot gradedqualityBmaintenanceProvides a zero-dependency SQLite memory layer for AI agents, letting them record lessons and work state, automatically test recurring patterns as hypotheses, and surface proven preferences during each session.47 PyPIMIT