Skip to content
Menu

DocsReference

View as Markdown

MCP server

Connect Claude and other AI assistants to KeelDB through the remote MCP server to create, branch, inspect and query databases.

KeelDB runs a remote Model Context Protocol server. Connect an AI assistant to it and the assistant can list, create, branch, inspect and query your databases with the same rules as the REST API.

Endpoint and authentication

URLhttps://keeldb.com/api/mcp
TransportStreamable HTTP, stateless (no session id). Responses are plain JSON.
AuthenticationAuthorization: Bearer keel_xxx with an API key
Rate limit120 requests per minute per key, bursts of 60, separate from the REST API budget

The server acts on the API key's organization. Tool results are JSON text. When a tool fails (for example a limit is reached or the database isn't running), the result is marked as an error and the message explains why, so the assistant can tell you. An invalid argument is named in the message (Invalid input: name: Name must be at least 2 characters). The result's structured content carries the REST API's error with its HTTP status: a 4xx asks for different arguments, a 5xx for a retry.

Set up

Create a dedicated API key for each assistant under API keys in the console, for example "Claude Code on my laptop".

Claude Code

export KEELDB_API_KEY=keel_xxx
claude mcp add --transport http keeldb https://keeldb.com/api/mcp --header "Authorization: Bearer $KEELDB_API_KEY"

Clients that support remote HTTP servers with headers

Most clients that can connect to remote MCP servers take a configuration like this:

{
  "mcpServers": {
    "keeldb": {
      "type": "http",
      "url": "https://keeldb.com/api/mcp",
      "headers": {
        "Authorization": "Bearer keel_xxx"
      }
    }
  }
}

Check your client's documentation for the file location and exact keys.

Clients that only start local servers

If your client can only launch local (stdio) servers, for example through claude_desktop_config.json in Claude Desktop, bridge to the remote server with mcp-remote:

{
  "mcpServers": {
    "keeldb": {
      "command": "npx",
      "args": ["-y", "mcp-remote", "https://keeldb.com/api/mcp", "--header", "Authorization:${KEELDB_AUTH_HEADER}"],
      "env": {
        "KEELDB_AUTH_HEADER": "Bearer keel_xxx"
      }
    }
  }
}

Keeping the header value in an environment variable avoids problems with spaces inside args on some clients.

Tools

Database ids look like k7m2x9qa4pz1. Tools that return databases use the database object from the REST API. A tool that reads what a REST endpoint reads returns that endpoint's data with the same fields: regions, databases, branches, moves, snapshots, schedules, backups, jobs and extensions.

ToolWhat it doesArguments
list_plansThe catalog: Free, Launch, and every Dedicated size and topology with its price and whether it can be ordered now. Read-only.None
list_regionsProviders and locations, and whether each is available (as in List regions). Read-only.None
list_databasesAll databases and branches in the organization. Read-only.None
get_databaseStatus, plan, hosts and storage of one database, with its move between plans as tier_move while one is under way and, on Free, free_usage (as in Get a database). Read-only.id
get_free_usageWhere the organization's Free databases stand against the Free limits this month (as in Get Free usage). Read-only.
create_databaseCreates a database. Launch and Scale bill usage; Dedicated bills each node for every started hour, never more than its monthly node price in a calendar month, with extra storage, backup storage and egress billed on top.name (2 to 48 characters), plan (free, launch, scale or dedicated, default free), size and topology (Dedicated only), region (default us-east, the region available today), postgres_version (18, 17 or 16, default 18)
update_databaseRenames, moves between plans, toggles the pooler, sets read replicas, the IP allowlist, a Launch database's autoscaling range, warm floor, scale to zero and what it does at the spend limit, deletion protection, protection (Launch and Dedicated), a branch's expiry, the slow query threshold of its logs or what a single-copy database does when its data center is lost.id, and any of name, plan, size, topology, pooler_enabled, read_replicas (0 to 3), ip_allowlist (array, replaces the list), scale_to_zero_minutes (Launch, or null for always on), on_limit (Launch: hold_min or suspend), min_cu and max_cu (Launch: the autoscaling range; a new range restarts PostgreSQL once), warm_floor (Launch: true keeps a small warm instance while idle, false sleeps at once), deletion_protection, protected, expires_at, relocation (relocate or wait), slow_query_ms (100 to 60,000, or null for 1,000) (as in the REST API)
move_databaseMoves a database between Free or Launch and Dedicated, or back to Launch, with the same hostname. Says in its result whether a move started or the change applied in place (as in the REST API).id, plan, size and topology (Dedicated only)
get_tier_moveProgress of the latest move: state, estimated copy time, lag, switch-over and rollback window, or null when the database never moved. Read-only.id
cancel_tier_moveCancels a move before its switch-over. Marked destructive.id
delete_databaseDeletes a database. Marked destructive. Refused while deletion protection is on or the database is protected.id, confirm_name (must equal the database's name)
create_branchCopies a database now, or as of a past moment within its restore window.id, name (2 to 48 characters), at (optional ISO 8601 time), plan (optional), expires_at (optional, at most 30 days ahead)
list_branchesDirect branches of a database. Read-only.id
get_connection_stringConnection URIs (direct, pooled, read-only) including the password. Logged in the audit log.id
run_sqlRuns SQL as the database owner: 30 second timeout, 500 rows per result.id, sql, read_only (default true)
get_insightsSlowest queries, table sizes, unused indexes, cache hit ratio and live sessions. Read-only.id
get_metricsDatabase size, sessions and commits per second on the primary, one sample every 5 minutes while the database runs (see Metrics). Read-only.id, range (1h, 24h, 3d, 7d, 14d or 30d, default 24h)
get_logsThe database's PostgreSQL logs, newest first: errors and warnings, slow queries and sessions, including the SQL run with run_sql (application keeldb-sql; see PostgreSQL logs). Read-only.id, and any of kind (array of error, slow_query, connection), since, until, min_duration_ms, search, limit (default 50), cursor
get_compute_metricsCPU and memory of the primary against its allocation, its cache hit ratio, sessions and commits per second, per minute up to per hour (see Metrics). Read replicas are not included. Read-only.id, range (1h, 24h, 3d, 7d, 14d or 30d, default 24h)
list_extensionsThe extension catalog, or with id that database's catalog with each extension's status. Read-only.id (optional)
enable_extensionHas KeelDB install a managed extension (and what it requires) in a database; one that needs a preloaded library (pg_cron, TimescaleDB) restarts the database once. Check with list_extensions.id, name (for example vector, postgis, pg_cron, timescaledb)
disable_extensionHas KeelDB drop a managed extension. Refused while objects in the database use it. Marked destructive.id, name
list_backupsBackups with status and restore test results (as in List backups). Read-only.id
list_snapshotsA database's snapshots, newest first, with what each holds and its size. Read-only.id
create_snapshotTakes a named snapshot, kept until deleted. Billed per GB-month on Launch and Dedicated.id, name (1 to 63 characters)
restore_snapshotRestores a ready snapshot into a new branch or a new database, with its own hostname and password.snapshot_id, target (branch or database), name (2 to 48 characters)
delete_snapshotDeletes a snapshot. Marked destructive.snapshot_id, confirm_name (must equal the snapshot's name)
get_backup_scheduleThe daily, weekly and monthly snapshot schedules and their next runs. Read-only.id
set_backup_scheduleLaunch and Dedicated: turns schedules on or off and sets how many snapshots each keeps.id, and any of daily, weekly, monthly (each enabled, keep), hour_utc, weekday, month_day
run_operationRestarts, fails over, takes a backup or rotates the password. Returns job_id and status (as in Start an operation).id, kind (restart, failover, backup or rotate_password)
get_jobStatus of an operation started with run_operation (the job object of Get a job). Read-only.job_id

The rules and limits are the REST API's: see Branching, Limits and Run a query.

Safety

  • Deleting needs the exact name. delete_database and delete_snapshot only delete when confirm_name matches the name; otherwise they return deleted: false with the expected name. The server also tells assistants to get your explicit confirmation before calling destructive tools. Read what your assistant proposes before you approve it.
  • SQL is read-only by default. run_sql uses read_only: true unless the assistant sets it to false. A read-only run takes one statement, in a read-only transaction that is never committed, on a read-only instance when the database has one, and that statement cannot lift it. The one exception is an extension that opens its own connection, such as dblink: what it does on that connection is outside the run. Approve writes deliberately.
  • Some tools disrupt running apps. run_operation with rotate_password makes the old password stop working within seconds, and restart or failover drop connections (a restart of a single-copy database refuses new ones until it is back, usually within a minute).
  • Connection strings are secrets. get_connection_string returns the password into the conversation. Avoid it when the assistant doesn't need to connect directly.
  • Use a dedicated API key. A key can do what its role and permissions allow, which can include deleting databases; give an assistant a key limited to what it needs (for example db.read only). Give each assistant its own key, so you can revoke it on its own and see its actions in the audit log, shown as "API key" and its name to owners, admins and developers, and as "API key" to billing members.
  • Mind the bill. create_database, create_branch and restore_snapshot can start paid databases, which are billed hourly until deleted; snapshots and schedules add snapshot storage; protected: true keeps a Launch database's compute on.