# Merget in Codex

Step 2 of https://sema.merget.ai/agent-setup/prompt.md, for Codex CLI, Codex in the ChatGPT desktop app and the Codex IDE extension (they share `~/.codex/config.toml`). Run the commands yourself; the human signs in. When `merget_status` is among your tools, continue at the prompt's step 3.

## Install

Plugin, the usual route in the CLI and the desktop app (the IDE extension has no plugins): Merget's MCP server and skills in one unit. Codex reads the marketplace's `.claude-plugin/marketplace.json`.

```
codex plugin marketplace add MergetAI/merget-plugin
codex plugin add merget@merget-queue
```

Or the human installs Merget from the plugin browser — `/plugins` in a CLI session, or the desktop app's Plugins directory with `merget-queue` as the source. Start a new session afterwards.

MCP server and skills by hand (the IDE extension too):

```
codex mcp add merget --url https://sema.merget.ai/mcp
codex mcp login merget
npx -y skills add MergetAI/merget-plugin -a codex -g -y
```

The skills land in `~/.agents/skills`; skip that line when the plugin is installed, it ships them. One route or the other: the plugin and a hand-added server at the same URL list every tool twice. In the desktop app the human can instead add the server under Settings › MCP servers › Add server (Streamable HTTP, the URL), save it and select Restart.

## Sign in

`codex mcp login merget` opens the browser; in the app or the extension the human selects Authenticate next to the server. On Merget's sign-in page they pick the organization and your permissions; `codex mcp login merget` again signs in as someone else or with other permissions.

## Check

`/mcp` in a session lists the connected servers; `codex mcp list` from a shell. Start a new session after installing; if `merget` stays disconnected, log in again.

## Updates

Plugin: `codex plugin marketplace upgrade merget-queue` refreshes the marketplace, then the plugin browser offers the new version. Skills by hand: run the `npx -y skills add` line again.

## Dead ends

- No shell (you cannot run `codex`): hand the commands to the human.
- `-g` writes under the home directory; the sandbox may ask the human to approve it.
- `invalid_redirect_uri`, or a saved connection that stops connecting: stop and point the human to https://sema.merget.ai/orgs/<slug>/docs/mcp.
- A headless run with no browser to sign in takes an agent key: the human creates one at https://sema.merget.ai/orgs/<slug>/settings/agents › Create agent key (shown once; it goes in no URL or prompt) and sets it as `MERGET_KEY` in the run's environment; in `config.toml`, give `merget` `bearer_token_env_var = "MERGET_KEY"` in place of `codex mcp login`.
