# Use Potions over MCP

> Connect Claude Code, Codex, Cursor and other MCP clients to Potions so your agent can deploy, follow and roll back your apps, check and create servers, and ask to delete apps.

Potions runs an MCP server at `https://potions.io/mcp`. Connect it to your coding agent and you can say "deploy this to potions": the agent finds or creates the app, deploys the commit you pushed, follows the build, reads the logs if it fails and gives you the URL when it's live. It can also tell you how much room your servers have, create a new server, and ask you to confirm deleting an app.

## Before you start

- Your app's code is on GitHub and the Potions GitHub App can see the repository. Potions builds from GitHub, so your agent pushes before it deploys.

## Connect by signing in

Most clients connect by signing in to Potions in your browser, so there's no token to create or store. In Claude Code:

```
claude mcp add --transport http --scope user potions https://potions.io/mcp
```

Then start Claude Code (restart it if it's running), run `/mcp`, choose **potions** and **Authenticate**. Potions opens in your browser: sign in, leave the abilities ticked and approve. `--scope user` adds Potions to every project. Without it, Claude Code adds it only to the folder you ran the command in.

In Codex:

```
codex mcp add potions --url https://potions.io/mcp
```

Codex opens Potions in your browser right away, to sign in and approve. If it doesn't, run `codex mcp login potions`.

For Cursor, VS Code, Gemini CLI, Claude and ChatGPT, see [Connect AI Apps](/docs/connect-ai-apps).

## Connect with an API token

Use a token for a client that can't sign in, or when you'd rather manage the credential yourself. Open [API tokens](/account/api-tokens) and create a token with the **Agent** preset. Potions shows it once, when you create it. Never paste it into a chat with your agent.

Connect each client one way only. Two connections to the same server, like a sign-in and a token, show every tool twice.

### Claude Code

The plugin keeps your token in your system's credential store:

```
claude plugin marketplace add potionsio/agent-plugin
claude plugin install potions-mcp@potions
```

Claude Code asks for your token when the plugin is enabled.

With [the Potions CLI](/docs/cli) installed, `potions setup agent --agent claude-code --mcp` connects the server using your CLI login, so no token is stored in Claude Code at all.

To add the server by hand, export your token as `POTIONS_TOKEN` and run:

```
claude mcp add-json potions '{"type":"http","url":"https://potions.io/mcp","headers":{"Authorization":"Bearer ${POTIONS_TOKEN}"}}' --scope user
```

### Codex

Add this to `~/.codex/config.toml` and export `POTIONS_TOKEN` in the shell you start Codex from:

```
[mcp_servers.potions]
url = "https://potions.io/mcp"
bearer_token_env_var = "POTIONS_TOKEN"
tool_timeout_sec = 75
```

### Cursor

Add this to `~/.cursor/mcp.json`:

```
{"mcpServers": {"potions": {"url": "https://potions.io/mcp", "headers": {"Authorization": "Bearer ${env:POTIONS_TOKEN}"}}}}
```

### VS Code

```
{
  "inputs": [{"type": "promptString", "id": "potions-token", "description": "Potions API token", "password": true}],
  "servers": {"potions": {"type": "http", "url": "https://potions.io/mcp", "headers": {"Authorization": "Bearer ${input:potions-token}"}}}
}
```

### Gemini CLI

```
gemini mcp add --transport http --scope user -H "Authorization: Bearer $POTIONS_TOKEN" potions https://potions.io/mcp
```

Gemini CLI saves the token in its settings file, so use a token you can revoke easily.

## What your agent can do

| Tool | What it does |
|---|---|
| `whoami` | Shows the account and token in use |
| `find_app` | Finds the app for a GitHub repository |
| `list_servers` | Lists your servers with their size and room for another app, to choose where a new app goes |
| `get_server` | Shows one server's specs, memory, disk and load over the last 24 hours, its apps, and whether another app fits |
| `list_server_options` | Shows your plan's room, your connected cloud accounts and their regions, and a region's sizes with monthly prices |
| `create_server` | Creates an app server on your DigitalOcean or Hetzner account, or adds a server you bring |
| `wait_for_server` | Follows a new server's setup for up to 45 seconds per call |
| `create_app` | Creates an app for a repository on one of your servers |
| `deploy` | Deploys a pushed commit |
| `wait_for_deployment` | Follows a deploy for up to 45 seconds per call, with progress |
| `get_deployment` | Shows a deploy's status, failed step and AI failure summary |
| `get_deployment_logs` | Reads a deploy's log, with every environment variable value removed |
| `rollback` | Switches back to the previous release without a rebuild |
| `request_env` | Asks you to enter missing environment variables in your browser |
| `set_env_config` | Sets non-secret settings such as `POOL_SIZE` |
| `generate_secret` | Creates a random value, such as a signing salt, that nobody sees |
| `delete_app` | Asks you to confirm deleting an app in Potions; never deletes by itself |

Every client sees every tool. A token can only do what its abilities allow: with a **Read only** token, `deploy` and the other tools that change things answer with an error that names the missing ability.

## Your secrets stay in your browser

Your agent never sees or sets a secret value. When a deploy needs a variable you haven't set, like `STRIPE_SECRET_KEY`, the agent calls `request_env`. In Claude Code, it asks to open a Potions page in your browser; in other clients, it shows you the link. You sign in, enter the value and save, and your agent continues. The page checks that you're signed in as the account the agent is using. Values apply on the next deploy, or right away if you click **Save and deploy**.

## Room on your servers

`list_servers` and `get_server` give each server a verdict for one more app: **room**, **tight** or **full**, with the reasons. Potions takes the highest memory use of the last 24 hours, adds about 250 MB for another Phoenix app, and compares that with 75% and 90% of the server's memory; disk counts at 80% and 90% full. Load can only turn room into tight, because the BEAM keeps CPUs busy-waiting and its CPU percent looks higher than the real load. A server with less than a day of metrics gets low confidence. It's a guide: your agent shows you the numbers and you choose.

## Creating servers

Your agent shows you the regions, sizes and monthly prices from your cloud account, and asks before it creates anything. It has to send back the price you agreed to: if the price has changed, Potions creates nothing. Claude Code always asks you before `create_server` runs, even in auto mode. Each token can create 5 servers an hour, and your plan's server limit applies. A server you bring needs its connect command, which you copy from the server's page; your agent never sees it.

Potions emails you about every server an agent creates, with its size, region and monthly price, and the server's page says which token created it. If no app has run on it after 48 hours, Potions emails you once more. It never deletes the server for you.

Your agent can't connect a cloud account for you: connect DigitalOcean or Hetzner from your account page, so their tokens never pass through a chat.

## Deleting needs you

`delete_app` doesn't delete anything. It tells your agent what would go (the app, its database and its backups) and gives you a link to the app's danger zone in Potions. There you type the name and tick each consequence, exactly as when you delete from the dashboard. The link only works for your account and expires after an hour. An agent can't take that step for you, even if something it reads tells it to. Potions also emails you when an agent asks, and the request shows on the app's Settings page for that hour, so you can open Potions yourself instead of the link.

Agents can't delete servers at all, or ask to. Delete a server from its page in Potions.

## What your agent can't do

Agents can't run commands on your servers, read environment variable values, change build hooks, connect cloud accounts, or create database servers and load balancers. Do those in the dashboard.

## Troubleshooting

- **The server shows as failed or needs authentication.** With a token: it's missing, mistyped, expired or revoked; create a new one and update your client config. Without one, your client should offer to sign in: see [Connect AI Apps](/docs/connect-ai-apps).
- **A tool answers insufficient_ability.** Your token doesn't have that ability. Create a token with the Agent preset.
- **"push first".** The commit isn't on GitHub yet. Push and ask your agent to deploy again.
- **Codex stops waiting.** Each wait lasts at most 45 seconds, under Codex's 60 second limit; your agent calls it again until the deploy finishes.
