Agents

Using CubiBase with AI agents

CubiBase is built to be operated by AI agents end to end: discover the API, authenticate with a personal access token, and act through an MCP server, a CLI, or plain HTTPS.

The agent surfaces

SurfaceWhereWhat it is for
MCP servernpx -y @cubibasehq/mcpTools for chat and IDE agents (Claude, Cursor, Codex): projects, full schema, rows, SQL, storage uploads, function deployments, logs, Data API, docs search
CLInpx -y @cubibasehq/cliShell agents and scripts; JSON output on stdout, structured errors on stderr. Same console parity as the MCP tools
TypeScript clientnpm install @cubibasehq/clientTyped ControlClient and DataClient for code agents
Control API OpenAPIhttps://api.cubibase.com/v1/openapi.jsonOpenAPI 3.1 with operationIds and typed errors for the whole Control API
Data API OpenAPIhttps://{slug}.api.cubibase.com/rest/v1/openapi.jsonPer-project spec generated from the live schema: exposed tables, columns, filters, RPC functions
Skill filehttps://cubibase.com/SKILL.mdA loadable skill (agentskills.io format) that teaches an agent the whole CubiBase workflow. Canonical repo: github.com/cubibase/skills; also inside the @cubibasehq/mcp and @cubibasehq/cli packages

Source for all three packages: github.com/cubibase/cubibase-agent (MIT).

Authentication an agent can finish

  1. Create a personal access token

    Console → Account → Access tokens. Scope read for inspection, write for building, admin for destructive operations. Optionally restrict the token to one project.

  2. Give the token to the agent

    Set CUBIBASE_TOKEN in the agent environment (MCP env block or shell). The token is a cb_pat_… string, shown once.

  3. Optional: add a service key for data access

    For Data API tools, create a secret key (cb_sec_…) in the project’s API keys and set CUBIBASE_SERVICE_KEY. It acts as the service actor; row-level security still applies.

MCP setup

Add the server to any MCP client (Claude Desktop, Cursor, Codex, and others):

mcp.json
{
  "mcpServers": {
    "cubibase": {
      "command": "npx",
      "args": ["-y", "@cubibasehq/mcp"],
      "env": {
        "CUBIBASE_TOKEN": "cb_pat_…",
        "CUBIBASE_SERVICE_KEY": "cb_sec_… (optional)"
      }
    }
  }
}

76 tools in seven groups. Projects: list, get, create, update, delete. Database: tables, columns, exposure, policies, PostgreSQL triggers, indexes, enum/composite types, views, rows (list/insert/update/delete), read-only SQL, SQL functions. Storage: bucket CRUD, object listing, cubibase_upload_file (end-to-end upload from text or base64), presigned upload URLs for large files, signed download links. Functions: create from source or template, deploy, activate deployments, secrets, http/database/storage/schedule triggers, test invocation, execution logs. Data API: cubibase_data_list, cubibase_data_rpc, cubibase_data_openapi. Observability: API keys, request logs, audit logs, usage, and cubibase_additional_usage (read-only V4.5 overage settings, per-resource excess and estimated costs, invoice preview — enabling overages stays a Console-only owner action). Docs: cubibase_search_docs searches the bundled documentation offline and returns excerpts with URLs.

Environment variableEffect
CUBIBASE_READ_ONLY=1Hides every mutating tool from the tool list. Pair with a read-scope token for safe exploration agents
CUBIBASE_FEATURES=database,storageOnly register the listed tool groups: projects, database, storage, functions, data, observability, docs
Read-only inspection server
{
  "mcpServers": {
    "cubibase": {
      "command": "npx",
      "args": ["-y", "@cubibasehq/mcp"],
      "env": {
        "CUBIBASE_TOKEN": "cb_pat_…",
        "CUBIBASE_READ_ONLY": "1"
      }
    }
  }
}

CLI setup

Shell
export CUBIBASE_TOKEN=cb_pat_…
npx -y @cubibasehq/cli projects list
npx -y @cubibasehq/cli tables list <projectId>
npx -y @cubibasehq/cli rows list <projectId> notes --filter status=eq.active --limit 10
npx -y @cubibasehq/cli sql <projectId> 'select count(*) from notes'
npx -y @cubibasehq/cli storage upload <projectId> --bucket avatars --path u1.png --file ./u1.png
npx -y @cubibasehq/cli functions create <projectId> --name hello --file ./hello.ts
npx -y @cubibasehq/cli functions deploy <projectId> hello

Command groups: projects, tables, rows, sql, rpc, exposure, policies, triggers, indexes, types, views, storage, functions, keys, logs, usage, tokens. Every command prints JSON. Errors print {"error":{code,message,status,retryAfterSeconds}} to stderr and exit 1.

Errors and retries

  • Every error carries a stable machine code (e.g. invalid_token, insufficient_scope, quota_exceeded) and a requestId for support.
  • 429 responses include a Retry-After header (seconds). Wait, then retry — do not hammer.
  • 401 means re-authenticate or check the token scope; 403 means the action is not allowed for this actor; 402 means a plan quota was reached.
  • The full error catalogue is on the error codes reference page.

Machine-readable discovery files

  • llms.txt — product summary and page index: https://cubibase.com/llms.txt
  • llms-full.txt — the entire site content in one file: https://cubibase.com/llms-full.txt
  • Markdown mirrors — every page is also served as {path}.md, e.g. https://cubibase.com/docs/quickstart.md
  • Pricing as text: https://cubibase.com/pricing.md
  • AI catalog: https://cubibase.com/.well-known/ai-catalog.json
  • Skill file: https://cubibase.com/SKILL.md

Additional resources