Codex MCP config.toml Approval Setup for Risky Tools

Returns a reviewed config.toml diff for one MCP server in Codex, with an allow list, per-tool approval prompts for risky tools, a startup choice and a 3-step check.

Agent prompt

The prompt

Prompt
You are a senior developer setting up MCP servers for Codex CLI in this repository.

Job: add  to the Codex config so that  always ask before running.

Inspect first. Run codex --version. Check whether this setup uses ~/.codex/config.toml or a project .codex/config.toml. List the server's tools from its docs or from a first run. If something is still missing, such as the auth variable or which tools I need, ask up to 3 short numbered questions in one message and wait.

Rules:
1. Use only keys from the Codex MCP docs: enabled_tools, disabled_tools, default_tools_approval_mode, required, startup_readiness, and a per-tool table with approval_mode. Check --help or the docs for anything else. Invent nothing.
2. enabled_tools is an allow list of only the tools I need. Each risky tool gets its own approval_mode override that prompts.
3. Do not guess what auto, prompt, writes or approve mean. Quote the docs line for each value you use, or mark it unconfirmed.
4. Pick one startup option and give a one-line reason. Either use lazy start, which is the default for optional stdio servers in 0.172.0, or set required = true with startup_readiness = "catalog".
5. Show the diff first. Write only after I approve, then state the file path. Never commit or push.

Output format:
## Tools found (table: tool | purpose | enabled | approval)
## Diff to config.toml
## Approval values used (doc quote or "unconfirmed")## Startup choice
## 3-step check: codex --version is 0.172.0 or newer; the server appears in /mcp; one risky tool asks before running.

Last line: what you could not confirm.

Example output

Example for: postgres-staging, a stdio Postgres MCP server for our staging database; risky tools = execute_sql and apply_migration.

codex --version reports 0.172.0. The repo has no .codex/config.toml, so the target is ~/.codex/config.toml. Tools were listed from a first run of npx -y @acme-internal/pg-mcp.

Tools found

ToolPurposeEnabledApproval
list_tablesList tables in a schemayesserver default (auto)
describe_tableColumns, indexes, constraintsyesserver default (auto)
query_readonlySELECT in a read-only transactionyesserver default (auto)
execute_sqlArbitrary SQL, including writesyesprompt
apply_migrationRuns a migration fileyesprompt
vacuum_tableVACUUM on a tableno—
list_extensionsInstalled extensionsno—

Diff to config.toml

+[mcp_servers.postgres-staging]
+command = "npx"
+args = ["-y", "@acme-internal/pg-mcp"]
+env_vars = ["STAGING_DATABASE_URL"]
+enabled_tools = ["list_tables", "describe_table", "query_readonly", "execute_sql", "apply_migration"]
+default_tools_approval_mode = "auto"
+
+[mcp_servers.postgres-staging.tools.execute_sql]
+approval_mode = "prompt"
+
+[mcp_servers.postgres-staging.tools.apply_migration]
+approval_mode = "prompt"

This has not been written yet. Reply "approve" and I will save it to ~/.codex/config.toml. I will not commit anything.

Approval values used

  • auto: unconfirmed. I could not open the Codex MCP docs from this session. My working assumption is "runs without asking". Check the docs before relying on it.
  • prompt: unconfirmed for the same reason. My working assumption is "asks before each call". Step 3 below tests it directly.

Startup choice

The server is optional, so I am using lazy start: no required, no startup_readiness. It is only needed for database tasks. In 0.172.0 an optional stdio server with a cached tool list starts on its first tool call, so sessions that never touch the DB do not pay its startup time.

3-step check

  1. Run codex --version and confirm it shows 0.172.0 or newer.
  2. Start Codex, run /mcp, and confirm postgres-staging is listed with 5 tools.
  3. Ask Codex to run SELECT 1 through execute_sql. It should ask before running.

Could not confirm: the exact doc wording for auto and prompt, and whether env_vars takes a list of names in this version.

What to check: make sure STAGING_DATABASE_URL points at staging, not production. Re-run step 3 after any Codex upgrade. If /mcp shows more than 5 tools, the allow list was not applied.

Written by AI from this prompt. Your results will vary.

Tips and common edits

Why this works

  • Quoting the docs for each approval value stops the agent from guessing what auto, prompt, writes or approve actually do.
  • An enabled_tools allow list plus per-tool prompts gates risky tools, even if the server default is permissive.
  • Diff-before-write and a 3-step check let you confirm a risky tool really asks first before trusting the config.

Paste into Codex at the repo root when you add an MCP server and want write tools gated. It follows Codex CLI 0.172.0. Have the server's package name or URL and the name of its auth env var ready.

Common edits

  • Second example, ready to paste: set {mcp_server} = "jira-gateway, a remote HTTP Jira MCP server behind our internal gateway" and {risky_tools} = "create_issue, transition_issue and delete_comment".
  • Make the server required and set startup_readiness = "catalog" when every session depends on it.
  • Add output_token_limit on chatty tools such as query results to keep tool output short.

Reuse it: Use in a workflowAdapt in the builder

Prompt details

By
Prompts-GPT editors
Published
How prompts are written and checked

Did this prompt work?

More in Codex

Create MCP Tool Configuration for Claude Code

Generate a secure, ready-to-use MCP server configuration file for Claude Code to enable local database and observability access safely.

Agentic AI

Tool Permission Matrix and Function Spec for a Tool-Using Agent

Produces a least-privilege tool inventory, function definitions, and approval rules for an agent that calls APIs or internal systems.

Package Skills, Hooks and MCP Into a Claude Code Plugin

A SKILL.md that turns the skills, subagents, hooks and MCP servers in your .claude folder into an installable Claude Code plugin with a marketplace file, then validates and test-installs it.

Why Is My AGENTS.md Ignored? Codex Instruction Diagnosis

A SKILL.md that finds why Codex skips or half-follows your AGENTS.md: wrong root, an override file, the 32 KiB limit cutting a nested file, or rules too vague to act on.

Claude Code Permission Allowlist and Deny Rules for This Repo in settings.json

Has Claude Code read your repo's scripts and CI, then propose allow, ask and deny permission rules with a reason for each, split into shared and local settings files, plus commands to test them.

Agentic AI

Agent Tool Names, Descriptions and JSON Schemas from API Docs

Turns pasted API docs or a function list into agent-ready tool names, descriptions, JSON input schemas and when-to-use and when-not-to-use notes.