Connect an AI client to Cloudgate

Connecting takes an Agent in the console and a few lines of client configuration. The configuration names the key's environment variable rather than holding the key, so it is safe to commit.

Applies to: Owner or AdminHosted and self-hosted

You need to be an Owner or Admin of the Organization to create an Agent. The steps below use the fictional Northwind Labs organization, its storefront Project and the web Service in production. What an Agent is, and why it is not you, is in the MCP overview.

Create an Agent

  1. Open the Agents settings

    In the console, open Settings, then Agents. Each Agent is one row, with its role, what it reaches, its keys and when a client last connected.

    cloudgate.octabyte.app/settings/agents
    Each row shows what the Agent reaches and when a client last connected with one of its keys.
  2. Name it and choose a role

    Press Create an Agent. Under Name, say what it is for, such as deploy-bot: it is how the audit log names it. Under Role, pick:

    • Reader (the default) to let it read Services, Environments, Deployments, Deployment logs and Domains, and change nothing;
    • Operator to let it also deploy, start, stop and cancel Deployments of what it is granted;
    • Caller only for an app that calls your AI models through the Gateway. A Caller gets no MCP tools.

    A Reader can still call request_plan, which spends the write budget. See guard rails.

  3. Grant what it may reach

    Under Access, tick the Projects, Environments or Services it may reach. Access starts empty, and granting a Service grants its Environment and Project too. For an agent that fixes the storefront, tick web in production of storefront, nothing more. You can save with nothing ticked and grant later with Manage access.

  4. Choose when the key expires, and copy it

    Under First key expires, pick 30 days, 90 days (the default) or a year. There is no never-expiring agent key. Press Create Agent and copy the key: this is the only time it is readable. The Connect panel appears under it.

Add Cloudgate to your client

The Connect panel shows one tab per client, with your console’s address already filled in. The address is your console’s origin plus /mcp: https://cloudgate.octabyte.app/mcp on the Hosted instance, and here https://cloud.northwind.example/mcp for a self-hosted one.

cloudgate.octabyte.app/settings/agents
The panel never shows the key; it names the CLOUDGATE_AGENT_KEY variable instead.

Claude Code

In .mcp.json at the root of your project. Set CLOUDGATE_AGENT_KEY to the key in the environment you start Claude Code from; it asks once before it uses a project’s .mcp.json.

{
  "mcpServers": {
    "cloudgate": {
      "type": "http",
      "url": "https://cloud.northwind.example/mcp",
      "headers": { "Authorization": "Bearer ${CLOUDGATE_AGENT_KEY}" }
    }
  }
}

Connected with Claude Code 2.1.278.

VS Code

In .vscode/mcp.json. VS Code asks for the key the first time it starts the server and keeps it in its own secret storage, so no environment variable is needed.

{
  "inputs": [
    {
      "type": "promptString",
      "id": "cloudgate-agent-key",
      "description": "Cloudgate agent key",
      "password": true
    }
  ],
  "servers": {
    "cloudgate": {
      "type": "http",
      "url": "https://cloud.northwind.example/mcp",
      "headers": { "Authorization": "Bearer ${input:cloudgate-agent-key}" }
    }
  }
}

Checked against VS Code’s documentation at 1.138.0.

Cursor

In ~/.cursor/mcp.json. Set CLOUDGATE_AGENT_KEY to the key in the environment you start Cursor from.

{
  "mcpServers": {
    "cloudgate": {
      "url": "https://cloud.northwind.example/mcp",
      "headers": { "Authorization": "Bearer ${env:CLOUDGATE_AGENT_KEY}" }
    }
  }
}

Checked against Cursor’s documentation at 3.6.31.

Codex CLI

In ~/.codex/config.toml. Set CLOUDGATE_AGENT_KEY to the key in the environment you start Codex from; Codex sends it as the bearer token.

[mcp_servers.cloudgate]
url = "https://cloud.northwind.example/mcp"
bearer_token_env_var = "CLOUDGATE_AGENT_KEY"

Read back by Codex CLI 0.155.1; its documentation confirms the header.

Any other client

Any MCP client that speaks Streamable HTTP and can send a header. Replace <agent key> with the key, or with your client’s way of reading CLOUDGATE_AGENT_KEY.

{
  "url": "https://cloud.northwind.example/mcp",
  "headers": { "Authorization": "Bearer <agent key>" }
}

The client must not send an Origin header, and a client on a 2025 protocol revision must send an Accept header naming both application/json and text/event-stream. MCP clients do both already.

Set the variable before you start the client, for example in your shell profile:

export CLOUDGATE_AGENT_KEY=<agent key>

Check that it is connected

Ask the agent “list my Cloudgate Projects”. It should call list_projects and answer with the Projects you granted, and the Agent’s row in the console changes Last connected from “No client has connected yet” to a time. If it does not:

What you see Why Fix
401 “This key is not valid.” The key is wrong, revoked, or the variable is not set where the client starts Check CLOUDGATE_AGENT_KEY in that environment
401 “…this is a personal key.” A Personal key was used Use the Agent’s key
401 “This agent key expired on …” The key ran out Add key on the Agent’s row
403 “…suspended by an operator.” Someone suspended the Agent Resume on its row
403 before any tool runs Something in front of Cloudgate adds an Origin header Stop adding it for /mcp
The tool list is empty The Agent’s role is Caller Change its role to Reader or Operator
Empty lists, or “Not found or not permitted.” Nothing is granted Manage access on its row

More refusals, with what each means, are in guard rails.

Give an agent access to your repository

Cloudgate’s grant reaches Projects, Environments and Services, never your git provider. An agent that pushes a fix and then asks for a requested preview of its branch needs write access to the repository the Application builds from. Give the AI tool that access with your git provider, scoped as you see fit; nothing in Cloudgate asks for it.

Rotate or revoke a key

Press Add key on the Agent’s row, put the new key in the client, then Revoke the old one. The Agent’s other keys keep working throughout. The Connect action on the row shows the client configuration again, but never a key. The Agents guide covers suspending and deleting an Agent, and the audit log shows every call each key made.

Questions

Is there a configuration for Claude Desktop?

The Connect panel has none. It offers Claude Code, VS Code, Cursor, Codex CLI and a generic block. Any client that can send an Authorization header to an HTTP MCP server can use the generic one.

I lost the agent key. Can I see it again?

No. Cloudgate keeps only a hash of it. Press Add key on the Agent's row for a new one, point the client at it, then revoke the old one.

Can I commit the configuration file?

Yes. None of the snippets holds the key: they read it from CLOUDGATE_AGENT_KEY, or in VS Code from its secret storage.

Can one Agent be used from two machines?

Yes. Give each machine its own key with Add key so you can revoke one without the other. All of an Agent's keys share its rate limits.

Something missing or wrong on this page? Email support@octabyte.io, or start a free trial and try it in the console.