Codex Memory
Local Markdown-backed memory tools for Codex and other MCP-capable agents. Exposes durable agent knowledge via CLI and MCP server.
README
Codex Memory
Local Markdown-backed memory tools for Codex and other MCP-capable agents.
Codex Memory keeps durable agent knowledge in ordinary Markdown files, builds local indexes for retrieval, and exposes the result through both a CLI and an MCP server. It is designed for local-first use: your memory vault and session transcripts stay on your machine unless you share them yourself.
Features
- Markdown memory vault with simple YAML front matter.
- CLI commands for
doctor,write,read,search,reindex,hygiene, andweekly-hygiene. - MCP tools:
search_memory,read_memory,write_memory,reindex_memory, andmemory_hygiene. - Local keyword retrieval with SQLite and an optional Tantivy helper.
- Optional semantic retrieval when
CODEX_MEMORY_ENABLE_SEMANTIC=1. - Local browser tools for recent sessions, agent monitoring, and report-board drafting.
- Codex hook entrypoints for session-start context and stop-time candidate capture.
Install
Use Python 3.12 or newer.
python3 -m venv .venv
. .venv/bin/activate
pip install -e .
Build the optional Tantivy keyword helper:
cd rust/codex-memory-keyword
cargo build --release
The Python implementation still works without the helper, but keyword search is faster after it is built.
Quick Start
Copy the synthetic example vault to a writable location:
cp -R examples/memories /tmp/codex-memory-demo
Run the basic workflow:
PYTHONPATH=src python3 -m codex_memory --memory-root /tmp/codex-memory-demo doctor
PYTHONPATH=src python3 -m codex_memory --memory-root /tmp/codex-memory-demo reindex --force
PYTHONPATH=src python3 -m codex_memory --memory-root /tmp/codex-memory-demo search "demo workflow" --status active,risk_pending
PYTHONPATH=src python3 -m codex_memory --memory-root /tmp/codex-memory-demo hygiene
Create a new candidate memory:
PYTHONPATH=src python3 -m codex_memory --memory-root /tmp/codex-memory-demo write \
--title "Demo candidate" \
--body "A short note for later review." \
--keyword Codex
Configuration
Defaults are intentionally home-relative and overrideable:
CODEX_MEMORY_ROOT: memory vault root. Defaults to~/.codex/memories.CODEX_MEMORY_SERVICE_ROOT: source checkout root used to find the optional Rust keyword helper. Defaults to the repository root in editable installs.CODEX_MEMORY_ENABLE_SEMANTIC=1: enables semantic indexing/search.CODEX_MEMORY_TRANSCRIPT_ROOTS: extra transcript roots for session and hook tests, separated by the platform path separator.CODEX_MEMORY_PROJECT_SPECIFIC_TERMS: comma-separated local lint terms used to flag records that should be filed under a concrete project instead of a shared knowledge-base project.
Every CLI command also accepts --memory-root.
MCP Server
Start the MCP server with:
codex-memory-mcp
Example MCP client command configuration:
{
"command": "codex-memory-mcp",
"env": {
"CODEX_MEMORY_ROOT": "/absolute/path/to/your/memories"
}
}
Available MCP tools:
search_memory(query, project?, type?, status?, limit=5, mode?, diagnostics=false)read_memory(id_or_path)write_memory(record, update_id?)reindex_memory(force=false)memory_hygiene(stale_days=30)
status accepts comma-separated values such as active,risk_pending.
read_memory and write_memory reject absolute paths or .. traversal outside
the configured vault.
Local Browser Tools
All browser tools bind to 127.0.0.1 by default.
PYTHONPATH=src python3 -m codex_memory --memory-root /tmp/codex-memory-demo sessions ui --no-open
PYTHONPATH=src python3 -m codex_memory --memory-root /tmp/codex-memory-demo agents ui --no-open
PYTHONPATH=src python3 -m codex_memory --memory-root /tmp/codex-memory-demo reports ui --no-open
sessions uireads recent Codex JSONL transcripts from~/.codex/sessionsand any extraCODEX_MEMORY_TRANSCRIPT_ROOTS.agents uiderives parent/subagent status summaries from local transcripts.reports uisearches the memory vault, lets you select/edit candidate material, and exports Markdown underreport-board-output/.
These tools do not write transcripts, do not call external services, and do not publish a network-facing endpoint unless you explicitly bind them elsewhere.
Hooks
The package exposes two CLI hook commands:
codex-memory --memory-root /absolute/path/to/memories hook-session-start
codex-memory --memory-root /absolute/path/to/memories hook-stop
hook-session-start ensures the vault layout exists and returns compact startup
guidance. hook-stop reads an allowed local transcript and writes an inbox
candidate only when it sees reusable-experience signals such as blockers,
verified fixes, durable rules, or unresolved risks.
Memory Format
Records are Markdown files with front matter:
---
id: mem-demo-workflow
title: Demo workflow
project: demo-project
type: workflow
status: active
keywords:
- Codex
- demo
source: example
---
# Demo workflow
Use this record as searchable local context.
Supported type values are candidate, project_profile, long_term_rule,
issue, build_flow, protocol, script, hardware_risk, and workflow.
Supported status values are candidate, active, risk_pending, and
archived.
Privacy
Do not publish your real memory vault or session transcripts. This repository
contains only code and synthetic examples. See docs/privacy.md for the full
local-data boundary.
Development
Run the Python tests:
PYTHONPATH=src python3 -m unittest discover -s tests
Run the Rust helper tests:
cd rust/codex-memory-keyword
cargo test
Optional live-vault retrieval checks are skipped unless explicitly enabled:
CODEX_MEMORY_LIVE_GOLDEN=1 CODEX_MEMORY_LIVE_ROOT=/path/to/memories \
PYTHONPATH=src python3 -m unittest \
tests.test_markdown_store.MarkdownStoreTests.test_live_vault_golden_queries_when_enabled
License
MIT.
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。