Recipes · Recipe

Query your connected DB from chat

Ask a business question and get an answer backed by governed, read-only SQL.

Goal: ask a business question in plain language and get an answer backed by governed, read-only SQL you can inspect — without a single row ever being copied into Chiron's storage.

This is the database tools in practice. It assumes a database is already connected (Connect a database) and its catalog is built.

1. Confirm the database is ready

text
ingestion_status(project_id)
  -> { readiness: "ready", ... }

If readiness is building_catalog, wait — ingestion_status(project_id, wait_seconds=60) blocks until a terminal state.

text
describe_database(project_id, scope="summary")
  -> domains, tables, business descriptions

This is the metadata Chiron stored *about* the database — enough to ground a question without touching a row.

3. Ask

text
ask_database(
  question = "How many active workspaces signed up in the last 30 days?",
  project_id = "acme-platform"
)
-> {
     "answer": "412 active workspaces were created in the last 30 days.",
     "sql": "SELECT count(*) FROM workspaces WHERE created_at > now() - interval '30 days' AND status = 'active'",
     "columns": ["count"],
     "rows_preview": [[412]],
     "status": "success"
   }

The returned sql is the whole point: the answer is auditable. If you would rather write the query yourself, run_sql runs exactly one read-only SELECT under the same limits.

What governs the query

Every query runs under a read-only role verified at connection time, with query validation, an enforced row_limit and timeout_s, and a per-user audit trail. Results return to the caller and are never persisted. See Privacy & data handling.

Next: Wire up MCP in your editor.