Codex Work Context is a small local CLI and MCP server that turns your local Codex session history into useful work context.
It answers questions like:
- Which repositories did I work on yesterday?
- What did I do in a specific repo last week?
- Can I export the raw Codex conversations for a given date range?
- Can an MCP client retrieve this context without reading my whole machine?
The project is read-only. It does not call OpenAI APIs, does not summarize with a model, and does not write back into your Codex data.
- Reads local Codex JSONL sessions from
~/.codex/sessionsand~/.codex/archived_sessions. - Filters conversations by local date or inclusive date range.
- Groups activity by Git repository or workspace.
- Handles forked sessions without replaying copied history from the parent thread.
- Omits retrospective/meta conversations by default when used through the raw MCP export.
- Omits transitional Codex progress messages by default, keeping user messages and final answers.
- Provides both a command-line interface and a read-only MCP server.
- Supports HTTP MCP clients and stdio MCP clients.
Codex stores local sessions as JSONL files under your Codex home directory. This tool scans those files, extracts user messages and Codex final answers inside a requested local date window, resolves each conversation to the closest Git repository, then renders the result as Markdown or MCP structured content.
The main data flow is:
~/.codex JSONL sessions
|
v
src/codexReader.mjs
|
v
date filtering + fork handling
|
v
src/workContext.mjs
|
v
repo grouping + optional repo filter
|
v
CLI Markdown output or MCP tool response
- Node.js 18 or newer
- npm
- A local Codex installation with session files under
~/.codex
Clone the repository, then install dependencies:
git clone https://github.com/Tomrun974/codex-work-context.git
cd codex-work-context
npm installList the repositories you worked in on one day:
node bin/codex-work-context.mjs list-repos --date 2026-04-28Export conversations for one day:
node bin/codex-work-context.mjs export --date 2026-04-28Export a date range:
node bin/codex-work-context.mjs export \
--start-date 2026-04-20 \
--end-date 2026-04-26Filter to one repository:
node bin/codex-work-context.mjs export \
--date 2026-04-28 \
--repo example-apiSave an export to a Markdown file:
node bin/codex-work-context.mjs export \
--date 2026-04-28 \
--output exports/2026-04-28.mdUse another Codex home directory:
node bin/codex-work-context.mjs list-repos \
--date 2026-04-28 \
--codex-home /path/to/.codexBy default, exports include user messages and Codex final answers only. To include Codex progress updates:
node bin/codex-work-context.mjs export \
--date 2026-04-28 \
--include-transitional-codex-messagescodex-work-context export --date YYYY-MM-DD [options]
codex-work-context export --start-date YYYY-MM-DD --end-date YYYY-MM-DD [options]
codex-work-context list-repos --date YYYY-MM-DD [options]
codex-work-context list-repos --start-date YYYY-MM-DD --end-date YYYY-MM-DD [options]
Options:
| Option | Description |
|---|---|
--date YYYY-MM-DD |
Export or list activity for one local date. |
--start-date YYYY-MM-DD |
Inclusive start date for a range. |
--end-date YYYY-MM-DD |
Inclusive end date for a range. |
--timezone TZ |
IANA timezone. Defaults to Europe/Paris. |
--repo TEXT |
Keep only repos whose name or path contains the filter text. |
--codex-home PATH |
Codex home directory. Defaults to ~/.codex. |
--max-chars N |
Truncate CLI export output to N characters. |
--output PATH |
Write the full Markdown export to a file. |
--include-transitional-codex-messages |
Include Codex progress messages, not only final answers. |
Start the local HTTP server:
npm startThe server listens on:
http://127.0.0.1:8787/mcp
Use a different port:
PORT=8788 npm startBy default, the server binds to 127.0.0.1. To expose it on another interface intentionally:
HOST=0.0.0.0 PORT=8788 npm startIf your MCP client needs an HTTPS URL, you can create a tunnel:
cloudflared tunnel --url http://localhost:8788Then configure the MCP client with the public HTTPS URL ending in /mcp.
Only do this when you understand the privacy implications. The server can expose local prompts, repo paths, and unfinished work.
For MCP clients that support stdio servers:
node bin/mcp-stdio.mjsExample stdio command configuration:
{
"command": "node",
"args": ["/absolute/path/to/codex-work-context/bin/mcp-stdio.mjs"]
}The MCP server exposes three read-only tools.
| Tool | Purpose |
|---|---|
get_local_date_context |
Returns local date context for a timezone: now, today, yesterday, start of week, and end of week. |
list_worked_repos |
Lists repos/workspaces with Codex activity during a date or date range. |
get_raw_codex_conversations |
Returns grouped Codex conversations for a date or date range. |
Use this before interpreting relative dates such as "today", "yesterday", or "this week".
Input:
{
"timezone": "Europe/Paris"
}Input:
{
"date": "2026-04-28",
"timezone": "Europe/Paris",
"repo": "optional-name-or-path-filter",
"codex_home": "~/.codex",
"include_transitional_codex_messages": false
}You can also use start_date and end_date instead of date.
Input:
{
"start_date": "2026-04-20",
"end_date": "2026-04-26",
"timezone": "Europe/Paris",
"repo": "optional-name-or-path-filter",
"max_chars": 180000,
"codex_home": "~/.codex",
"include_meta_conversations": false,
"include_transitional_codex_messages": false
}.
├── bin/
│ ├── codex-work-context.mjs # CLI entrypoint
│ ├── mcp-server.mjs # HTTP MCP server entrypoint
│ └── mcp-stdio.mjs # stdio MCP server entrypoint
├── src/
│ ├── codexExport.mjs # Public facade for CLI and MCP callers
│ ├── codexReader.mjs # Codex JSONL filesystem reader and parser
│ ├── dateWindow.mjs # Date/range normalization
│ ├── markdownRenderer.mjs # Markdown rendering and truncation
│ ├── mcpServer.mjs # MCP tool registration and HTTP app
│ └── workContext.mjs # Repo grouping and conversation filtering
├── test/
│ ├── codexExport.test.mjs
│ └── mcpTools.test.mjs
├── assets/
│ └── codex-logo.png
└── README.md
This tool reads local Codex conversations. Those conversations may contain:
- prompts
- repository paths
- debugging context
- copied code snippets
- unfinished work
- private notes
The MCP server is read-only, but it can still expose sensitive local content to whichever client can reach it.
Recommended precautions:
- Keep the HTTP server bound to
127.0.0.1unless you intentionally expose it. - Do not run it on a public network without authentication or access controls in front of it.
- Be careful with tunnels such as
cloudflared. - Review exports before sharing them.
- Keep
.env, logs, exports, and runtime databases out of Git.
Run tests:
npm testRun a dependency audit:
npm audit --audit-level=moderateCheck the CLI help:
node bin/codex-work-context.mjs --helpCheck that your Codex home exists and contains session files:
ls ~/.codex/sessionsIf your Codex data is stored elsewhere, pass --codex-home.
The CLI expects exact dates in YYYY-MM-DD format. MCP clients should call get_local_date_context before converting relative requests like "today" or "yesterday" into exact dates.
Increase --max-chars or write the full export to a file with --output.
That is the default:
127.0.0.1:8787
Set HOST=0.0.0.0 only when you intentionally want other machines or a tunnel to reach it.
MIT