AI Learn
OpenAI · Codex Tutorial

Add and audit an MCP server in Codex

Connect a local or remote MCP server, inspect available tools and authentication, test one read operation, and keep external writes under explicit review.

Reviewed September 19, 2026Independent tutorialFeatures may vary
Not official support. AI Learn is an independent education site and is not affiliated with OpenAI. Check the provider’s current documentation for plan-specific limits, pricing and feature availability.
Before you start

Codex CLI, IDE and supported desktop surfaces can share MCP configuration on the same host. A convenient shared config also means a high-privilege server can affect more than one surface.

1. Choose one trusted server

Start with one server tied to a clear job such as docs, browser automation or an issue tracker. Verify the publisher and setup source.

2. Add it with the supported Codex configuration

Use codex mcp or the documented config path. Keep tokens in supported auth or environment mechanisms rather than project files.

3. Inspect tools before delegating

List the current MCP tools and identify which can read, create, edit, send or delete. Note any tool that reaches data outside the repository.

4. Test a narrow read

Retrieve one known object and compare it with the source. This catches wrong accounts, wrong tenants and overly broad search scopes early.

5. Apply least privilege to writes

Only enable or use consequential tools when the task requires them. Keep an approval or explicit confirmation step before mutations.

Try this prompt

List the MCP servers and tools available in this Codex session. For [server], categorize each tool as read or write. Use only the read tool to fetch [known object]. Stop before any mutation.

Common mistakes

Adding many servers before one workflow works; keeping secrets in a repository config; confusing tool discovery with permission review; allowing a remote server to mutate external data without confirmation.

Finish check

You know which server provides every tool, authentication is stored safely, a read test matches the source, and write actions remain explicitly controlled.

开始之前

Codex CLI、IDE 和支持的桌面端可以在同一主机共享 MCP 配置。共享配置很方便,但也意味着高权限 Server 的影响范围可能跨多个界面。

1. 只从一个可信 Server 开始

先选一个和明确工作直接相关的 Server,例如文档、浏览器自动化或 issue tracker,并核对发布方和配置来源。

2. 按 Codex 当前支持方式添加

使用 codex mcp 或官方文档规定的配置方式。Token 放在支持的认证或环境机制里,不要写进项目文件。

3. 委派任务前先查看工具

列出当前 MCP 工具,区分哪些可以读取、新建、编辑、发送或删除,并标记所有能触达仓库外部数据的工具。

4. 先做一个窄范围只读测试

读取一个你已经知道内容的对象,与源系统核对。这样能尽早发现账号、tenant 或搜索范围错了。

5. 写入仍然坚持最小权限

只有任务确实需要时才启用或调用有后果的工具,并在外部修改前保留人工审批或明确确认。

可以直接套用的提示词

列出本次 Codex 会话可用的 MCP Server 和工具。对【Server】把每个工具分成只读/写入两类;然后只用只读工具获取【已知对象】,任何修改动作之前都停下来。

常见错误

第一个流程还没跑通就接很多 Server;把密钥写进仓库配置;把“看到了工具”误当成已经审查权限;让远程 Server 在没有确认的情况下修改外部数据。

完成检查

完成后,你知道每个工具来自哪个 Server,认证信息保存安全,只读测试与源系统一致,所有写动作仍然被明确控制。

開始之前

Codex CLI、IDE 和支持的桌面端可以在同一主機共享 MCP 配置。共享配置很方便,但也意味著高權限 Server 的影響範圍可能跨多個界面。

1. 只從一個可信 Server 開始

先選一個和明確工作直接相關的 Server,例如文檔、瀏覽器自動化或 issue tracker,並核對發佈方和配置來源。

2. 按 Codex 當前支持方式添加

使用 codex mcp 或官方文檔規定的配置方式。Token 放在支持的認證或環境機制里,不要寫進專案檔案。

3. 委派任務前先查看工具

列出當前 MCP 工具,區分哪些可以讀取、新建、編輯、發送或刪除,並標記所有能觸達倉庫外部數據的工具。

4. 先做一個窄範圍只讀測試

讀取一個你已經知道內容的對象,與來源系統核對。這樣能盡早發現賬號、tenant 或搜尋範圍錯了。

5. 寫入仍然堅持最小權限

只有任務確實需要時才啓用或調用有後果的工具,並在外部修改前保留人工審批或明確確認。

可以直接套用的提示詞

列出本次 Codex 會話可用的 MCP Server 和工具。對【Server】把每個工具分成只讀/寫入兩類;然後只用只讀工具獲取【已知對象】,任何修改動作之前都停下來。

常見錯誤

第一個流程還沒跑通就接很多 Server;把密鑰寫進倉庫配置;把“看到了工具”誤當成已經審查權限;讓遠程 Server 在沒有確認的情況下修改外部數據。

完成檢查

完成後,你知道每個工具來自哪個 Server,認證資訊儲存安全,只讀測試與來源系統一致,所有寫動作仍然被明確控制。

Official references

Check current product details at the source

Related practical tutorials

Continue with another single-task workflow.

All tutorials →