Skip to content
Browse docs
Rolling out

MCP server

Layerbase runs a hosted Model Context Protocol server, so an AI agent such as Claude Code, Codex, Cursor or Grok can work with your Layerbase Cloud databases directly: list them, create one, fetch its connection string, run a query, branch it, and tidy up afterwards. The agent connects with a token you create in account settings, and that token acts as your account with exactly your permissions.

The MCP server is rolling out. If you do not see MCP tokens in your account settings yet, it is not on your account yet.

The endpoint

One URL for every client. It speaks MCP over Streamable HTTP and authenticates with a bearer token in the Authorization header:

MCP endpoint
https://layerbase.com/api/mcp
Authorization header
Authorization: Bearer lbm_YOUR_TOKEN

Any client that can reach a remote MCP server over HTTP and send a custom header works. The MCP server is available on every plan, Free included; each tool applies the same plan limits the dashboard does.

Create a token

  1. Open account settings and find the MCP tokens section.
  2. Choose New token, give it a label (up to 80 characters) that says where it will live, such as "Claude Code on my laptop", and pick an expiry: 30 days, 90 days, 1 year, never.
  3. Copy the token. It is shown exactly once, together with ready-made setup for the clients below. Layerbase stores only a hash, so a lost token cannot be shown again: revoke it and create a new one.

Tokens start with lbm_. The settings list shows each active token by its label and its first 8 characters after the prefix, with when it was last used and when it expires. Create one token per agent or machine, so you can revoke one without touching the others.

Revoke a token

Select the trash icon next to a token in MCP tokens and confirm. Any agent using it loses access on its next request; revoking cannot be undone. An expired token stops working the same way. Nothing about a token is cached between requests, so a revoke, an expiry or a change to your account takes effect on the very next call.

Connect your client

Replace lbm_YOUR_TOKEN with your token. The new-token dialog in settings fills it in for you.

Claude Code

Terminal
claude mcp add --transport http layerbase https://layerbase.com/api/mcp --header "Authorization: Bearer lbm_YOUR_TOKEN"

Codex CLI

~/.codex/config.toml
[mcp_servers.layerbase]
url = "https://layerbase.com/api/mcp"
http_headers = { "Authorization" = "Bearer lbm_YOUR_TOKEN" }

Grok

Terminal
grok mcp add --transport http layerbase https://layerbase.com/api/mcp --header "Authorization: Bearer lbm_YOUR_TOKEN"

OpenCode

opencode.json
{
  "$schema": "https://opencode.ai/config.json",
  "mcp": {
    "layerbase": {
      "type": "remote",
      "url": "https://layerbase.com/api/mcp",
      "enabled": true,
      "headers": {
        "Authorization": "Bearer lbm_YOUR_TOKEN"
      }
    }
  }
}

Cursor

~/.cursor/mcp.json
{
  "mcpServers": {
    "layerbase": {
      "url": "https://layerbase.com/api/mcp",
      "headers": {
        "Authorization": "Bearer lbm_YOUR_TOKEN"
      }
    }
  }
}

Claude Desktop

claude_desktop_config.json
{
  "mcpServers": {
    "layerbase": {
      "command": "npx",
      "args": [
        "mcp-remote",
        "https://layerbase.com/api/mcp",
        "--header",
        "Authorization:${AUTH_HEADER}"
      ],
      "env": {
        "AUTH_HEADER": "Bearer lbm_YOUR_TOKEN"
      }
    }
  }
}

Claude Desktop reaches remote servers through the mcp-remote bridge, which needs Node.js. The file is in ~/Library/Application Support/Claude on macOS and %APPDATA%\Claude on Windows. Restart Claude Desktop after saving.

Other clients (JSON)

Your client config
{
  "mcpServers": {
    "layerbase": {
      "url": "https://layerbase.com/api/mcp",
      "headers": {
        "Authorization": "Bearer lbm_YOUR_TOKEN"
      }
    }
  }
}

The common shape for clients that speak streamable HTTP. Check your client docs for the exact file and key names.

Then ask the agent to call whoami. If it answers with your email and plan, the connection works.

Tools

The server offers 21 tools. Each one calls the same code path as the matching dashboard action, so plan limits, quotas, ownership rules and maintenance pauses apply exactly as they do in the browser. Slow operations (create, start, wake, branch) return at once; the agent polls get_database until the status is running. Team-scoped tools take an optional team slug from list_teams and otherwise use your own default team.

Account and teams

whoamiread only

The account the token acts as: email, role and plan. A good first call to confirm the connection works.

list_teamsread only

Teams the account belongs to, which one is the default, and which ones it owns.

get_usageread only

The resource pool (RAM, vCPU, storage) and how much each database draws from it.

Databases

list_enginesread only

Engines and versions the account can create, and which ones need a paid plan.

list_databasesread only

Every database the account can reach, its own and its teams', with branches included.

get_databaseread only

Status, engine, version and settings of one database. Never includes credentials.

get_connection_stringread only

The connection string and credentials for one database. The agent receives a secret.

get_database_usageread only

Storage and memory use of one database.

create_databasechanges state

Create a database with the same plan, quota and placement checks as the dashboard. Only a team owner can create on a team.

start_databasechanges state

Start a stopped database.

stop_databasechanges state

Stop a running database. Open connections drop.

wake_databasechanges state

Wake a hibernated database.

Queries

run_querycan destroy data

Run one statement, exactly like the dashboard query console: SQL, a mongosh or Redis command, a REST request for HTTP engines, or a TigerBeetle operation. Writes are allowed.

Branches

list_branchesread only

Branches of one database (database owner only).

create_branchchanges state

Fork a database into a copy-on-write branch (database owner only). Can reuse an existing branch of the same name.

reset_branchcan destroy data

Discard every change on a branch and re-fork it from its parent. Requires confirmName.

delete_branchcan destroy data

Delete one branch and its data. Refuses a primary database. Requires confirmName.

delete_databasecan destroy data

Permanently delete a database (database owner only). Requires confirmName and confirm: true; a database with branches also needs cascade: true.

Integrations

list_integrationsread only

Whether the team has Vercel and GitHub connected. Connecting an integration stays in the dashboard.

list_preview_mappingsread only

The rules that wire git branches to databases: which branch reads production, which gets a staging branch, and the env var name.

update_preview_mappingchanges state

Change a preview mapping rule. Only the fields sent change.

Some things are deliberately not tools: billing and plan changes, team membership, API keys, backups and restores, and connecting or replacing an integration. Do those in the dashboard.

Permissions and security

  • A token is your account. It can do anything the tools allow that you could do yourself, and nothing more. On a team you do not own, the agent gets the same refusals you would: a team member can query and start a shared database, but only the database owner can delete or branch it, and only the team owner can create databases on the team. See Teams.
  • Destructive tools ask for proof. reset_branch, delete_branch and delete_database refuse unless confirmName matches the database name exactly as list_databases shows it. delete_database also needs confirm: true, and refuses a database with branches unless cascade: true is sent. Deleting through MCP takes the same final backup as deleting from the dashboard, and can take a few minutes for that reason.
  • Queries can write. run_query runs with your own database access, so an agent can change or drop data. It shares the query console's rate limit and result-size limit (see Query console). For bulk work, give the agent a connection string instead.
  • Credentials reach the agent. get_connection_string returns the database password into the agent's context. Treat that conversation like any other place a secret lives.
  • Account standing is checked on every call. MCP access pauses entirely while an account is past due, suspended or frozen, and stops for a deleted account. This is stricter than the REST API and CLI, because an agent runs unattended.
  • Calls are logged without their contents. Each tool call is logged with the tool name, the account and the token it used, and whether it succeeded. Arguments and results are not logged.
  • Treat tool results as data. Query results can contain text anyone wrote into your database. Use an agent that asks before running destructive tools, and give production tokens only to agents you trust.

Troubleshooting

401 missing_token
The request had no bearer token. Check that your client sends Authorization: Bearer lbm_YOUR_TOKEN as a header, with the word Bearer and a space before the token.
401 invalid_token
The token is revoked, expired, or mistyped. A token is lbm_ followed by 40 characters with no spaces or quotes. Create a new one in account settings if in doubt.
403 not_available
The MCP server is not on your account yet while it rolls out.
403 account_past_due, account_suspended, account_frozen or account_deleted
MCP access is paused for the account's standing. Update your payment method on the plan page or contact support. Access returns on the next call once the account is in good standing.
503 unavailable
Layerbase could not verify the token right now. This is not a bad token; retry shortly.
confirmation_mismatch
confirmName did not match. The error names the database as Layerbase shows it; ask the agent to use that exact name.
rate_limited
run_query hit the query console's per-account limit. Wait a minute, or connect to the database directly for heavy work.
database_owner_required, unknown_team or not_found
The tool is limited to the database or team owner, the team slug is not one of yours (check list_teams), or the database id is not one this account can reach (check list_databases).
The client gives up on delete_database
Deletion backs the database up first and can take a few minutes. If your client has a tool timeout, raise it, then call list_databases to see whether the delete finished before retrying.
Claude Desktop does not show the server
Check that Node.js is installed (the mcp-remote bridge runs with npx), that the JSON is valid, and restart Claude Desktop after saving the file.