Expand description
Bridge agent runtime/session environment variables across lean-ctx processes.
The lean-ctx MCP server is a long-lived child of the agent host. Some agents
(notably Codex) expose runtime/session variables such as CODEX_THREAD_ID
only in the native agent shell environment, not in the MCP server process
(#370). ctx_shell runs inside the MCP server, so it cannot forward those
variables by reading its own std::env.
Short-lived lean-ctx processes that do run inside the agent environment —
the hook handlers (lean-ctx hook …) and the lean-ctx -c shell wrapper —
capture the relevant variables into a small file in the data dir. The MCP
server then loads them when constructing the child environment for
ctx_shell (see crate::server::execute).
Constants§
- FORWARD_
PREFIXES - Env var name prefixes identifying agent runtime/session state worth forwarding
to
ctx_shellchild processes.
Functions§
- capture
- Capture forwardable variables from the current (agent) environment into the
data dir so the MCP server can forward them to
ctx_shellchildren. - collect_
from_ process - Forwardable variables present in the current process environment.
- is_
forwardable - Whether
keyis an agent runtime variable lean-ctx forwards to child shells. - load
- Load captured agent runtime variables, honoring the freshness TTL.