Skip to main content
Glama
Codex Native Memory

Codex Native Memory

by BulbuLbul86

Codex Native Memory

CI Python License: MIT

Local cross-session memory for Codex Desktop and Codex CLI.

NOTE

Codex is the primary coding AI. Claude, Gemini, and other tools are optional attached sources or review targets. If you only use Codex, there is nothing extra to configure.

The goal is deliberately narrow: import Codex transcript JSONL files, index them locally in SQLite, expose search through MCP, and optionally ask the local Codex CLI to summarize conversations. No Claude, Gemini, OpenRouter, or vendor API key is required. The summarizer uses the user's existing Codex/ChatGPT auth through codex exec.

Documentation

Related MCP server: memtree

How It Works

Codex transcripts -> local importer -> SQLite/FTS -> MCP tools -> Codex context

The architecture is Codex-first and project-centric. Codex is the primary coding shell and the default coding AI. Claude, Gemini, Cursor, Aider, or other AI systems can attach later as optional external sources or review targets. Codex-only mode is the normal default: if you do not use Claude, Gemini, or any other AI, there is nothing extra to configure. Imported sessions are stored with source_app and source_kind metadata so future external transcripts can flow into the same local project memory without taking over the main Codex workflow.

Status

This is an MVP. It already supports:

  • importing ~/.codex/sessions/**/*.jsonl;

  • SQLite storage with FTS5 search when available;

  • a stdio MCP server with search, import, recent sessions, and health tools;

  • project-oriented memory context with summaries, decisions, questions, and observations;

  • a dynamic project profile with preferences, constraints, warnings, and recent activity;

  • pinned manual memory items for durable user, project, and workflow rules, including update/delete and duplicate suppression;

  • JSON export/import for pinned memory backups and project-profile handoffs;

  • a bootstrap flow that imports recent memory, summarizes the queue, and returns context;

  • project candidate discovery for temporary Codex new-chat* workspaces;

  • queue processing with extractive summaries;

  • optional AI summaries through codex exec --ephemeral;

  • optional configurable external sources through sources.json;

  • optional review targets for Claude, Gemini, or generic external AI checks;

  • a Codex plugin manifest and helper scripts.

Planned adapter direction:

  • codex: current ~/.codex/sessions/**/*.jsonl importer;

  • claude: local Claude transcript/history importer;

  • gemini: local Gemini CLI/project history importer;

  • generic-jsonl: user-supplied transcript folders mapped into the canonical schema.

Codex always remains the default coding AI. If you only use Codex, skip this section. Later, Claude, Gemini, and other tools can attach to it as memory sources or optional review targets by pointing the plugin at their transcript paths:

python -m codex_native_memory sources list
python -m codex_native_memory sources add claude --type claude --path "$HOME\.claude\**\*.jsonl" --review-enabled
python -m codex_native_memory sources add gemini --type gemini --path "$HOME\.gemini\**\*.jsonl" --review-enabled
python -m codex_native_memory backfill --all-sources
python -m codex_native_memory sources review-options

Before using external AI review, check whether review targets are configured. If none are configured, keep review inside Codex and do not ask the user to connect external AI tools.

Quick start

For the annotated install flow, see docs/INSTALL.md.

Clone the repository and install the Python package in editable mode:

git clone https://github.com/BulbuLbul86/codex-native-memory.git
cd codex-native-memory
python -m pip install -e ".[dev]"

From the repository directory:

python -m codex_native_memory doctor
python -m codex_native_memory doctor --json
python -m codex_native_memory init
python -m codex_native_memory bootstrap "current task" --cwd "$PWD" --json
python -m codex_native_memory remember "Codex remains the primary coding AI." --cwd "$PWD"
python -m codex_native_memory revise 1 --text "Codex remains the primary coding AI for this project."
python -m codex_native_memory memories --cwd "$PWD"
python -m codex_native_memory export --cwd "$PWD" --output memory-export.json
python -m codex_native_memory import memory-export.json --cwd "$PWD"
python -m codex_native_memory backfill --limit 50
python -m codex_native_memory context "current task" --cwd "$PWD" --limit 5
python -m codex_native_memory search "VPN" --limit 5
python -m codex_native_memory process-queue --limit 5 --mode extractive

To expose it to Codex as MCP:

.\scripts\install-for-codex.ps1

On macOS/Linux:

./scripts/install-for-codex.sh

Restart Codex after installing the MCP entry. In Codex, a normal prompt such as подними память проекта should be enough for the skill to call memory_bootstrap. The CLI commands above are fallback and maintenance tools, not something users should memorize for daily use.

TIP

If Codex starts inside a temporarynew-chat* folder, memory_bootstrap can recommend the likely real project and return that project's context.

To attach Claude/Gemini sources interactively later:

.\scripts\configure-sources.ps1

Commands

doctor                       Show paths, Codex CLI discovery, and DB stats.
init                         Create the local SQLite database.
backfill                     Import changed transcript JSONL files.
watch                        Poll transcript files and import changes.
search <query>               Search messages, summaries, observations, and memories.
context [query]              Build project-oriented memory context.
bootstrap [query]            Import recent memory and return profile/context.
remember <text>              Store a pinned memory item.
revise <id>                  Update a pinned memory item.
memories                     List pinned memory items.
forget <id>                  Delete a pinned memory item.
export                       Export pinned memory and project profile JSON.
import [path]                Import pinned memory from an export JSON file/stdin.
process-queue                Summarize imported sessions.
mcp                          Run the MCP stdio server.

Development

python -m pip install -e ".[dev]"
python -m ruff check .
python -m compileall -q codex_native_memory
python -m unittest discover -s tests -v

See CONTRIBUTING.md, CHANGELOG.md, and SECURITY.md before publishing a public release.

export writes pinned memory. When scoped with --project or --cwd, it also includes a computed project profile for handoff context; unscoped exports omit the project profile because they may contain memory from multiple projects. Imported items carry an origin_key, so repeated imports update existing records even when the source memory text changed. Use --project or --cwd on import to move project/workflow memory into a new target project; user scope memory remains global.

Data defaults to %USERPROFILE%\.codex-native-memory. Override it with CODEX_NATIVE_MEMORY_HOME.

MCP tools

  • memory_search: search imported conversations.

  • memory_context: build project-oriented context from recent sessions, summaries, decisions, open questions, observations, and optional query matches.

  • memory_bootstrap: import recent memory, process pending summaries, and return a dynamic project profile plus memory_context output in one call. When the current cwd is a temporary Codex new-chat* workspace with little memory, the result also includes project_candidates and, when useful, recommended_profile/recommended_context for the likely real project.

  • memory_remember: store a pinned memory item for future bootstrap/context.

  • memory_notes: list pinned memory items for a project/cwd.

  • memory_update: update a pinned memory item by id.

  • memory_export: export pinned memory and computed project profile as JSON.

  • memory_import_bundle: import pinned memory from a memory_export bundle.

  • memory_forget: delete a pinned memory item by id.

  • memory_recent: list recent imported sessions.

  • memory_import: import changed Codex transcript files.

  • memory_sources: list attached sources and external review options.

  • memory_health: show DB, package, MCP wrapper, provider, and source health.

If a long-lived Codex thread reports that the MCP transport closed right after a plugin reinstall, check doctor/memory_health and retry in a fresh thread. The server uses JSON-lines stdio for Codex and opens SQLite lazily on the first tool call.

For common setup issues, see docs/TROUBLESHOOTING.md.

Search results are intentionally normalized around sessions, messages, summaries, and observations. External adapters should write into the same shape and keep their original source path/source app metadata for traceability.

Provider behavior

process-queue --mode codex calls the local Codex CLI like this:

codex exec --ephemeral --ignore-user-config --ignore-rules --sandbox read-only

The run is ephemeral, so it should not create recursive transcript files. The working directory is under the memory data directory and the command uses the existing Codex auth stored in CODEX_HOME.

Use --mode extractive for a fully local, no-model pass. Use --mode auto to try Codex and fall back to extractive summaries on failure.

Available Tools

13 tools
memory_bootstrapC

Import recent memory, summarize pending sessions, and return a dynamic project profile plus project-oriented context.

Inputs: cwd, force, query, project, +6 more.

memory_contextC

Build project-oriented memory context: summaries, decisions, open questions, observations, recent sessions, and optional query matches.

Inputs: cwd, limit, query, project.

memory_exportC

Export pinned memory and a computed project profile as a JSON bundle.

Inputs: cwd, limit, scope, project, +1 more.

memory_forgetB

Delete a pinned memory item by id.

Inputs: id (required).

memory_healthA

Show Codex Native Memory database health and counts.

Inputs: no named parameters.

memory_importC

Import changed Codex transcript JSONL files into memory.

Inputs: force, limit, source_id, all_sources.

memory_import_bundleC

Import pinned memory items from a memory_export JSON bundle. Provide payload or payload_json.

Inputs: cwd, source, payload, project, +1 more.

memory_notesB

List pinned memory items for a project/cwd, including global user memory.

Inputs: cwd, limit, scope, project.

memory_recentC

List recent imported Codex sessions.

Inputs: limit.

memory_rememberC

Store a pinned memory item for future Codex project bootstrap/context.

Inputs: text (required), cwd, scope, source, +3 more.

memory_sourcesC

List attached AI sources and external review targets.

Inputs: action.

memory_updateC

Update a pinned memory item by id.

Inputs: id (required), cwd, text, scope, +4 more.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    B3.1/5.0

    Scored across 13 tools

    Disambiguation5/5

    Each tool has a clearly distinct purpose: bootstrap and context handle project loading, import/export manage data transfer, remember/update/forget/notes cover CRUD on pinned items, search queries conversations, and sources lists AI attachments. No two tools overlap in functionality.

    Naming Consistency5/5

    All tools follow a consistent pattern: memory_ prefix with snake_case verb_noun (e.g., memory_remember, memory_import_bundle). No mixing of styles or irregular verbs.

    Tool Count4/5

    With 13 tools, the server covers a comprehensive range of memory operations without being bloated. It could potentially add a prune or merge tool, but the current count is well-scoped for a memory system.

    Completeness4/5

    The tool set provides full CRUD for pinned memory items, import/export, session bootstrap/context, search, and health monitoring. Minor gaps exist (e.g., no bulk delete), but the surface covers core workflows effectively.

    Maintenance

    ActivityInactive
    ResponsivenessOutdated data

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      C
      quality
      B
      maintenance
      Provides persistent, local-first AI memory across sessions via MCP tools for storing, searching, and retrieving context from past interactions.
      31
      668 PyPI
      1
      MIT
    • F
      license
      Not graded
      quality
      D
      maintenance
      Collects session JSONL from Codex and Claude Code into local SQLite memory, exposed through MCP with tools for memory context, search, get, put, forget, sleep, and status.
      -
    • A
      license
      Not graded
      quality
      C
      maintenance
      MCP server providing durable Substrate organizational memory tools, including search, read, query, ingest, remember, and sync. It integrates with Codex to automatically capture completed turns and session boundaries for persistent memory.
      MIT
    • A
      license
      A
      quality
      C
      maintenance
      Provides persistent, searchable memory for AI agents across any MCP-compatible client, storing project context, user preferences, and session learnings locally in SQLite with tools to save, retrieve, search, and manage them.
      12
      9 npm
      MIT