Per-project MCP server configuration in .codex/config.toml or mcp.json (avoid wrapper scripts)
What variant of Codex are you using?
Codex CLI (with project-level .codex/config.toml)
What feature would you like to see?
I’d like first-class support for configuring MCP servers per project/directory, either in .codex/config.toml and/or via mcp.json.
Today, the current config level is not enough for workflows where MCP servers need to be started with directory-specific context. Tools like ai-mate use a per-directory MCP server model, but in Codex this is hard to express cleanly.
Current workaround: wrapper scripts that inject the project path or dynamic context before launching the MCP server. This works, but it adds setup complexity and is not a great UX.
A concrete example is this Symfony AI integration PR, which needed a wrapper-based approach:
https://github.com/symfony/ai/pull/1682
Requested outcome:
- Allow native per-project/directory MCP server configuration.
- Support this cleanly through
.codex/config.tomland/ormcp.json. - Remove the need for wrapper scripts in common integrations.
- Make MCP behavior more predictable and ergonomic across projects.
This came up in the PR discussion here (which was closed):
https://github.com/openai/codex/pull/12718
I understand why that PR was closed, but I think this use case still needs a proper configuration-level solution.
Additional information
If helpful, I can propose concrete config shape options (for example, project-scoped server entries, per-workspace overrides, or variable interpolation for the current directory) and help test them against real integrations.
5 Comments
Potential duplicates detected. Please review them and close your issue if it is a duplicate.
Powered by Codex Action
Per-Project MCP Configuration - Design Patterns
Strong +1 for this. Having worked with MCP integrations across multiple agent frameworks, the wrapper-script workaround is a real pain point. Here are some patterns that could work well:
1. Config Shape Options
Option A: Direct
.codex/config.tomlextensionOption B: Separate
mcp.json(VSCode-style)2. Variable Interpolation (Critical)
Key variables to support:
${workspaceFolder}- Project root${cwd}- Current working directory${env:VAR_NAME}- Host environment variables${file}- Currently focused file (if applicable)3. Lifecycle Considerations
MCP servers often need different lifecycles:
4. Config Precedence
Recommend clear layering:
.codex/config.toml(highest priority)~/.codex/config.tomlWith explicit merge strategy (
overridevsextend).5. Real-World Use Case
Framework integrations (Symfony, Rails, Django) need this badly. Each framework has its own context (routes, models, services) that an MCP server should understand. Currently everyone builds wrapper scripts like:
This would be cleaner as native config with
${workspaceFolder}.Happy to help test against real integrations if you ship an experimental flag!
---
Building AI integrations at RevolutionAI - we hit this pattern constantly with client projects.
From what I can tell,
.mcp.jsonhas become the most common standard for project-level MCP. Projects are willing to absorb a.mcp.jsonin their repos, but they're not gonna be willing to have different configuration mechanisms for every different agent.I think it'd be essential for Codex to adopt picking up project-level
.mcp.jsonsooner than later, I've already seen people dismiss Codex entirely simply over not supporting this.This would be very useful for our workflow as well.
At work we rely heavily on project-local
.mcp.jsonfiles with Claude Code to connect coding agents to app-development MCP servers.A concrete example is Tidewave MCP in Elixir/Phoenix projects, which exposes development capabilities such as fetching logs, evaluating code in the app context, running queries, and inspecting runtime state.
This already works in Codex when configured manually through
config.toml, but in our case we have many microservices/MVPs and each service may expose its MCP server on a different local port. With ~20 services, maintaining those MCP entries globally or manually editing ports becomes painful.Project-local
.mcp.jsonsupport would let each service declare its own MCP endpoint next to the codebase. Codex could detect it, ask for approval in the TUI, and connect to it for that workspace.Trusted project
.codex/config.tomlfiles now support MCP servers.