MCP server
DBCraft has a built-in Model Context Protocol server. Connect Claude, or any MCP client, and it can explore your schemas, run read-only queries and build dashboards for you, with your permissions and nothing more.
How it works
One endpoint
Your server exposes MCP at <base_url>/mcp over HTTP. Nothing extra to deploy.
OAuth 2.1 with PKCE
Authorization code flow, S256 PKCE only. Clients register themselves at /oauth/register.
Explicit consent
Users sign in to DBCraft and see exactly which permissions a client is asking for before they click Allow.
Isolated tokens
MCP tokens carry their own audience. They are rejected by the web API, and web sessions are rejected by /mcp.
Rotating refresh tokens
Access tokens last 1 hour, refresh tokens 30 days and rotate on every use. Authorization codes are single-use and expire in 60 seconds.
Same rules as the UI
Every tool call runs as the signed-in user, with their data source access and the same PII masking.
Connect a client
- 1Make sure
DBCRAFT__SERVER__BASE_URLis set to your public HTTPS address. The OAuth discovery documents are built from it. - 2In Claude, add a custom connector with the URL
https://your-dbcraft-host/mcp. Other clients take the same URL. - 3The client registers itself and opens DBCraft. Sign in, review the requested permissions, and click Allow.
- 4Ask for what you need, for example "build a dashboard of weekly signups by channel".
For clients configured with a file, the equivalent definition looks like this:
{
"name": "dbcraft",
"transport": "http",
"url": "https://your-dbcraft-host/mcp",
"auth": {
"type": "oauth2",
"client_name": "My MCP client",
"scopes": [
"dbcraft.datasources.read",
"dbcraft.schema.read",
"dbcraft.queries.execute",
"dbcraft.dashboards.read",
"dbcraft.dashboards.write",
"dbcraft.charts.write",
"dbcraft.dashboards.share"
]
}
}Request only the scopes you need. Leave out dbcraft.dashboards.share if the client should never publish links.
Scopes
| Scope | Grants |
|---|---|
| dbcraft.datasources.read | List data sources and read their schemas (never credentials). |
| dbcraft.queries.execute | Run read-only SQL against data sources the user can reach. |
| dbcraft.queries.write | Create, edit and delete saved queries. |
| dbcraft.dashboards.read | List dashboards and read chart configuration and SQL. |
| dbcraft.dashboards.write | Create dashboards, edit them, set layout, delete dashboards you own. |
| dbcraft.charts.write | Add, update and delete charts on dashboards you own. |
| dbcraft.dashboards.share | Turn public links on or off, with optional password and expiry. |
| dbcraft.schema.read | Read curated schema notes on tables and columns. |
| dbcraft.schema.write | Add and replace schema notes. Admins only. |
A tool called without its scope fails with insufficient_scope and names the scope it needed.
Tools
22 tools, covering everything you can do in the dashboard builder.
Data sources and schema
| dbcraft_list_datasources | List the data sources you can see, with connection metadata and no credentials. |
| dbcraft_get_datasource_schema | Live databases, tables and columns, with curated schema notes inlined. |
| dbcraft_sample_table | A small, read-only sample of rows to check a table's shape before writing SQL. |
Queries
| dbcraft_execute_query | Run read-only SQL and get columns and rows back. Writes are rejected. |
| dbcraft_list_saved_queries | Saved queries, grouped into personal and org-wide templates. |
| dbcraft_save_query | Save a query for reuse, personally or as an org-wide template. |
| dbcraft_update_saved_query | Edit a saved query you own. |
| dbcraft_delete_saved_query | Delete a saved query you own. |
Dashboards
| dbcraft_list_dashboards | Dashboards you can see, grouped into personal, global and org-shared. |
| dbcraft_get_dashboard | A dashboard's layout, filters and metadata. |
| dbcraft_create_dashboard | Create an empty dashboard and get its id back. |
| dbcraft_update_dashboard | Change a dashboard's metadata, filters or full layout. |
| dbcraft_delete_dashboard | Delete a dashboard and its charts. Owner or admin only. |
Charts and layout
| dbcraft_add_chart | Add a chart to a dashboard. The SQL is stored and re-run on every render. |
| dbcraft_update_chart | Update a chart. Fields you leave out stay as they are. |
| dbcraft_delete_chart | Remove a chart from its dashboard. |
| dbcraft_arrange_layout | Set every chart's position in one call, on a 12-column grid. |
Sharing
| dbcraft_share_dashboard | Turn a public link on or off, with an optional password and expiry. |
Schema notes
| dbcraft_list_schema_notes | Active notes on a data source, filterable by scope, target and severity. |
| dbcraft_add_schema_note | Add a curated note to a data source, table or column. Admins only. |
| dbcraft_supersede_schema_notes | Replace a set of notes with new ones in a single transaction. Admins only. |
| dbcraft_get_active_user_predicate | The canonical WHERE fragment that filters to active users, if one is defined. |
Schema notes
Schema notes are short, curated facts about your data: which table holds settled payments, how to filter to active users, which columns hold personal data, which timezone timestamps are stored in. Admins attach them to a data source, database, table or column, with a severity of info, warn or critical.
They are inlined into dbcraft_get_datasource_schema: data source notes at the top, table notes on each table, column notes on each column. An agent reads them at the moment it looks at the table, before it writes any SQL, which is where most wrong answers start.
Security model
- A data source the user cannot reach in the UI returns "not found" over MCP as well.
- Query results go through the same PII classification and masking as the UI, so personal data reaches the model masked.
- Read-only mode, query deadlines and row limits apply to every call.
- Unknown clients and unregistered redirect URIs get an error page, never a redirect, so the consent flow cannot be used as an open redirect.
Endpoints
| Path | Purpose |
|---|---|
| /mcp | MCP endpoint (JSON-RPC over HTTP POST) |
| /.well-known/oauth-protected-resource | Protected resource metadata (RFC 9728) |
| /.well-known/oauth-authorization-server | Authorization server metadata (RFC 8414) |
| /oauth/register | Dynamic client registration, public clients only (RFC 7591) |
| /oauth/authorize | Sign-in and consent screen |
| /oauth/token | Code exchange and refresh token rotation |
| /oauth/revoke | Token revocation (RFC 7009) |
| /oauth/introspect | Token introspection (RFC 7662) |
