Plugin MCP servers: no workspace/project-root signal (hooks have cwd; MCP servers don't)
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 125k
- Forks
- 19.5k
- PR merge metrics
- PR metrics pending
Description
Use case
A plugin ships a stdio MCP server that serves per-project data (in our case: a per-project knowledge index — the server must know which project the session is working in to serve the right one). Hooks can do this today: every hook payload carries cwd with the session working directory. Plugin MCP servers cannot.
Current behavior (codex-cli 0.146.0)
- A plugin-registered stdio MCP server with
"cwd": "."is spawned in the plugin's materialized cache directory (~/.codex/plugins/cache/<marketplace>/<plugin>/<version>/), soprocess.cwd()carries no project information. - No substitution token or injected environment variable exposes the workspace/session root to plugin MCP server configs (nothing analogous to hook payload
cwd;env_varsonly whitelists variables from the codex process environment, which requires a manual per-shell export). - The MCP client does not declare the
rootscapability, soroots/listis unavailable as an in-protocol signal (codex-rs/codex-mcp/src/rmcp_client.rsconstructs client capabilities withoutrootsas ofrust-v0.146.0).
The net effect: a plugin MCP server cannot be project-aware without asking users to export an environment variable in every shell before launching codex.
Ask
Any one of these would close the gap:
- A substitution token for plugin MCP server
env/argsvalues that resolves to the session workspace root (the equivalent of thecwdfield hooks already receive), or - An injected environment variable carrying the workspace root in the MCP server child process, or
- Declaring the
rootscapability and answeringroots/listwith the workspace folder.
Option 1 or 2 seems most consistent with the existing hook contract, and with the MCP spec's 2026-07-28 direction (Roots is deprecated there in favor of server configuration).
Environment
- codex-cli 0.146.0, macOS
- Plugin installed via
codex plugin addfrom a marketplace repo
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with codex-rs/codex-mcp/src/rmcp_client.rs and the plugin-registered stdio MCP server configuration, then compare the existing hook cwd payload with the MCP client capabilities. Trace how plugin cwd, env, and args are resolved. Done means a plugin MCP server can reliably receive the session workspace root through one supported mechanism.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- backend-api-design, cli
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100