Skip to content

feat(mcp-server-supabase): let the SQL classifier decide run_notebook prompts - #584

Open
barryroodt wants to merge 2 commits into
feat/sql-classify-stepfrom
feat/run-notebook-classify-step
Open

barryroodt wants to merge 2 commits into
feat/sql-classify-stepfrom
feat/run-notebook-classify-step

Conversation

@barryroodt

@barryroodt barryroodt commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

Fourth PR in the stack replacing #454. Base: #583 (4/5).

Why this changes

#583 lets hosts choose the SQL classifier that execute_sql and apply_migration use for confirmation. This PR makes run_notebook use that classifier too. It changes when the notebook asks for approval. A separate check still decides how each cell runs.

Decision How run_notebook makes it
Does the notebook need approval? With confirmation enabled on a writable server, ask once for the whole notebook if any primary-database cell fails the plain-read check or the configured classifier flags a cell.
How does each cell run? A primary-database cell runs read-only if it passes the plain-read check and the built-in regex clears it. Otherwise it uses the server’s configured mode.

The default confirmation classifier uses the same regex as the run-mode check. Setting a custom classifier replaces the regex only for confirmation. For example, if the custom classifier flags a plain read that the regex clears, the user sees a prompt and the cell still runs read-only after approval. Conversely, if only the regex flags that cell, it uses the server’s configured mode and can run without a prompt if nothing else requires approval.

What the user sees

The classifier checks primary-database cells in notebook order and stops at the first flag. With the default classifier, the only visible change is that the prompt says “at least 1 destructive.” With a custom classifier, that wording can be misleading. For example, the classifier may flag SQL because it was too large to inspect.

If classification fails, the tool returns SqlClassifierCallError before any cell runs. When the user answers a matching prompt, the tool applies that answer without classifying again.

Hold the release until #585 lets hosts see when classification failed.

Refs AI-1338

…un_notebook

Tests for run_notebook asking the configured classifier which cells need
confirmation. They fail on this commit by design: the tool does not read
the option yet.

- One row per outcome class (clears, flags, cannot answer) on each path
  that classifies, and the paths that must not call the classifier.
- When the classifier cannot answer, the error the host's onToolCall gets
  is a SqlClassifierCallError with no cause and none of the classifier's
  text.
- The loop classifies only selected primary-database cells, in notebook
  order, and stops at the first flagged cell.
- An aborted classification runs no cell and asks about no later cell.
- The prompt: the count, the 'at least 1 destructive' clause and the
  permanent-removal line follow the classifier's flag.
- The run mode follows the built-in regex, whatever the classifier says.

Two existing prompt assertions move from a destructive count to the
approved 'at least 1 destructive' clause.
… prompts

run_notebook now asks the server's classify step whether a run needs
confirmation, instead of the built-in regex. It checks the database cells
in notebook order and stops at the first flagged cell, so the prompt says
"at least 1 destructive" in place of a count. A classifier that cannot
answer fails the call before any cell runs.

The built-in regex still picks the mode each cell runs in, so the mode is
the same on every host and an accepted resend needs no classifier call.

The classifier doc comments now say which prompt wording belongs to
execute_sql and apply_migration, and that run_notebook shows one prompt for
the whole notebook.
@barryroodt
barryroodt force-pushed the feat/run-notebook-classify-step branch from 0de08fc to d101ca5 Compare November 23, 2026 08:44
@barryroodt
barryroodt force-pushed the feat/sql-classify-step branch from 27619f2 to 0162527 Compare November 23, 2026 08:44

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant