Skip to content

fix(mcp-server-supabase): keep a declined or cancelled SQL confirmation final - #581

Merged
barryroodt merged 2 commits into
mainfrom
fix/sql-confirmation-accept-only
Nov 23, 2026
Merged

barryroodt merged 2 commits into
mainfrom
fix/sql-confirmation-accept-only

Conversation

@barryroodt

@barryroodt barryroodt commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

First PR in the stack replacing #454. Base: main (1/5).

Why this changes

When execute_sql or apply_migration asks for confirmation, the client sends a second tool call with the server-issued state and the user’s answer. Today, only Accept skips a second SQL classification. If the user clicks Decline or Cancel, the server checks the SQL again before it honors that answer.

The current regex always gives the same answer for the same SQL. The next PR makes the classifier replaceable, so a parser could flag a query on the first call and a fallback could clear it on the second. Today, that would run SQL the user just declined. #455 added observability and a test that captures this behavior.

What changes

The server checks that the signed state is valid and unexpired, then matches it to the current tool, project ID and exact SQL text. For apply_migration, the migration name must also match.

Answer for a matching prompt What the server does
Decline or Cancel Returns the user’s answer immediately. It skips classification and stops before executing the SQL.
No answer Asks again, even if the classifier now clears the SQL. In that case, the prompt says “This SQL was flagged for confirmation earlier and still needs your approval.”
Accept Runs the SQL, as it does today.

A decline ends that call. The client can still send Accept for the same prompt before the state expires. If the client changes the SQL, the earlier answer doesn’t apply to the new query. The server classifies it as before.

Where to review

Start with checkDestructiveSqlConfirmation, which decides when to classify the SQL. The updated tests show what happens when the classifier changes its answer or throws after the first prompt. SQL confirmation handling · PR diff and tests

Refs AI-1338

…ion final

Once execute_sql or apply_migration has asked for confirmation, only an
accept runs the SQL. A decline or cancel stays final when the SQL classifies
differently on the resend, and the classifier is not consulted. An unanswered
resend that no longer classifies as destructive asks again.

Also covers the state-error path (state for another tool, other SQL or
another project) for the two classes that had no test: SQL that now
classifies as not destructive runs and ignores the stale state, and a
classification that throws returns that failure, not the state error.

The first group fails on this commit by design. The state-error rows pass
on main and guard the gate change that follows.
…on final

When a resend of execute_sql or apply_migration carries state this server
issued for the same tool, project, name and query, only an accept runs the
SQL. A decline or cancel returns its result before the SQL is classified, so
a classifier that throws or now returns "not destructive" cannot hide the
answer or run the SQL. A resend with no answer asks again with a neutral
reconfirm line when the SQL no longer classifies as destructive.

Unchanged: a first call with no state, an accepted resend, and a state error
(another tool's state, changed arguments), which keeps the not-destructive
bypass.

Carried from d06882d and 2015346 on PR 454, without the classifier interface.
@coveralls

Copy link
Copy Markdown

Coverage Report for CI Build 44699107992

Warning

Build has drifted: This PR's base is out of sync with its target branch, so coverage data may include unrelated changes.
Quick fix: rebase this PR. Learn more →

Coverage increased (+0.01%) to 98.152%

Details

  • Coverage increased (+0.01%) from the base build.
  • Patch coverage: 39 of 39 lines across 2 files are fully covered (100%).
  • No coverage regressions found.

Uncovered Changes

No uncovered changes found.

Coverage Regressions

No coverage regressions found.


Coverage Stats

Coverage Status
Relevant Lines: 6354
Covered Lines: 6259
Line Coverage: 98.5%
Relevant Branches: 1384
Covered Branches: 1336
Branch Coverage: 96.53%
Branches in Coverage %: Yes
Coverage Strength: 296.1 hits per line

💛 - Coveralls

@barryroodt
barryroodt merged commit 03afe8e into main Nov 23, 2026
10 of 12 checks passed
@barryroodt
barryroodt deleted the fix/sql-confirmation-accept-only branch November 23, 2026 08:23
@supabase-releaser supabase-releaser Bot mentioned this pull request Nov 23, 2026
barryroodt pushed a commit that referenced this pull request Nov 26, 2026
🤖 I have created a release *beep* *boop*
---


<details><summary>mcp-utils: 0.11.1</summary>

##
[0.11.1](mcp-utils-v0.11.0...mcp-utils-v0.11.1)
(2026-11-26)


### Bug Fixes

* **mcp-ui:** shared project card for create-project and create-branch
([#578](#578))
([efe189f](efe189f))
</details>

<details><summary>mcp-server-supabase: 0.20.0</summary>

##
[0.20.0](mcp-server-supabase-v0.19.0...mcp-server-supabase-v0.20.0)
(2026-11-26)


### Features

* **debugging:** add project issues DEBUG-311
([#546](#546))
([01f8021](01f8021))
* **mcp-server-supabase:** add optional schemas parameter to
generate_typescript_types
([#592](#592))
([7532f53](7532f53))


### Bug Fixes

* **debugging:** link docs once per issue in get_issues
([#610](#610))
([74801d8](74801d8))
* **mcp-server-supabase:** detect import maps uploaded with a ./ prefix
([#591](#591))
([6b8f4dc](6b8f4dc))
* **mcp-server-supabase:** keep a declined or cancelled SQL confirmation
final ([#581](#581))
([03afe8e](03afe8e))
* **mcp-server-supabase:** match Studio's notebook row_limit and clarify
skip and blank-input messages
([#593](#593))
([ad07f1b](ad07f1b))
* **mcp-server-supabase:** skip cost confirmation for $0 projects on
clients without forms
([#608](#608))
([50cfc37](50cfc37))
* **mcp-server-supabase:** stop reusing a removed import map on edge
function redeploy ([#588](#588))
([56093a6](56093a6))
* **mcp-ui:** shared project card for create-project and create-branch
([#578](#578))
([efe189f](efe189f))
* **mcp:** confirm UPDATEs without WHERE that follow a comment and set a
dollar-quoted value ([#612](#612))
([468907a](468907a))
* **mcp:** confirm UPDATEs without WHERE that use inheritance syntax
([#565](#565))
([687b3ee](687b3ee))
* **mcp:** confirm UPDATEs without WHERE when a column name ends in
where ([#557](#557))
([57fa34b](57fa34b))
</details>

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: supabase-releaser[bot] <223506987+supabase-releaser[bot]@users.noreply.github.com>
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.

3 participants