Where AI tools store MCP server credentials: a plaintext secrets audit
Where 9 MCP clients keep server API keys and OAuth tokens: config paths, project files, env var syntax, and which use the OS keychain.
MCP (Model Context Protocol) servers connect AI tools to GitHub, databases, ticketing systems and other services. Those connections need API keys or OAuth tokens. This audit covers nine MCP clients. For each one it asks where server config is written, whether a project-level file can end up in git, how to reference a secret instead of pasting it, and where OAuth tokens land on disk.
We read source code for the open-source clients and official documentation for the closed ones. We did not run any client, so treat this as a map of documented and coded behaviour to check against your own installation.
Summary: where do MCP credentials live?
| Client | Evidence | User-level config | Project-level file | Reference a secret instead of pasting it | MCP OAuth token storage |
|---|---|---|---|---|---|
| Claude Desktop | Docs | claude_desktop_config.json (per-OS path below) | None documented | None documented; extensions keep sensitive fields in the OS keychain | Not documented |
| Claude Code | Docs, changelog | ~/.claude.json (local and user scopes) | .mcp.json | ${VAR}, ${VAR:-default} | macOS keychain; client secrets in keychain (macOS) or a credentials file |
| Cursor | Docs | ~/.cursor/mcp.json | .cursor/mcp.json | ${env:NAME}; envFile (stdio) | Not documented |
| VS Code / Copilot | Docs, VS Code source | ~/.copilot/mcp-config.json; profile mcp.json | .vscode/mcp.json; workspace-root .mcp.json | ${env:NAME}, ${input:id}, envFile (VS Code format); ${NAME} (portable format) | VS Code SecretStorage (encrypted) |
| Gemini CLI | Source e5d88fb | ~/.gemini/settings.json | .gemini/settings.json (default for gemini mcp add) | $VAR, ${VAR}; %VAR% on Windows | Plaintext ~/.gemini/mcp-oauth-tokens.json (0600) by default; keychain opt-in |
| Codex CLI | Source 4f8205c, docs | ~/.codex/config.toml | .codex/config.toml (trusted projects) | env_vars, bearer_token_env_var, env_http_headers | OS keyring; fallback ~/.codex/.credentials.json (0600) |
| Cline | Source c5df41f | ~/.cline/data/settings/cline_mcp_settings.json | None | ${env:VAR} (VS Code extension) | Same settings file, oauth key, plain JSON |
| Continue | Source 5522c6f (Jul 20, 2026) | ~/.continue/config.yaml (config.json legacy) | .continue/mcpServers/ | ${{ secrets.NAME }} from .env files or Continue Hub | ~/.continue/index/globalContext.json, plain JSON |
| Zed | Source 985bbf4, docs | ~/.config/zed/settings.json (context_servers) | .zed/settings.json (Restricted Mode until trusted) | None documented | System keychain (release builds) |
The risk: a literal token in a config file
Most MCP server READMEs ask you to add an entry like this:
{ "mcpServers": { "github": { "command": "npx", "args": ["-y", "@modelcontextprotocol/server-github"], "env": { "GITHUB_PERSONAL_ACCESS_TOKEN": "<YOUR_TOKEN>" } } }}That exact <YOUR_TOKEN> pattern comes from the archived reference GitHub server. Once you replace the placeholder with a real token, the token is:
- Readable by any process running as your user, including a compromised npm package or a malicious MCP server.
- Copied wherever the file goes: Time Machine and other backups, dotfile repositories, settings sync.
- One
git add .away from a commit, if the file lives inside a project.
Detailed findings by client
Claude Desktop
Config location (from the official MCP guide):
- macOS:
~/Library/Application Support/Claude/claude_desktop_config.json - Windows:
%APPDATA%\Claude\claude_desktop_config.json - Linux:
~/.config/Claude/claude_desktop_config.json
Servers are listed under mcpServers, each with command, args and an optional env block. The Connect to local MCP servers guide walks through the filesystem server, which needs no key. Its Windows troubleshooting example puts a key straight into env as "BRAVE_API_KEY": "...".
Referencing secrets: No environment-variable interpolation is documented for this file.
Desktop extensions: Anthropic’s Desktop Extensions announcement says that for one-click extensions, “Sensitive configuration like API keys are stored in the OS keychain”. For servers available as extensions, that is the only documented way to keep a key out of claude_desktop_config.json.
OAuth token storage and file permissions: Not documented.
Claude Code
Config locations (Claude Code MCP docs):
- Local scope (the default):
~/.claude.json, under the current project’s entry, private to you. - User scope:
~/.claude.json, available in all projects. - Project scope:
.mcp.jsonat the project root, meant to be committed.
The docs recommend local scope for “servers with credentials you don’t want in version control.”
Referencing secrets: Claude Code expands ${VAR} and ${VAR:-default} in a server’s command, args, env, url and headers:
{ "mcpServers": { "api-server": { "type": "http", "url": "${API_BASE_URL:-https://api.example.com}/mcp", "headers": { "Authorization": "Bearer ${API_KEY}" } } }}If a variable is unset and has no default, Claude Code warns and leaves the ${VAR} text in place.
The --env trap: claude mcp add --env KEY=value stores whatever value it receives. The docs’ own example is --env AIRTABLE_API_KEY=YOUR_KEY. If you type --env GITHUB_TOKEN=$GITHUB_TOKEN, your shell substitutes the real token before Claude Code runs, so the token itself is saved in ~/.claude.json, or in .mcp.json with --scope project. To keep a reference, use claude mcp add-json with single quotes so the shell leaves ${GITHUB_TOKEN} alone, or edit .mcp.json directly.
OAuth token storage: The MCP docs say only that “Authentication tokens are stored securely and refreshed automatically.” The Claude Code changelog for v2.1.281 says Anthropic “Fixed macOS credential writes dropping stored MCP OAuth tokens or deleting the keychain entry”, which places those tokens in the macOS keychain. For confidential OAuth clients, the docs say “The client secret is stored securely in your system keychain (macOS) or a credentials file, not in your config”. Claude Code’s own login credentials go to the macOS Keychain, or to ~/.claude/.credentials.json with mode 0600 on Linux.
Project approvals: Claude Code asks for approval before using servers from a project’s .mcp.json. A cloned repository can’t approve its own servers: approval settings committed to the project’s .claude/settings.json are ignored until you trust the folder.
Removing credentials: claude mcp remove deletes the stored OAuth tokens but “doesn’t revoke the tokens at the authorization server”. Run claude mcp logout <name> first if you want them revoked.
Cursor
Config locations (Cursor MCP docs): ~/.cursor/mcp.json (global) and .cursor/mcp.json (project).
Referencing secrets: Cursor resolves variables in command, args, env, url and headers:
${env:NAME}: environment variable${userHome},${workspaceFolder},${workspaceFolderBasename},${pathSeparator}/${/}: paths
{ "mcpServers": { "remote-server": { "url": "https://api.example.com/mcp", "headers": { "Authorization": "Bearer ${env:MY_SERVICE_TOKEN}" } } }}Stdio servers can also load variables from a file with envFile. Remote servers can’t.
Static OAuth credentials: Remote servers can take an auth block with CLIENT_ID, CLIENT_SECRET and scopes. The docs advise: “Use environment variables for Client ID and Client Secret instead of hardcoding them.”
Mixed messages in the docs: The first mcp.json examples on the same page use literal values ("API_KEY": "value"), while the FAQ says “Use environment variables for secrets, never hardcode them.”
OAuth token storage: Cursor supports OAuth with PKCE for SSE and Streamable HTTP servers, but the docs don’t say where tokens are stored on your machine. They do say Cloud Agents keep their own MCP sign-ins on Cursor’s servers, separate from your local ones.
VS Code / GitHub Copilot
VS Code now supports two config formats with different capabilities (MCP configuration reference):
VS Code format (.vscode/mcp.json, profile mcp.json) | Portable format (workspace-root .mcp.json, ~/.copilot/mcp-config.json) | |
|---|---|---|
| Top-level key | servers | mcpServers |
| Env references | ${env:NAME} | ${NAME} or ${NAME:-default} |
Input variables (${input:id}) | Yes | No |
envFile | Yes | No |
The setup guide says Copilot Global config goes to $COPILOT_HOME/mcp-config.json, or ~/.copilot/mcp-config.json when COPILOT_HOME is unset. It labels .vscode/mcp.json and the profile mcp.json as kept “for compatibility” and marked deprecated in the guided flow.
Prompted secrets: In the VS Code format, an input variable prompts you when the server first starts, and the reference says “The value is then securely stored for subsequent use.” The input type is promptString, and password: true hides what you type:
{ "inputs": [ { "type": "promptString", "id": "perplexity-key", "description": "Perplexity API Key", "password": true } ], "servers": { "perplexity": { "type": "stdio", "command": "npx", "args": ["-y", "server-perplexity-ask"], "env": { "PERPLEXITY_API_KEY": "${input:perplexity-key}" } } }}The catch, quoted from the docs: “Portable configurations don’t support VS Code input variables or environment files. Servers requiring interactive inputs aren’t forwarded to Copilot harness sessions.”
OAuth: The reference says a confidential client’s secret “is not part of mcp.json” and that “VS Code keeps the secret in its secret storage.” In VS Code’s open-source core, dynamic MCP OAuth sessions are written to SecretStorage. The extension API docs say SecretStorage contents are “stored encrypted” and not synced across machines.
Copilot connectors (preview) provide “GitHub-managed MCP connections for Copilot harness sessions without local server setup or manual MCP configuration.”
The docs’ own guidance is blunt: “A personal configuration file is not a secret store.”
Gemini CLI
Config locations: ~/.gemini/settings.json (user) and .gemini/settings.json (project), both under mcpServers (MCP server docs).
Default scope is the project: gemini mcp add has --scope with “[default: “project”]” (source). The documented example is gemini mcp add -e API_KEY=123 .... Run as written inside a repository, that puts the key in .gemini/settings.json in the repository.
Referencing secrets: Values in the env block can use $VAR or ${VAR} on all platforms and %VAR% on Windows. Unset variables become empty strings. Expansion runs through the dotenv-expand library (source), which also handles ${VAR:-default}, though Gemini’s docs don’t mention that form. The GitHub tutorial uses this pattern so that, in its words, “your secret isn’t hardcoded in the config file”:
"env": { "GITHUB_PERSONAL_ACCESS_TOKEN": "${GITHUB_PERSONAL_ACCESS_TOKEN}"}OAuth token storage: The default is a plaintext file, not the keychain. In oauth-token-storage.ts, the keychain-backed HybridTokenStorage is used only when GEMINI_FORCE_ENCRYPTED_FILE_STORAGE is true. Otherwise tokens are written as JSON to ~/.gemini/mcp-oauth-tokens.json with { mode: 0o600 } (path from storage.ts; the docs call this “Stored securely”). With the opt-in variable set, Gemini CLI tries the OS keychain via @github/keytar. If none is usable, as is common on headless Linux and WSL, it falls back to ~/.gemini/gemini-credentials.json, encrypted with AES-256-GCM. The key is derived from the hostname and username, so the encryption mainly guards against casual reading.
Node applies mode only when it creates a file. A token file that already existed with looser permissions keeps them.
OpenAI Codex CLI
Config locations (Codex MCP docs): ~/.codex/config.toml, or “a project-scoped .codex/config.toml (trusted projects only)”. The Codex CLI, IDE extension and ChatGPT desktop app share this configuration.
[mcp_servers.figma]url = "https://mcp.figma.com/mcp"bearer_token_env_var = "FIGMA_OAUTH_TOKEN"Referencing secrets: Codex doesn’t interpolate ${VAR} inside values. Instead you name variables:
env_vars = ["LOCAL_TOKEN"]forwards variables from your environment to a stdio server.bearer_token_env_varnames the variable that holds an HTTP bearer token.env_http_headersmaps header names to environment variable names.
The env table and http_headers take literal values. codex mcp add --env VAR1=VALUE1 writes into that env table, so a shell-expanded $TOKEN lands in config.toml. The docs also note that --oauth-client-secret is saved as mcp_servers.<name>.oauth.client_secret in config.toml: “Keep that file private and out of version control.”
OAuth token storage: The setting is mcp_oauth_credentials_store, with values auto | file | keyring (config reference). The source types.rs documents each mode:
auto(default): “PreferKeyringand useFilewhen keyring storage is unavailable.”file:CODEX_HOME/.credentials.json, which “will be readable to Codex and other applications running as the same user.”keyring: “Keyring when available, otherwise fail.”
On macOS and Linux the keyring backend stores the token directly in the OS keyring. On Windows the default backend keeps credentials in a local encrypted secrets file whose key lives in the OS keyring. The fallback file is opened with mode 0600, and its permissions are reset to 0600 on every write (oauth.rs). Keyring entries are keyed by the server’s URL.
Cline
Config location: Current Cline keeps MCP servers in one shared file, ~/.cline/data/settings/cline_mcp_settings.json, used by the VS Code extension, the CLI and JetBrains. CLINE_DIR, CLINE_DATA_DIR or CLINE_MCP_SETTINGS_PATH can override the location. Older versions kept cline_mcp_settings.json in VS Code’s extension storage (globalStorage/saoudrizwan.claude-dev/settings/) or ~/Documents/Cline/MCP/, and the extension migrates those files to the new path.
Referencing secrets: The VS Code extension expands ${env:VAR} in server config (envExpansion.ts). An unset variable is left unexpanded and logged as a warning.
OAuth token storage: OAuth tokens go into the same settings file. The header of McpOAuthManager.ts reads: “MCP OAuth state is stored in the shared MCP settings file (~/.cline/data/settings/cline_mcp_settings.json) under each server’s oauth key”. The extension migrates tokens out of its older VS Code secret store (mcpOAuthSecrets) into this file. The shared writer (config-loader.ts) writes atomically but sets no file mode, so permissions follow your umask, commonly 0644 on macOS and Linux.
Continue
The latest commit on Continue’s main branch when we checked was July 20, 2026.
Config locations: ~/.continue/config.yaml, with config.json as the legacy format. Per-project servers can go in .continue/mcpServers/ at the workspace root (MCP docs).
Referencing secrets: The docs use ${{ secrets.NAME }} templates:
mcpServers: - name: GitHub command: npx args: ["-y", "@modelcontextprotocol/server-github"] env: GITHUB_PERSONAL_ACCESS_TOKEN: ${{ secrets.GITHUB_PERSONAL_ACCESS_TOKEN }}For local configs, LocalPlatformClient.ts checks ~/.continue/.env, then .continue/.env in the workspace, then a workspace .env, and finally the process environment. Continue Hub secrets are another source. If a secret can’t be resolved, Continue reports an error that points you to the secrets page in Continue Hub.
OAuth token storage: Continue supports MCP OAuth for SSE servers only (code comment: “currently support oauth for sse transports only”). MCPOauth.ts saves tokens, client registration and PKCE verifier under mcpOauthStorage in Continue’s global context file, ~/.continue/index/globalContext.json (GlobalContext.ts). That file is plain JSON written with fs.writeFileSync and no explicit mode.
An apiKey field on a server is turned into an Authorization: Bearer header.
Zed
Config location (Zed MCP docs): the context_servers block of your settings file (~/.config/zed/settings.json on Linux and macOS). Zed’s settings schema also accepts context_servers in a project’s .zed/settings.json. Per the worktree trust docs, new projects open in Restricted Mode, which stops MCP servers from project settings from being installed and started until you trust the project.
{ "context_servers": { "remote-mcp-server": { "url": "https://example.com/mcp", "headers": { "Authorization": "Bearer <token>" } }, "remote-mcp-server-with-oauth": { "url": "https://mcp.example.com/mcp" } }}Referencing secrets: The docs describe no environment-variable interpolation for env or headers, and we found no expansion code in the context-server settings path. Values are used as written.
OAuth: “When a remote MCP server has no configured "Authorization" header, Zed will prompt you to authenticate yourself against the MCP server using the standard MCP OAuth flow.” The resulting session is written to the system keychain, keyed by server URL (context_server_store.rs). Development builds use a file-based credentials provider unless ZED_DEVELOPMENT_USE_KEYCHAIN is set; Stable, Preview and Nightly use the keychain (zed_credentials_provider.rs).
What setup instructions actually show
Some official examples teach good habits and others leave a token on disk.
- GitHub MCP server, current README (github/github-mcp-server): The VS Code examples use
${input:github_token}andBearer ${input:github_mcp_pat}. The README warns that “Some applications (like Windsurf) require hardcoded tokens in config files”. Its build-from-source example uses"GITHUB_PERSONAL_ACCESS_TOKEN": "<YOUR_TOKEN>". Its Claude example,claude mcp add github -e GITHUB_PERSONAL_ACCESS_TOKEN=$GITHUB_PAT ..., is presented as referencing the token, but the shell expands$GITHUB_PATfirst, so the token value is what gets saved. - Archived reference GitHub server (
@modelcontextprotocol/server-github, now deprecated): Its examples use"<YOUR_TOKEN>"placeholders inenv. - Client docs: Cursor shows
"API_KEY": "value", Claude Code shows--env AIRTABLE_API_KEY=YOUR_KEY, Gemini CLI shows-e API_KEY=123and-H "Authorization: Bearer abc123", and Zed shows"Bearer <token>". - Good counter-examples: Gemini CLI’s GitHub tutorial uses
${GITHUB_PERSONAL_ACCESS_TOKEN}, VS Code’s reference usespassword: trueinputs, and Codex’s docs usebearer_token_env_var.
Practical hardening steps
For all clients
- Reference secrets with your client’s own syntax (see the summary table). They are not interchangeable: Cursor wants
${env:NAME}, Claude Code and Gemini want${NAME}, and Codex wants a variable name inenv_varsorbearer_token_env_var. - Don’t rely on
$VARin a shell command to keep a secret out of config. Single-quote it, or edit the file directly. - Check which file a CLI writes to.
gemini mcp adddefaults to the project, andclaude mcp add --scope projectwrites.mcp.json. - Ignore project config files that hold literal secrets, or better, switch them to references and commit them:
.cursor/mcp.json.mcp.json.vscode/mcp.json.gemini/settings.json.codex/config.toml.continue/mcpServers/.zed/settings.json
- Search git history for MCP config files. Note that
**/.mcp.jsonmisses a root-level.mcp.jsonin git’s default pathspec matching. This form matches root and nested files:Terminal window git log --all -p -- '*mcp.json' '*mcp-config.json' '.gemini/settings.json' '.codex/config.toml' '.zed/settings.json' '.continue/mcpServers/*' - Prefer OAuth where the server supports it, in a client that keeps tokens in the keychain. OAuth tokens are usually scoped and short-lived, and can be revoked without rotating a long-lived key.
Claude Code
- Add servers with JSON that keeps the reference intact:
Terminal window claude mcp add-json github '{"command":"npx","args":["-y","@modelcontextprotocol/server-github"],"env":{"GITHUB_PERSONAL_ACCESS_TOKEN":"${GITHUB_TOKEN}"}}' - Run
claude mcp logout <name>beforeclaude mcp remove <name>to revoke tokens at the authorization server.
Gemini CLI
- Pass
--scope usertogemini mcp addunless you mean to share the server with the repository. - Check
~/.gemini/mcp-oauth-tokens.json. If it exists, your MCP OAuth tokens are in plaintext, which is the default. SetGEMINI_FORCE_ENCRYPTED_FILE_STORAGE=trueto use the keychain instead. We found no code that migrates existing tokens, so expect to sign in to each server again.
Codex CLI
- Set
mcp_oauth_credentials_store = "keyring"in~/.codex/config.tomlif you’d rather fail than fall back to~/.codex/.credentials.json. - Use
env_varsandbearer_token_env_varinstead of literalenvorhttp_headersvalues.
VS Code
- Use
promptStringinputs withpassword: truefor keys in.vscode/mcp.json, and${NAME}references in portable.mcp.jsonfiles.
Cline and Continue
- Treat
~/.cline/data/settings/cline_mcp_settings.jsonand~/.continue/index/globalContext.jsonas credential files. On shared machines,chmod 600them.
What config hygiene doesn’t fix
- The running process still holds the secret. Once a server starts, the token is in its environment. On Linux,
/proc/<pid>/environcan be read by processes running as the same user, and by root. - MCP servers can log what they receive.
- Tool output enters the model’s context. If an MCP tool returns a secret, or an agent reads a config file, that value becomes part of the prompt sent to the model provider.
- The
.envfile you moved the secret into is still a plaintext file that backups copy.
Where Shadow fits
Shadow replaces secrets with reversible fakes in AI request traffic before prompts leave your machine. Shadow can mask traffic from Claude Code, Codex CLI, Gemini CLI and GitHub Copilot, and from Cline and Continue when you use your own API keys. For those tools, a secret that Shadow detects in a prompt does not reach the model provider. That covers point 3 above, for example when an agent reads .mcp.json or an MCP tool echoes a token. Cursor uses a binary protocol, so Shadow recognizes its traffic but cannot mask it.
What Shadow doesn’t do: Shadow works on model traffic, not on files or on the MCP server’s own connections. It doesn’t encrypt mcp.json, config.toml or OAuth token files. It doesn’t touch the token an MCP server sends to GitHub or your database. Protecting those files still depends on the reference, scope and permission practices above.
Limitations of this research
- We read code and docs; we did not install or run any client or inspect the files it created.
- For closed-source clients (Claude Desktop, Claude Code, Cursor, VS Code with Copilot), we relied on official documentation and public changelogs. Where docs are silent, we say “not documented” rather than guess.
- Source findings are tied to the commits listed. Continue’s latest commit is from July 2026; the other repositories were current as of November 11, 2026.
- File permissions follow your umask wherever a client sets no explicit mode, and differ on Windows.
- Paths can change with environment-variable overrides (
CLAUDE_CONFIG_DIR,CODEX_HOME,COPILOT_HOME,CLINE_DIR,CONTINUE_GLOBAL_DIR). - We did not test OAuth flows end-to-end, verify keychain behaviour on every platform, or search GitHub for committed MCP secrets.
- Windsurf and other MCP clients were not covered.
About this research
Written by the Shadow Research Team from source code of open-source MCP clients and official documentation of closed-source ones. Shadow is a privacy layer for AI from Tiny Bubble Company, with a free Core tier and Shadow Hub at $3 per user per month. It is not affiliated with any of the tools examined in this article.
Disclaimer: This article describes publicly available source code and documentation as of the dates noted. It is not legal advice. Behavior may change between versions; verify on your installed version before relying on these findings.
Install Shadow Core freeAll research
Frequently asked questions
Is it safe to put API keys in claude_desktop_config.json?
The file is plain JSON, readable by any process running as your user, and copied by backups and dotfile sync. Claude Desktop's docs describe no environment-variable interpolation for this file. If a server is available as a Claude Desktop extension, its fields marked sensitive are stored in the OS keychain instead, which Anthropic describes in its Desktop Extensions announcement.
Should .cursor/mcp.json be in .gitignore?
Only if it holds literal secrets. Cursor resolves ${env:NAME} in command, args, env, url and headers, so a project .cursor/mcp.json that references variables can be committed safely. Cursor's own doc examples use literal values like "API_KEY": "value"; replace those with ${env:NAME} before committing.
How do I use environment variables in VS Code mcp.json?
In .vscode/mcp.json or your profile mcp.json, use ${env:NAME}, ${input:id} for a prompted value, or envFile for stdio servers. In a workspace-root .mcp.json or ~/.copilot/mcp-config.json, use ${NAME} or ${NAME:-default}; those portable files do not support input variables or envFile.
Where does Claude Code store MCP OAuth tokens?
The MCP docs say only that tokens are 'stored securely'. The Claude Code changelog (v2.1.281) refers to stored MCP OAuth tokens in the macOS keychain. For a confidential OAuth client, the docs say the client secret is stored 'in your system keychain (macOS) or a credentials file, not in your config'. claude mcp remove deletes local tokens; run claude mcp logout first if you also want them revoked at the authorization server.
Does Cursor encrypt MCP credentials?
Cursor's documentation does not say. ~/.cursor/mcp.json and .cursor/mcp.json are plain JSON, and the docs do not state where OAuth tokens for remote servers are kept. Use ${env:NAME} interpolation, or envFile for stdio servers, to keep keys out of the file.
Where does Gemini CLI store MCP OAuth tokens?
By default in ~/.gemini/mcp-oauth-tokens.json, plain JSON written with mode 0600. If you set GEMINI_FORCE_ENCRYPTED_FILE_STORAGE=true, Gemini CLI uses the OS keychain through keytar, or if no keychain is available, an AES-256-GCM encrypted ~/.gemini/gemini-credentials.json.
Should I commit .mcp.json to my repository?
Claude Code's .mcp.json is designed to be committed, and Claude Code asks for approval before starting project servers. Use ${VAR} references for keys; Claude Code expands them in command, args, env, url and headers. Do not create the file with claude mcp add --scope project --env KEY=$TOKEN, because your shell substitutes the real token first.
Where are Codex CLI MCP OAuth tokens stored?
With the default mcp_oauth_credentials_store = "auto", Codex uses the OS keyring and falls back to ~/.codex/.credentials.json (mode 0600) if the keyring is unavailable. Set mcp_oauth_credentials_store = "keyring" in ~/.codex/config.toml to fail instead of falling back to the file.