> ## Documentation Index
> Fetch the complete documentation index at: https://marrow-docs.hologrow.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# 使用 Codex

# 使用 Codex 连接 Marrow

Codex 可以读取您在 Marrow 中已同步的店铺和广告数据。推荐优先在 **AI Hub → AI Platforms** 中使用 OAuth；仅当您偏好密钥配置或 OAuth 不可用时使用 MCP。

## 前置条件

至少一个数据源已完成连接并同步；您拥有 Codex 账户；使用 MCP 时，请先在 AI Platforms 创建 MCP key。

## 方式一：OAuth（推荐）

1. 打开 **AI Hub → AI Platforms**；
2. 在 **Quick connection: OAuth** 下选择 **Codex**；
3. 点击 **Connect**，完成授权；
4. 在 **OAuth sessions** 中确认会话已创建。

已通过 OAuth 连接时，无需再配置 MCP。

## 方式二：MCP

在 `~/.codex/config.toml`（全局）或 `.codex/config.toml`（项目）中添加：

```toml theme={null}
[mcp_servers.marrow]
url = "https://mcp.marrow.ai/mcp/v1"
bearer_token_env_var = "MARROW_MCP_KEY"
startup_timeout_sec = 30
```

然后设置环境变量，切勿把密钥写入配置文件：

```bash theme={null}
export MARROW_MCP_KEY="YOUR_MCP_KEY"
```

也可以使用静态请求头，但不建议用于会提交到版本库的配置：

```toml theme={null}
[mcp_servers.marrow]
url = "https://mcp.marrow.ai/mcp/v1"
http_headers = { "Authorization" = "Bearer YOUR_MCP_KEY" }
startup_timeout_sec = 30
```

重启 Codex 会话或重新加载 IDE 扩展后，测试：

```
Show me my Amazon Seller sales for the last 7 days.
```

若返回已同步账户中的实际数据，说明连接成功。Marrow 始终为只读；需要停用访问时，请在 AI Platforms 撤销 OAuth 会话或轮换 MCP 密钥。
