# Connect your agent

Your agent talks to Pombus through the Model Context Protocol (MCP). You can run the Pombus MCP server on your computer, or use the hosted one at `https://mcp.pombus.com`. Both run the same catalog of tools, and each shows only the tools its credential reaches. [MCP tools](mcp-tools.md) lists them per credential.

You need a Pombus account and an API key first. See the [Quickstart](quickstart.md).

## On your computer: `npx pombus`

The `pombus` package needs Node.js 20 or newer. It has three commands.

| Command | What it does |
| --- | --- |
| `npx pombus init` | Writes the Pombus server into your client's configuration. |
| `npx pombus doctor` | Checks your key and reports its scope. One read-only request. |
| `npx pombus mcp` | Runs the MCP server over stdio. Your client starts it; you rarely do. |

### What `init` does

1. Reads the key from the `POMBUS_API_KEY` environment variable. If it is not set, `init` asks for it. The input is hidden.
2. Checks the key against Pombus.
3. Writes the server block for Claude Code, Cursor and Gemini CLI, and prints the block for Codex CLI.
4. Tells you to restart your client.

The block is the same for every client that uses JSON:

```json
{
  "mcpServers": {
    "pombus": {
      "command": "npx",
      "args": ["-y", "pombus", "mcp"],
      "env": { "POMBUS_API_KEY": "<YOUR_POMBUS_API_KEY>" }
    }
  }
}
```

`init` changes only the `pombus` entry under `mcpServers`. The rest of the file stays as it was. The write is atomic, and on macOS and Linux the file is set to owner-only access. The key is stored in that file as plain text. If it leaks, revoke it under **Settings › API keys**.

`init` does not write when it cannot do so safely. It prints the block for you to paste when:

- the existing configuration file is not valid JSON;
- your home directory cannot be resolved, or is itself a git repository.

Options:

| Option | Effect |
| --- | --- |
| `--client <id>` | Target one client: `claude-code`, `cursor`, `gemini` or `codex`. |
| `--print` | Print the block and write nothing. Without a key, it prints a placeholder. |
| `--create-inbox --domain <name>` | Create an inbox on a domain you own and have verified in Pombus. |
| `--locale <loc>` | Language of the messages: `en-US`, `pt-BR` or `es-419`. |

`--create-inbox` always needs `--domain`. Your `@pombus.com` address is the one from sign-up, and an API key cannot create another one.

### Claude Code

```sh
npx pombus init --client claude-code
```

`init` writes to `~/.claude.json` (on Windows, `%USERPROFILE%\.claude.json`). Restart Claude Code.

### Cursor

```sh
npx pombus init --client cursor
```

`init` writes to `~/.cursor/mcp.json`. Restart Cursor.

### Gemini CLI

```sh
npx pombus init --client gemini
```

`init` writes to `~/.gemini/settings.json`. Restart Gemini CLI.

### Codex CLI

Codex reads a TOML file. `init` does not write TOML. It prints this block, with your key, for you to paste into `~/.codex/config.toml`:

```toml
[mcp_servers.pombus]
command = "npx"
args = ["-y", "pombus", "mcp"]

[mcp_servers.pombus.env]
POMBUS_API_KEY = '<YOUR_POMBUS_API_KEY>'
```

```sh
npx pombus init --client codex
```

## Hosted: `https://mcp.pombus.com`

The hosted server speaks MCP over Streamable HTTP. It accepts one of two credentials per request.

| Credential | Header | Reach |
| --- | --- | --- |
| OAuth access token | `Authorization: Bearer <token>` | Every space you authorized for this connection. |
| API key | `x-api-key: <your key>` | What that key reaches. |

Send one of them, never both. A request with both headers is refused.

### Claude.ai and ChatGPT (OAuth)

1. In your client, add a custom connector (a remote MCP server) with the URL `https://mcp.pombus.com`.
2. The client opens a Pombus page in your browser. If you are not signed in, sign in to the webmail.
3. On **Connect an agent**, choose the space the agent will work in. The field is labeled **Organization**. Only spaces you own are listed.
4. Choose what the agent can do. The screen starts on a preset: **Read and draft** in most cases, **Operator** when the client asks to send, **Read-only** when it asks only to read. Change it if you want. The screen shows only permissions this connection can hold, and the agent gets exactly the ones you leave on. [API keys and permissions](keys.md) lists them.
5. Select **Authorize**. You go back to your client, and the tools appear. **Deny** cancels.

You have 10 minutes to finish steps 2 to 5. After that the request expires and you start again from the client.

The authorization lasts 1 hour. There is no automatic renewal: when it ends, the client asks you to authorize again.

To work in a second space, ask the agent to call `select_organization`. If you have not authorized that space yet, the tool returns a link to authorize it. `list_organizations` shows the spaces already authorized and which one is active.

For developers of MCP clients: the server publishes its OAuth metadata at `/.well-known/oauth-protected-resource` and `/.well-known/oauth-authorization-server`. It supports the authorization code grant with PKCE (`S256` only), public clients (no client secret), and dynamic client registration at `/register`. A registered redirect URI must use `https`, or `http` on `localhost` or `127.0.0.1`, with at most 5 URIs per client.

### Any MCP client

We have not tested every client. The instruction below is generic. It applies to any client that speaks MCP, such as Grok Bot, dots, Muse or Hermes.

If the client runs local commands, use the JSON block from the top of this page.

If the client connects to remote servers:

- URL: `https://mcp.pombus.com`
- Authentication: OAuth, if the client supports it for MCP servers. Otherwise a custom header `x-api-key` with your Pombus key.

## Check the connection

Ask the agent to list the newest threads of your inbox. If it has no Pombus tools, go through the list below.

## Troubleshooting

### On your computer

The messages appear in your system language, or in the one you pass with `--locale`.

| What you see | Cause | What to do |
| --- | --- | --- |
| `POMBUS_API_KEY is not set. Export your Pombus API key and try again.` | The server started without a key. It lists the tools, and every call returns this message. | Set `POMBUS_API_KEY` in the server block, or run `npx pombus init` again. |
| `Could not authenticate with Pombus. Check that POMBUS_API_KEY is valid.` | The key was rejected: mistyped, revoked or expired. | Run `npx pombus doctor`. Create a new key if needed. |
| `Could not reach the Pombus API. Check your connection and try again.` | No route to Pombus. | Check your connection or proxy. |
| `This client's config format is not written automatically (to avoid corrupting it). Paste the block below into its config file.` | Codex CLI, or a configuration file `init` would not overwrite. | Paste the printed block yourself. |
| `--create-inbox needs --domain <your verified domain>` | An extra inbox needs a domain of your own. | Add `--domain`, or drop `--create-inbox`. |
| `That domain is not verified in your Pombus space yet.` | The domain exists but is not verified. | Verify it under **Domains**, then run `init` again. |
| `Your plan's inbox limit is reached.` | Your plan has no inbox left. | Delete an inbox or change plan. |
| `This API key cannot create inboxes.` | The key has no `inbox_create` permission. | Use another key, or drop `--create-inbox`. |
| The agent has no send tool, or some other tool is missing. | The key does not grant that permission, or its scope does not reach that tool. | See [API keys and permissions](keys.md). |
| A tool answers `error: not_found`. | The item does not exist, or the key cannot reach it. A revoked or expired key gives the same answer. | Check the id. Run `npx pombus doctor`. |
| A tool answers `error: inbox_required`. | The key reaches more than one inbox and the call had no `inbox_id`. | The agent calls `list_inboxes` and passes the `inbox_id`. |

### Hosted

| What you see | Cause | What to do |
| --- | --- | --- |
| HTTP 401 with a `WWW-Authenticate` header | No credential, an invalid one, or an authorization older than 1 hour. | Authorize again from your client, or check the `x-api-key` value. |
| HTTP 400 `{"error":"invalid_request"}` | Both `Authorization` and `x-api-key` were sent. | Send one of them. |
| HTTP 403 with an empty body | A browser called the server from a page that is not allowed to. | Connect from the MCP client itself. |
| HTTP 429 `{"error":"rate_limited"}` | More than 30 requests in a minute, from one IP address, to `/authorize`, `/register` or `/token`. | Wait 60 seconds. |
| HTTP 503 with `Retry-After: 60` | The server is temporarily unavailable. | Retry after a minute. |
| `This request expired. Restart the connection from the agent.` | More than 10 minutes passed on the consent screen. | Start the connection again from your client. |
| `You are not a member of that organization.` | The space you chose is not yours. | Choose another one. |
| `One of the chosen permissions can't go on this key. Reload the page and choose again.` | The page was older than the list of permissions the server grants. Nothing was created. | Reload the page and choose again. |
| `invalid_pkce` | The client did not use PKCE with `S256`. | The client must support PKCE `S256`. |
| `invalid_redirect_uri` | The redirect URI is not registered for that client. | The client must register it first at `/register`. |
| `invalid_grant` | The code was already used, expired (60 seconds), or does not match the client. | Start the connection again. |
