Skip to content

feat(mcp-server-supabase): add destructive SQL observations - #455

Merged
barryroodt merged 55 commits into
mainfrom
feat/mcp-observability-destructive-sql
Oct 14, 2026
Merged

barryroodt merged 55 commits into
mainfrom
feat/mcp-observability-destructive-sql

Conversation

@barryroodt

@barryroodt barryroodt commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

Why

Platform measures destructive-SQL confirmations for execute_sql and apply_migration alongside cost confirmations. This adds those facts for AI-1273, stacked on #428.

What changed

execute_sql and apply_migration report confirmation decisions, successful issuance, consumed responses, resume validation, and backend operations. Supabase owns these concrete facts; mcp-utils stays generic.

The shared SQL gate stages confirmation facts and outcomes, applying outcomes before dispatching facts. A non-destructive bypass discards both. Accepted valid resumes still skip classification, preserving existing SQL policy and cost behavior.

Built-in facts contain finite values and durations without payloads or IDs; custom producers remain responsible for privacy. Outcomes stay independent of fact contents. With no observer, no facts or timings are recorded.

How to test

pnpm test:packed-platform-consumer

All 3 packed-consumer checks pass, including ESM/CJS SQL confirmation flows.

Trade-offs

  • Hosts own collection; platform #39142 includes SQL observations. Secret collection belongs in a separate PR stacked on this one.
  • Synchronous observers can block despite failure isolation.

@barryroodt barryroodt self-assigned this Oct 5, 2026
@barryroodt barryroodt added the publish-preview Runs `publish-preview` workflow to publish preview packages via https://pkg.pr.new/ label Oct 5, 2026
@barryroodt
barryroodt marked this pull request as ready for review October 5, 2026 14:50
@barryroodt
barryroodt requested a review from a team as a code owner October 5, 2026 14:50
@pkg-pr-new

pkg-pr-new Bot commented Oct 5, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

pnpm add https://pkg.pr.new/@supabase/mcp-server-postgrest@30ef8d2
pnpm add https://pkg.pr.new/@supabase/mcp-server-supabase@30ef8d2
pnpm add https://pkg.pr.new/@supabase/mcp-utils@30ef8d2

commit: 30ef8d2

# Conflicts:
#	packages/mcp-server-supabase/src/tools/confirmation.ts
…-observability-cost

# Conflicts:
#	README.md
…-observability-cost

# Conflicts:
#	packages/mcp-server-supabase/src/tools/account-tools.ts
#	packages/mcp-server-supabase/src/tools/branching-tools.ts
@barryroodt barryroodt changed the title feat: add destructive SQL observations feat(mcp-server-supabase): add destructive SQL observations Oct 14, 2026
barryroodt added a commit that referenced this pull request Oct 14, 2026
)

## Why

Platform measures how Supabase cost confirmations for `create_project`
and `create_branch` behave, without shipping payloads. This is part of
[AI-1273](https://linear.app/supabase/issue/AI-1273/observability-for-mcp-elicitations-and-requests),
building on [#427](#427), with
[#455](#455) adding SQL confirmation
facts.

## What changed

- Supabase owns concrete tool and fact types plus observer aliases, and
classifies tools with a `CURRENT_ELICITATION_TOOLS` lookup; `mcp-utils`
supplies the generic core.
- `create_project` and `create_branch` report confirmation decisions and
protected-operation durations that exclude observer recording latency.
Consumed responses set the outcome before fact dispatch or changed-quote
validation.
- Built-in facts contain bounded values without raw arguments, results,
state or errors. Custom fact producers remain responsible for privacy.
- Existing confirmation behavior stays intact. With no observer, no
facts or timings are recorded.

## How to test

```sh
pnpm test:packed-platform-consumer
```

All 3 packed-consumer checks pass.

## Trade-offs

- Hosts own collection; synchronous observers can block despite failure
isolation.
- Packed checks don't cover branch or cancellation paths.
@barryroodt
barryroodt changed the base branch from feat/mcp-observability-cost to main October 14, 2026 09:06
…y-destructive-sql

# Conflicts:
#	CONTRIBUTING.md
#	packages/mcp-server-supabase/src/observation-confirmation.test.ts
#	packages/mcp-server-supabase/src/observation.ts
#	packages/mcp-server-supabase/src/tools/account-tools.ts
#	packages/mcp-server-supabase/src/tools/branching-tools.ts
#	packages/mcp-server-supabase/src/tools/confirmation.ts
#	scripts/fixtures/packed-platform-consumer/modern-call.mjs
#	scripts/fixtures/packed-platform-consumer/types-check.ts
@barryroodt
barryroodt merged commit 4595698 into main Oct 14, 2026
6 checks passed
@supabase-releaser supabase-releaser Bot mentioned this pull request Oct 14, 2026
@coveralls

Copy link
Copy Markdown

Coverage Report for CI Build 38541493789

Warning

No base build found for commit e4dc6ef on main.
Coverage changes can't be calculated without a base build.
If a base build is processing, this comment will update automatically when it completes.

Coverage: 97.348%

Details

  • Patch coverage: 139 of 139 lines across 2 files are fully covered (100%).

Uncovered Changes

No uncovered changes found.

Coverage Regressions

Requires a base build to compare against. How to fix this →


Coverage Stats

Coverage Status
Relevant Lines: 4722
Covered Lines: 4618
Line Coverage: 97.8%
Relevant Branches: 822
Covered Branches: 779
Branch Coverage: 94.77%
Branches in Coverage %: Yes
Coverage Strength: 102.11 hits per line

💛 - Coveralls

barryroodt pushed a commit that referenced this pull request Oct 14, 2026
🤖 I have created a release *beep* *boop*
---


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

##
[0.9.0](mcp-utils-v0.8.0...mcp-utils-v0.9.0)
(2026-10-14)


### Features

* **mcp-utils:** add bounded request lifecycle observations
([#427](#427))
([b11d62b](b11d62b))
</details>

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

##
[0.14.0](mcp-server-supabase-v0.13.0...mcp-server-supabase-v0.14.0)
(2026-10-14)


### Features

* **advisors:** add health advisor support
([#420](#420))
([8a26508](8a26508))
* **mcp-server-supabase:** add bounded cost lifecycle observations
([#428](#428))
([657d1f3](657d1f3))
* **mcp-server-supabase:** add destructive SQL observations
([#455](#455))
([4595698](4595698))


### Bug Fixes

* **mcp:** clarify cost and deploy tool descriptions for OpenAI scanner
([#467](#467))
([1f9da03](1f9da03))
* **mcp:** stop double cost confirmation on create_project and
create_branch ([#468](#468))
([3c3b1fc](3c3b1fc))
</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>
barryroodt added a commit that referenced this pull request Nov 23, 2026
…on final (#581)

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](https://github.com/supabase/mcp/blob/92be4920a465b507d2efc5196cff252eb9323126/packages/mcp-server-supabase/src/tools/database-operation-tools.ts#L67-L152)
· [PR diff and tests](https://github.com/supabase/mcp/pull/581/files)

Refs AI-1338
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

publish-preview Runs `publish-preview` workflow to publish preview packages via https://pkg.pr.new/

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants