db_dump
Full SQL dump of the project's database — schema (CREATE TABLE / INDEX / TRIGGER) + every row as INSERT statements. The output is standard SQL you can pipe into any SQL database client to restore, or migrate to Postgres via pgloader.
Returns the raw .sql file as a string. One call gives you the complete raw SQL database's schema and rows to take anywhere. A project that keeps its tables in the managed database has no raw SQL database to dump (RAW_DATABASE_NOT_READY); its managed rows are read with db_browse (plane: "managed") and their schema and row counts with db_describe.
Table access declarations and sensitive-column marks are platform policy, not SQL. Their labels travel as comment lines in the SQL preamble and, parsed, as excluded_security_policy.policies (labels only, never applied by a SQL restore); a warning appears only when the list is non-empty. policies: [] on a successful capture means no table-access declarations were found in this capture — it does not establish that access is safe or preserve your application's authorization, and member join definitions and handler authorization are outside that list. After restoring, redeploy db/schema.ts (access rules are set there and take effect on deploy), then verify with db_scope_list.
excluded_security_policy.capture (v1) is the capture receipt, carrying identity, hashes and times only: canonical project_id and database_id (the top-level project_id echoes your reference), sql_sha256 / schema_sha256 / policy_sha256, and policy_observed_at, data_observation_started_at, data_observation_completed_at, binding_checked_at. The hashes detect changed bytes against metadata you retain; they are not a signature, not provenance, and not a cross-store snapshot. Matching binding checks before and after mean the same project, owner and database were observed; they do not exclude a change in between. When capture metadata is present but malformed, or its SQL or policy hash does not match, this tool returns DUMP_INTEGRITY_UNCONFIRMED (502) and no SQL. An absent capture (an older API during a rolling release) means no capture-integrity evidence; the informational policy labels may still be present.
Refusals, never a partial file: DATABASE_NOT_INITIALIZED (409 — the dump never creates a database), DUMP_SOURCE_CHANGED (409), DUMP_SCHEMA_CHANGED (409), DUMP_POLICY_INVALID (422), DUMP_UNSUPPORTED_SCHEMA (422), DUMP_ROW_LIMIT_EXCEEDED (413, above 1,000,000 rows in a table — no truncation and no streaming export; narrow with db_export_csv filters), DUMP_CAPTURE_LIMIT_EXCEEDED (413), DUMP_POLICY_UNAVAILABLE (503), DUMP_CAPTURE_UNCONFIRMED (503), DUMP_SCHEMA_UNAVAILABLE (503), PROJECT_ACCESS_DENIED (403).
Example:
{ "project_id": "my-saas" }
// Returns the full .sql as text — write it to disk and you're portable.Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"project_id": "<project_id>"
},
"name": "db_dump"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| project_id | Yes | Project ID (UUID), subdomain, or slug — resolved server-side, no UUID lookup needed. 'default' also works when the account has exactly one project; multi-project accounts must name one (the error lists them). |