# Connect Codex

Create an agent in Rukou and copy its MCP address from **Agents**. These instructions use
Codex's remote MCP support; the Rukou app's client picker may label it **Another MCP client**.

## Sign in from the CLI

Replace `AGENT_MCP_ADDRESS` with the complete address copied from Rukou:

```sh
codex mcp add rukou-research --url "AGENT_MCP_ADDRESS"
codex mcp login rukou-research
```

If adding the server already completes sign-in, the second command is unnecessary. Authorize
the intended Rukou agent in the browser. Use `codex mcp list` or `/mcp` inside Codex to check
the server. These commands follow the [official Codex MCP documentation](https://learn.chatgpt.com/docs/extend/mcp?surface=cli).

In the IDE extension, open **MCP servers** from the gear menu, add a **Streamable HTTP** server
with the agent's address, save, restart the extension, and authenticate when prompted.
[Codex's IDE setup](https://learn.chatgpt.com/docs/extend/mcp?surface=cli#configure-in-the-ide-extension)
describes those controls.

## Use an API key

For a setup that uses a key instead, make an API key for the Rukou agent. Provide it through
your private launch environment as `RUKOU_API_KEY`, then add the connection:

```sh
codex mcp add rukou-research-key --url "AGENT_MCP_ADDRESS" --bearer-token-env-var RUKOU_API_KEY
```

Codex reads the named environment variable for bearer authentication. Its value is the key
alone, without `Bearer `. Keep it out of the command and prompts. See
[Codex's HTTP configuration](https://learn.chatgpt.com/docs/extend/mcp?surface=cli#configure-with-configtoml).

## Check it

Ask Codex to call `rukou_status` and confirm the organization, workspace, and agent. Then try
the [first browsing task](../getting-started.md#try-your-first-task).

If a key-based connection fails, check that the process running Codex received the environment
variable. After a successful connection, any saved logins that **need access** still require
a handover on Rukou's [Agents page](../agents.md#check-connections-and-login-access).
