Installing the MCP Server

Connect your editor so the agent uses the same Apex as Settings → AI Agents.

One-click from Apex

  1. Open Settings → AI Agents.
  2. Leave Device flow selected.
  3. Click Install in Cursor or Install in VS Code.

No key goes in the file. The first Apex tool call prints an approval link. Open it, approve, and the connection status on AI Agents turns green.

Claude Desktop uses the same page. Copy the config if your editor has no install button.

Manual setup (device flow)

Create or update .cursor/mcp.json in the workspace root:

{
  "mcpServers": {
    "apex": {
      "command": "npx",
      "args": ["-y", "-p", "@apex-inc/mcp-server", "mcp-server"],
      "env": {
        "APEX_URL": "https://app.apex.inc",
        "APEX_WORKSPACE_KEY": "your-workspace-key"
      }
    }
  }
}

Those npx arguments are required. A bare npx @apex-inc/mcp-server can hang on first run.

Restart the editor after you save the file.

API key (advanced)

Use a key when you want a static credential (CI, a locked-down laptop, or a shop key scoped to one workspace).

  1. Open Settings → AI Agents (or Settings → Profile → Your MCP Keys).
  2. Generate a key. Copy it once.
  3. Add it to the config:
{
  "mcpServers": {
    "apex": {
      "command": "npx",
      "args": ["-y", "-p", "@apex-inc/mcp-server", "mcp-server"],
      "env": {
        "APEX_URL": "https://app.apex.inc",
        "APEX_API_KEY": "apex_uk_your_key_here",
        "APEX_WORKSPACE_KEY": "your-workspace-key"
      }
    }
  }
}
KeyPrefixUse
User keyapex_uk_You, across organizations. Needed for list_orgs and switch_org.
Shop keyapex_sk_One organization. Fine for one shop. Cannot list orgs.

Cost of goods stays off both kinds of key until you turn cost:read on in AI Agents. A missing cost permission is not a revoked key.

Environment variables

ParameterTypeDescription
APEX_URLrequiredstringhttps://app.apex.inc in production. http://localhost:3000 when you run Apex locally.
APEX_WORKSPACE_KEYstringShop this session starts on. You can still call switch_workspace. APEX_PROJECT_KEY is the old name and still works.
APEX_API_KEYstringUser or shop key. Omit this when you use device flow.

Confirm it works

Ask the agent:

List my workspaces, then list experiments in the active one.

It should call list_workspaces and list_experiments. Empty is fine. A 401 means the key or device approval is wrong. A sentence about costs means that list needs cost access, not a new key.

On Settings → AI Agents, Connection status should show the editor reached Apex.

Tip

Local Apex uses APEX_URL http://localhost:3000. The MCP server calls the same API the dashboard uses.

Troubleshooting

What you seeWhat it usually isWhat to do
Unknown toolEditor did not load the serverRestart the editor. Check mcp.json uses -y -p @apex-inc/mcp-server mcp-server.
401Key or device token is wrongApprove the link again, or generate a new user key on AI Agents and restart.
This key cannot see costsCost access is off (by design)Turn it on for that key, or stop asking for product costs.
Connection refusedWrong APEX_URLcurl $APEX_URL/api/health should return 200.
list_orgs is emptyShop key (apex_sk_)Use device flow or a user key (apex_uk_).
Update Cursor on Set up ApexEditor is behind the serverOpen AI Agents and click Update Cursor.

Next steps