Project-specific MCPs

Resolved 💬 30 comments Opened Aug 23, 2025 by nick-youngblut Closed Jan 26, 2026
💡 Likely answer: A maintainer (LaelLuo, contributor) responded on this thread — see the highlighted reply below.

What feature would you like to see?

The mcp docs in the readme state:

The Codex CLI can be configured to leverage MCP servers by defining an mcp_servers section in ~/.codex/config.toml

So, there appears to be no way of setting up project specific MCP settings (e.g., using MCP server A in Project X via config in the Project X root location, while using MCP server B in Project Y).

Given the proliferation of MCP servers, and the difficulty of current models to handle large numbers of MCP tools, it is best to limit the MCP tools to only those required for the target project.

See Project Configuration in the Cursor docs for an example of project-specific MCP setups.

Are you interested in implementing this feature?

No

Additional information

_No response_

View original on GitHub ↗

30 Comments

noname-oni · 10 months ago

Definitely the issue. I think the whole workflow for managing and configuring MCPs should be enhanced.

alanwilhelm · 10 months ago

In CC lately I have been using --mcp-config=.claude/.mcp.json

It would be great to have the ability to just have a local json config for each project.

medeiroshudson · 10 months ago

Very important feat that Claude has, but Codex CLI doest not.
It would be very very useful in Codex

vaeho · 10 months ago

bump

theniceboy · 10 months ago

crucial feature

madtank · 10 months ago

Would love to see this. I've created an agent network, and I like to give them usernames. I also don't always want the same MCP server for every project. However having a global setting is great for common MCP servers, so don't remove that feature. Agreed here, mcp json files are nice, but can't share one with other agents so make it unique, but tbh, toml is better than a conflict with another agents config.

madtank · 10 months ago

This worked for me as a workaround:

export CODEX_HOME="$PWD/.codex"
ln -sfn ~/.codex/auth.json .codex/auth.json

This creates a project-level .codex/ directory. You’ll need to add a config.toml inside it with your MCP server configuration, for example:

[mcp_servers.myserver]
command = "npx"
args = ["-y", "some-mcp@latest", "--stdio"]

The symlink to ~/.codex/auth.json means you don’t have to re-authenticate in every project.
It’s a decent workaround until proper project-level config support is added.

jpcaparas · 10 months ago

This codex2 wrapper is handy in maintaining per-repository/per-project configs while we wait for OpenAI to officially support it.

# Paste into your ~/.bashrc, ~/.zshrc, etc.
codex2() {
  # If there's a project-local config (.codex/config.toml), use it as CODEX_HOME
  # and symlink your global auth.json into it so you don't need to re-auth.
  local project_codex_dir="$PWD/.codex"
  local project_config="$project_codex_dir/config.toml"
  local global_auth="${CODEX_GLOBAL_AUTH:-$HOME/.codex/auth.json}"

  if [ -f "$project_config" ]; then
    export CODEX_HOME="$project_codex_dir"

    # Ensure the local .codex directory exists (it should, but be safe)
    mkdir -p "$CODEX_HOME"

    # If you already have a global auth.json, mirror it into the project
    if [ -f "$global_auth" ]; then
      ln -sfn "$global_auth" "$CODEX_HOME/auth.json"
    else
      printf 'codex2: warning: no global auth found at %s; you may need to auth once.\n' "$global_auth" >&2
    fi
  fi

  # Proxy all args through to codex
  command codex "$@"
}
DevGuyRash · 10 months ago
This codex2 wrapper is handy in maintaining per-repository/per-project configs while we wait for OpenAI to officially support it. `` # Paste into your ~/.bashrc, ~/.zshrc, etc. codex2() { # If there's a project-local config (.codex/config.toml), use it as CODEX_HOME # and symlink your global auth.json into it so you don't need to re-auth. local project_codex_dir="$PWD/.codex" local project_config="$project_codex_dir/config.toml" local global_auth="${CODEX_GLOBAL_AUTH:-$HOME/.codex/auth.json}" if [ -f "$project_config" ]; then export CODEX_HOME="$project_codex_dir" # Ensure the local .codex directory exists (it should, but be safe) mkdir -p "$CODEX_HOME" # If you already have a global auth.json, mirror it into the project if [ -f "$global_auth" ]; then ln -sfn "$global_auth" "$CODEX_HOME/auth.json" else printf 'codex2: warning: no global auth found at %s; you may need to auth once.\n' "$global_auth" >&2 fi fi # Proxy all args through to codex command codex "$@" } ``

Had codex vibe code a script to do a bit more with all this:

https://gist.github.com/DevGuyRash/5340267a636de44d6c48ceb603f88846

Just run codex-wrapper --init.

lentil32 · 10 months ago

.envrc version:

project_codex_dir="$PWD/.codex"
project_config="$project_codex_dir/config.toml"
global_auth="${CODEX_GLOBAL_AUTH:-$HOME/.codex/auth.json}"

if [[ -f "$project_config" ]]; then
  export CODEX_HOME="$project_codex_dir"
  mkdir -p "$CODEX_HOME"
  if [[ -f "$global_auth" ]]; then
    ln -sfn "$global_auth" "$CODEX_HOME/auth.json"
  else
    printf 'codex2: warning: no global auth found at %s; you may need to auth once.\n' "$global_auth" >&2
  fi
fi

codex2_bin_dir="$(direnv_layout_dir)/bin"
mkdir -p "$codex2_bin_dir"

cat <<'WRAPPER' > "$codex2_bin_dir/codex2"
#!/usr/bin/env bash
exec codex "$@"
WRAPPER
chmod +x "$codex2_bin_dir/codex2"

PATH_add "$codex2_bin_dir"
xizhibei · 9 months ago

I think you'll find 1MCP useful. I recently encountered the same issue while using Codex: the inability to configure MCP servers on a per-project basis. That's why I developed the proxy and .1mcprc features in 1MCP, which allow you to configure just one 1MCP proxy command in Codex while using project-specific .1mcprc files to group and filter all available MCP servers.

Quick Example:

cd /you/awesome/project
echo '{"preset": "web-dev"}' > .1mcprc
# Codex config.toml (one-time setup)
[mcp_servers.1mcp]
command = "npx"
args = ["-y", "@1mcp/agent", "proxy"]

Now Codex automatically loads different MCP servers based on your project's .1mcprc file!

The complete integration documentation is available at: https://docs.1mcp.app/guide/integrations/codex. If you encounter any issues, feel free to provide feedback at: https://github.com/1mcp-app/agent/issues

nick-youngblut · 9 months ago

@xizhibei does 1mcp actually reduce context length and prevent context rot?

xizhibei · 9 months ago
@xizhibei does 1mcp actually reduce context length and prevent context rot?

@nick-youngblut Yes, below is the example I test with ClaudeCode:

.mcp.json under project root:

{
  "mcpServers": {
    "1mcp": {
      "type": "http",
      "url": "http://127.0.0.1:3050/mcp?preset=dev-backend"
    }
  }
}

Initial State: My dev-backend preset contains 3 servers (22 tools), occupying 7.5% of the context window.

# Complete preset configuration details and server list [simplified display]
$ 1mcp preset show dev-backend
# Shows: 3 servers matched, 22 tools available

> /context
  ⎿  ⛁ ⛀ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁   Context Usage
     ⛁ ⛁ ⛁ ⛁ ⛁ ⛀ ⛀ ⛁ ⛁ ⛁    claude-sonnet-4-5-20250929 • 39k/200k tokens (20%)
     ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶   ⛁ MCP tools: 15.0k tokens (7.5%)
     # [Detailed tool list and token usage statistics simplified for display]

Using the preset editor to streamline servers:

$ 1mcp preset edit dev-backend
# [Interactive TUI interface details simplified for display]
# Select only the context7 server needed
# Real-time preview: 1 server matched

After optimization: After reconnecting, the effect is immediate!

> /mcp reconnect 1mcp
> /context
  ⎿  ⛁ ⛀ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛀   Context Usage
     ⛁ ⛁ ⛁ ⛀ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶    claude-sonnet-4-5-20250929 • 28k/200k tokens (14%)
     ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶   ⛁ MCP tools: 2.3k tokens (1.1%)
     # [Streamlined tool list shows only 2 core tools]
alvinycheung · 9 months ago

This feature would be really useful.

LaelLuo contributor · 8 months ago

I actually submitted a PR (#3864) for this exact feature\! Unfortunately, it was closed since the team isn't accepting new features right now. Project-scoped MCP configuration is really needed - it prevents cluttering global config with project-specific tools. Really hope to see this implemented someday\! 👍

Omoeba · 5 months ago

Please implement this, it is a major limitation for an otherwise good harness.

etraut-openai contributor · 5 months ago

This should now work if you're using the Codex CLI. You can define a project-local .codex/config.toml file and specify project-specific settings like MCP servers. One caveat: project-local config.toml files are ignored if the project is not trusted.

We're still working on plumbing this feature through for the Codex IDE Extension. I'll keep this thread open until that's complete.

etraut-openai contributor · 5 months ago

This will be included in the next release of the IDE Extension! As I mentioned above, it has been implemented in the CLI for the past few releases.

vim-zz · 5 months ago

it stopped working for me with latest update, anyone else experience this?

etraut-openai contributor · 5 months ago

@vim-zz, project-local configs are ignored for untrusted projects. That might explain the behavior you're seeing.

pushpak1300 · 5 months ago

@etraut-openai is there any plan to add project level config via cli codex mcp add --project ?

codeaholicguy · 4 months ago

Does the local <project-root>/.codex/config.toml still work? I added this config but it doesn't load the mcp server, when I move it to ~/.codex/config.toml, it works as normal.

[mcp_servers.playwright]
command = "npx"
args = ["@playwright/mcp@latest"]
etraut-openai contributor · 4 months ago

@codeaholicguy, is your local project trusted? Codex will not load a local project config if it's an untrusted project.

codeaholicguy · 4 months ago

@etraut-openai yes, I have this config inside my ~/.codex/config.toml

[projects."<path>"]
trust_level = "trusted"

But let me try to remove and add it again. Thanks for the reply.

noname-oni · 4 months ago

@codeaholicguy does it help?

codeaholicguy · 4 months ago

yes, it worked after I removed and added again

findusl · 3 months ago

Note for others that might find this, the codex app can load MCP in the project specific config, but it will not show it with /MCP. You have to ask your model whether it can access the MCP. You can also see them grayed out under settings -> mcp in the codex app. The codex cli will correctly list the MCP

mesilov · 3 months ago

i have same problem =(

thekeith · 2 months ago

Jumping in here. This is a major issue.

For example, If you have different database endpoint MCPs for different clients or projects you have to rely on Codex permissions to scope to a chat instead of having it set at the project level. And while you can add it directly in .codex/config.toml and it shows up in settings giving the impression of it working, it clearly doesn't, causing agents to go in circles before the user gives up and uses ~/.codex/config.toml

This effectively breaks a core aspect of project-scoped tools.

etraut-openai contributor · 2 months ago

This is a closed issue. If you're seeing behavior that you think is a bug with the latest version of Codex, please open a new bug report and fill in all of the requested details in the bug report template. If you'd like to suggest new functionality, open a new feature request.