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
访问服务器

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.

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选