---
title: "config MCP ของ OpenAI Codex CLI: path ไฟล์, key และตัวอย่าง · DotsAgent"
description: "เพิ่มเซิร์ฟเวอร์ MCP ของ OpenAI ใน OpenAI Codex CLI: ตำแหน่งไฟล์ config, key และรูปแบบระดับบนสุด, การรองรับ OAuth สำหรับเซิร์ฟเวอร์ remote และตัวอย่าง config"
url: https://dotsagent.io/th/mcp/clients/codex-cli
---

OpenAI

# เพิ่มเซิร์ฟเวอร์ MCP ใน OpenAI Codex CLI

Codex เก็บเซิร์ฟเวอร์ไว้ใน config.toml โดยใช้ตาราง [mcp_servers.<name>] แยกหนึ่งตารางต่อเซิร์ฟเวอร์ และเพิ่มเซิร์ฟเวอร์ได้ด้วย codex mcp add

- **macOS**: `~/.codex/config.toml`
- **Windows**: `~/.codex/config.toml`
- **Linux**: `~/.codex/config.toml`
- **ไฟล์โปรเจกต์**: `.codex/config.toml (trusted projects only)`
- **Key ระดับบนสุด**: `mcp_servers`
- **รูปแบบ**: toml
- **OAuth สำหรับเซิร์ฟเวอร์ remote**: 

## ตัวอย่าง config

ตัวอย่างนี้เพิ่มเซิร์ฟเวอร์ที่ GitHub โฮสต์ไว้และ Playwright เป็นเซิร์ฟเวอร์ local โดยใช้รูปแบบที่ไคลเอนต์นี้รองรับ

`.codex/config.toml`

```
[mcp_servers.github]
url = "https://api.githubcopilot.com/mcp/"

[mcp_servers.playwright]
command = "npx"
args = ["@playwright/mcp@latest"]
```

`shell`

```
codex mcp add github --url https://api.githubcopilot.com/mcp/
codex mcp add playwright -- npx @playwright/mcp@latest
```

## หมายเหตุและข้อควรระวัง

- Codex CLI, ส่วนขยาย IDE ของ Codex และแอป ChatGPT บนเดสก์ท็อปอ่านไฟล์ config.toml เดียวกัน
- โปรเจกต์จะอ่าน .codex/config.toml ก็ต่อเมื่อเป็นโปรเจกต์ที่เชื่อถือได้เท่านั้น
- env_vars ส่งต่อตัวแปรจาก shell โดยระบุชื่อ ส่วน bearer_token_env_var ส่ง token จากตัวแปรไปยังเซิร์ฟเวอร์ระยะไกล
- ตัวเลือกสำหรับแต่ละเซิร์ฟเวอร์ประกอบด้วย startup_timeout_sec, tool_timeout_sec, enabled_tools และ disabled_tools
- codex mcp login <name> เริ่มทำงานผ่าน OAuth โดยรองรับทั้ง CIMD และการลงทะเบียนแบบไดนามิก

[สร้าง config สำหรับ OpenAI Codex CLI →](https://dotsagent.io/th/mcp/config#client=codex-cli)

## ไคลเอนต์อื่น

[Claude Desktop](https://dotsagent.io/th/mcp/clients/claude-desktop)

[Claude Code](https://dotsagent.io/th/mcp/clients/claude-code)

[Cursor](https://dotsagent.io/th/mcp/clients/cursor)

[VS Code (GitHub Copilot)](https://dotsagent.io/th/mcp/clients/vscode-copilot)

[Windsurf / Devin Desktop](https://dotsagent.io/th/mcp/clients/windsurf)

[Zed](https://dotsagent.io/th/mcp/clients/zed)

[Gemini CLI](https://dotsagent.io/th/mcp/clients/gemini-cli)

[ChatGPT](https://dotsagent.io/th/mcp/clients/chatgpt)

[OpenClaw](https://dotsagent.io/th/mcp/clients/openclaw)

[Cline](https://dotsagent.io/th/mcp/clients/cline)

[Continue](https://dotsagent.io/th/mcp/clients/continue)

[JetBrains AI Assistant](https://dotsagent.io/th/mcp/clients/jetbrains-ai)

## แหล่งที่มา

1. [developers.openai.com](https://developers.openai.com/codex/mcp)/codex/mcp

แหล่งอ้างอิงอิสระสำหรับผู้สร้าง AI agent ไม่มีส่วนเกี่ยวข้องกับผู้ให้บริการที่กล่าวถึง

© 2026 DotsAgent · ตรวจสอบข้อมูลเมื่อ 1 ตุลาคม 2569
