An MCP server that lets Claude Code search your past AI coding conversations — across both OpenAI Codex CLI and Claude Code — so you can pull relevant context from previous sessions on demand.
Exposes three tools to Claude via the Model Context Protocol:
| Tool | What it does |
|---|---|
search_history |
Keyword search across all past sessions. Returns matching excerpts with surrounding context. |
list_sessions |
List all sessions with titles, dates, and message counts. |
get_session |
Retrieve the full conversation for a specific session. |
Example prompts you can use in Claude:
- "Search my history for CUDA illegal address"
- "Did I solve a similar sync issue before? Search for HMAC"
- "List my recent Codex sessions"
- "Get the full session where I fixed the GStreamer pipeline stall"
| Source | Location |
|---|---|
| OpenAI Codex CLI | ~/.codex/sessions/ |
| Claude Code | ~/.claude/projects/ |
Both are read-only. Nothing is uploaded anywhere — all search happens locally.
- Python 3.10+
- OpenAI Codex CLI and/or Claude Code with existing session history
pip install git+https://github.com/monishkumarvr/agent-history-mcp.gitgit clone https://github.com/monishkumarvr/agent-history-mcp.git
cd agent-history-mcp
pip install .Add to ~/.claude/.mcp.json (create the file if it doesn't exist):
{
"mcpServers": {
"agent-history": {
"command": "python3",
"args": ["-m", "codex_mcp"]
}
}
}That's it. Claude Code auto-launches the server when it starts.
Start Claude Code, then ask:
list my recent sessions
If you see a table of sessions, it's working.
By default the server auto-detects ~/.codex and ~/.claude. Override with environment variables if your paths differ:
{
"mcpServers": {
"agent-history": {
"command": "python3",
"args": ["-m", "codex_mcp"],
"env": {
"CODEX_PATH": "/custom/path/.codex",
"CLAUDE_PATH": "/custom/path/.claude"
}
}
}
}Once registered, the tools are available automatically in any Claude Code session. Claude will use them when relevant, or you can ask directly:
Search my history for "docker compose"
Search codex history for the redis migration
List my last 20 Claude sessions
Get session <id from list_sessions>
Use sources to narrow the search:
Search only Codex history for "pytest fixture"
Search only Claude history for "GStreamer pipeline"
- Read-only: the server never writes to disk
- Local-only: no network calls; the MCP server is a subprocess communicating over stdin/stdout
- No credentials accessed:
~/.codex/auth.jsonis never read - Conversations stay on your machine: excerpts are passed to Claude in your active session only, same as pasting text
Note: If you previously typed sensitive values (API keys, passwords, tokens) directly into a conversation,
search_historycould surface that text when Claude searches relevant terms. This is expected behaviour — it's your own history. Be mindful when sharing screen recordings or MCP logs.
Claude Code
↓ calls MCP tool (JSON-RPC over stdin/stdout)
agent-history server (python3 -m codex_mcp)
↓ reads JSONL files
~/.codex/sessions/**/*.jsonl (Codex CLI sessions)
~/.claude/projects/**/*.jsonl (Claude Code sessions)
↓ keyword search, deduplicate by session
Returns excerpts + context window to Claude
Token-efficient by design: search_history returns ~500 tokens of excerpts rather than injecting full sessions (which can be 200k+ tokens each).
codex_mcp/
├── __init__.py
├── __main__.py # python -m codex_mcp entry point
├── server.py # FastMCP server + 3 tools
├── parsers.py # Codex + Claude JSONL parsers → unified format
└── search.py # keyword search + result formatting
pyproject.toml
README.md
.gitignore
Issues and PRs welcome. The parsers are the most likely thing to need updates as Codex CLI and Claude Code evolve their session formats.
MIT