Databases
This reference is auto-generated from the registered MCP tool providers in perspectapiworkers.
It reflects the tools exposed by the per-site Perspect MCP server.
Connection
Use the per-site MCP endpoint:
https://perspect.com/mcp/{siteName}
Authenticate with OAuth or an MCP API key using Authorization: Bearer sk_mcp_....
Tools
database_bind
Title: Bind D1 Database
Attach a D1 database from the org pool to this site's worker script through the security-gated release flow. The database will be accessible as env.<binding_name> in the worker code. This triggers a build+deploy — use Security Auditor review, then Release Manager deployment with deploy_intent_type=database_bind. Valid from: unbound. A database can only be attached to one site at a time.
Required permission: app.deploy
Parameters
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
database_id |
string | Yes | — | The database ID (from database_create or database_list) |
binding_name |
string | Yes | "DB" |
The Worker binding name for this database (e.g. 'DB', 'ANALYTICS_DB'). Must use only letters, digits, and underscores; must start with a letter or underscore. |
Example call
{
"tool": "database_bind",
"arguments": {
"database_id": "string",
"binding_name": "DB"
}
}
Output schema
{
"type": "object",
"additionalProperties": true
}
database_create
Title: Create D1 Database
Provision a new Cloudflare D1 database for the organization. The database is created in the org pool, unattached to any site. Use database_bind with a binding_name to attach it to a specific site's worker. Database limits are based on the organization's subscription tier.
Required permission: app.write
Parameters
This tool accepts no arguments.
Example call
{
"tool": "database_create",
"arguments": {}
}
Output schema
{
"type": "object",
"additionalProperties": true
}
database_delete
Title: Delete D1 Database
Deleting a D1 database is not available as an agent action. Direct the user to do this manually through the admin console.
Required permission: app.write
Parameters
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
database_id |
string | Yes | — | The site database ID to delete |
Example call
{
"tool": "database_delete",
"arguments": {
"database_id": "string"
}
}
Output schema
{
"type": "object",
"additionalProperties": true
}
database_list
Title: List D1 Databases
List all D1 databases in the organization's pool, including which site each is attached to, binding names, status, and migration version.
Required permission: app.read
Parameters
This tool accepts no arguments.
Example call
{
"tool": "database_list",
"arguments": {}
}
Output schema
{
"type": "object",
"additionalProperties": true
}
database_migrate
Title: Apply Database Migrations
Direct migration execution is disabled for agents. Pending D1 migrations must be applied through Security Auditor review and Release Manager deployment with deploy_intent_type=database_migrate. Migration files still live in the migrations/ directory in the app source. Reads SQL files from the sandbox (requires app_init first), compares against the d1_migrations tracking table inside the D1, and applies unapplied ones in filename order. Migration files should be named like 0001_create_users.sql, 0002_add_orders.sql, etc. Write migration files with app_write_file or app_edit_file before calling this tool. D1 SQL constraints: do NOT use BEGIN/COMMIT/ROLLBACK (each migration is auto-wrapped), do NOT use PRAGMA statements, do NOT use ATTACH/DETACH/SAVEPOINT, and do NOT use the _cf_ prefix for table or index names (reserved by D1).
Required permission: app.write
Parameters
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
database_id |
string | Yes | — | The site database ID |
migrations_dir |
string | No | "migrations" |
Path to the migrations directory relative to workspace root. Defaults to 'migrations'. |
Example call
{
"tool": "database_migrate",
"arguments": {
"database_id": "string",
"migrations_dir": "migrations"
}
}
Output schema
{
"type": "object",
"additionalProperties": true
}
database_migrate_status
Title: Database Migration Status
Show migration status: which migrations from the migrations/ directory have been applied and which are pending. Requires app_init first (reads files from the sandbox).
Required permission: app.read
Parameters
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
database_id |
string | Yes | — | The site database ID |
migrations_dir |
string | No | "migrations" |
Path to the migrations directory relative to workspace root. Defaults to 'migrations'. |
Example call
{
"tool": "database_migrate_status",
"arguments": {
"database_id": "string",
"migrations_dir": "migrations"
}
}
Output schema
{
"type": "object",
"additionalProperties": true
}
database_query
Title: Query D1 Database
Execute a single read-only SELECT query against the site's D1 database. Schema or data writes must be performed through migration files and the security-gated release flow. Returns results and execution metadata.
Required permission: app.read
Parameters
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
database_id |
string | Yes | — | The site database ID |
sql |
string | Yes | — | The SQL query to execute |
params |
array<string> | No | — | Positional string parameters for the query (replaces ? placeholders). Runtime execution still coerces existing numeric/boolean callers to strings. |
Example call
{
"tool": "database_query",
"arguments": {
"database_id": "string",
"sql": "string"
}
}
Output schema
{
"type": "object",
"additionalProperties": true
}
database_unbind
Title: Unbind D1 Database
Removing a D1 database binding is not available as an agent action. Direct the user to do this manually through the admin console.
Required permission: app.deploy
Parameters
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
database_id |
string | Yes | — | The site database ID to unbind |
Example call
{
"tool": "database_unbind",
"arguments": {
"database_id": "string"
}
}
Output schema
{
"type": "object",
"additionalProperties": true
}
This page is generated from the registered MCP tool providers. Do not edit it by hand.