62 lines
1.1 KiB
Markdown
62 lines
1.1 KiB
Markdown
# Codex (OpenAI)
|
||
|
||
Codex 是 OpenAI 推出的 CLI 编程助手,支持 MCP 协议。
|
||
|
||
## 配置步骤
|
||
|
||
### 方式一:通过 CLI 参数
|
||
|
||
```bash
|
||
codex --mcp-config '{"my-api":{"type":"http","url":"https://www.agentfoxapp.com/mcp/{projectId}","headers":{"Authorization":"Bearer {your-api-key}"}}}'
|
||
```
|
||
|
||
### 方式二:通过配置文件
|
||
|
||
编辑 `~/.codex/config.json`:
|
||
|
||
```json
|
||
{
|
||
"mcpServers": {
|
||
"my-api": {
|
||
"type": "http",
|
||
"url": "https://www.agentfoxapp.com/mcp/{projectId}",
|
||
"headers": {
|
||
"Authorization": "Bearer {your-api-key}"
|
||
}
|
||
}
|
||
}
|
||
}
|
||
```
|
||
|
||
### 方式三:项目级配置
|
||
|
||
在项目根目录创建 `.codex/mcp.json`:
|
||
|
||
```json
|
||
{
|
||
"mcpServers": {
|
||
"my-api": {
|
||
"type": "http",
|
||
"url": "https://www.agentfoxapp.com/mcp/{projectId}",
|
||
"headers": {
|
||
"Authorization": "Bearer {your-api-key}"
|
||
}
|
||
}
|
||
}
|
||
}
|
||
```
|
||
|
||
## 验证连接
|
||
|
||
启动 Codex 后,在对话中测试:
|
||
|
||
```
|
||
你:调用 get_project_overview 查看 API 信息
|
||
Codex:[调用 get_project_overview]
|
||
项目信息如下:...
|
||
```
|
||
|
||
## 安全提示
|
||
|
||
使用项目级配置时,建议将 `.codex/` 添加到 `.gitignore`。
|