codex-substrate-memory

codex-substrate-memory

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.

Category
Visit Server

README

codex-substrate-memory

Public OpenAI Codex CLI plugin for durable Substrate organizational memory. It provides seven MCP tools, completed-turn capture through Codex's global notify hook, and a stale-rollout sweeper that emits content-free session boundaries.

Security requirement: ~/.codex/config.toml is world-readable plaintext. The Substrate API key must come from the Codex process environment. Never put SUBSTRATE_API_KEY in config.toml, an [mcp_servers.substrate.env] table, a command argument, or this repository.

Install

Python 3.11 or newer is required.

python -m pip install codex-substrate-memory

For a source checkout:

python -m pip install -e .

Set the service URL and API key in the environment that launches Codex:

SUBSTRATE_API_URL=https://api.substrate.example
SUBSTRATE_API_KEY=<set-in-process-environment>

Wire Codex

Codex plugins do not declare MCP servers in .codex-plugin/plugin.json. MCP registration lives only in the user's ~/.codex/config.toml.

Codex also has only one global notify setting. If no notify hook exists, use:

notify = ["python", "-m", "codex_memory.notify"]

[mcp_servers.substrate]
command = "python"
args = ["-m", "codex_memory.server"]
startup_timeout_sec = 30

If a notify hook already exists, preserve it with the chainer. Replace the placeholders with the existing command and arguments in the same order:

notify = ["python", "-m", "codex_memory.notify", "--chain", "<original-exe>", "<original-arg-1>"]

[mcp_servers.substrate]
command = "python"
args = ["-m", "codex_memory.server"]
startup_timeout_sec = 30

substrate-codex configure reads the current TOML and prints the appropriate snippet. It is advisory and does not modify the file. substrate-codex configure --write is the explicit opt-in mutation path and creates a backup first.

Tools

Tool Purpose
substrate_search Search organizational memory and return cited memory cards.
substrate_read Read one wiki page by repository-relative path.
substrate_query Ask a cited question across Substrate memory.
substrate_ingest Submit intended text for asynchronous ingestion.
substrate_remember Record a durable fact or decision.
substrate_sync Sweep stale rollouts and flush the local spool.
substrate_status Report content-free local configuration and delivery status.

Capture model

Completed turns

Codex appends one JSON argument to the global notify command after an agent-turn-complete event. codex_memory.notify extracts input-messages, last-assistant-message, turn_id, and cwd; applies the shared bounded redaction and event builder; durably queues the turn; and attempts delivery. Capture failures never block Codex. With --chain, the original notify command receives the identical final JSON argument and its exit code is propagated.

Session end

Codex does not emit a session-end notification. codex_memory.rollout therefore scans ~/.codex/sessions/**/rollout-*.jsonl for rollouts older than 15 minutes. It tolerates truncated final lines, unreadable files, and unknown record types. For each stale rollout it queues one deterministic, content-free session_end event containing counts and a message-index boundary only, then persists a one-shot checkpoint marker. The sweeper runs from substrate_sync and substrate-codex sync.

Codex limitations

  1. notify is a single global setting. Installing this plugin must not silently replace another hook. Use the documented --chain form to preserve the original executable, arguments, final JSON argument, and exit code.
  2. notify has no session-end event. Session closure is inferred only after a rollout file has been inactive past the sweeper threshold. It is not instantaneous.

Privacy boundary

  • API credentials are read from process environment variables only.
  • Captured messages are normalized, redacted, bounded, and spooled before network delivery.
  • The session-end sweeper sends no message text, rollout path, or working directory.
  • Local state defaults to ~/.substrate/codex_memory; SUBSTRATE_STATE_HOME overrides the parent directory for isolated environments.
  • Redaction cannot recognize every sensitive statement. Use a trusted Substrate server and protect local state.

CLI

substrate-codex serve
substrate-codex status
substrate-codex sync
substrate-codex configure

python -m codex_memory.server is the direct MCP entry point.

Repository map

  • .codex-plugin/plugin.json — Codex plugin metadata; intentionally no MCP registration.
  • skills/substrate-memory/SKILL.md — agent operating guidance.
  • src/codex_memory/ — Codex notify, rollout, configuration, CLI, and MCP integration.
  • src/substrate_capture/ — frozen shared capture core; do not edit.
  • docs/config-snippet.toml — placeholder-only configuration example.
  • tests/ — shared-core and Codex integration tests.
  • scripts/ — vendor-manifest and public-plugin safety verification.

Verification scope

The repository test suite exercises the notify shape and chainer, tolerant rollout parsing, one-shot session-end emission, configuration safety, and an in-memory MCP initialize/list/call round trip. It does not claim a live Codex-to-production-Substrate end-to-end run.

License

MIT © 2026 Sightline Technologies Inc.

Recommended Servers

playwright-mcp

playwright-mcp

A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.

Official
Featured
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.

Official
Featured
Local
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.

Official
Featured
Local
TypeScript
VeyraX MCP

VeyraX MCP

Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.

Official
Featured
Local
Kagi MCP Server

Kagi MCP Server

An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.

Official
Featured
Python
graphlit-mcp-server

graphlit-mcp-server

The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.

Official
Featured
TypeScript
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
Exa Search

Exa Search

A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.

Official
Featured
Qdrant Server

Qdrant Server

This repository is an example of how to create a MCP server for Qdrant, a vector search engine.

Official
Featured
E2B

E2B

Using MCP to run code via e2b.

Official
Featured