Skip to content

feat(mcp-server-supabase): detect instant elicitation cancels - #483

Merged
barryroodt merged 16 commits into
mainfrom
barryroodt/ai-1328-detect-instant-elicitation-cancels-from-clients-that-answer
Oct 26, 2026
Merged

barryroodt merged 16 commits into
mainfrom
barryroodt/ai-1328-detect-instant-elicitation-cancels-from-clients-that-answer

Conversation

@barryroodt

@barryroodt barryroodt commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

What kind of change does this PR introduce?

Feature

What is the current behavior?

Claude's cloud surfaces answer our confirmation prompts with cancel on their own, about half a second after we ask, and never show the user anything (anthropics/claude-ai-mcp#1085). Right now that looks the same as a person closing the prompt, so we can't count it and the model can't tell the user what happened. It came up in SU-495524, where the logs showed ~0.55 s between input_required and the cancel.

What is the new behavior?

Confirmation state for execute_sql, apply_migration, run_notebook, create_project and create_branch now carries a signed issued_at. If a cancel comes back less than 1 s after we asked, the result tells the model the client cancelled before a prompt was likely shown and that nothing ran, e.g. "The client cancelled this confirmation about 0.6 s after it was sent, faster than a person could answer, so it likely never showed you a prompt. The SQL was not run." We measure from when the resume request reaches the tool, so our own platform reads don't count. Normal cancels keep today's text, and structuredContent stays { status: 'cancelled' }.

I went with 1 s because nobody reads SQL and answers that fast, and the auto-cancels we saw were ~0.55 s. A wrong call only changes the text and the telemetry. It never changes whether anything runs: a cancel the server inspects never runs anything. There's a separate, older gap where a cancel resume that drops the form capability takes the legacy bypass in execute_sql/apply_migration and runs the SQL. That's AI-1360 and it's out of scope here.

The input_response observation fact now gets elapsed_ms, plus instant: true on instant cancels, so we can see which clients do this (ties into AI-1273). Nothing changes in hosted/mgmt-api logging.

Alternatives considered

I considered one neutral cancel message for every cancel, whatever the timing. It would confirm nothing ran and link the SQL confirmations troubleshooting page for clients that answer elicitations automatically. I ultimately decided against it and kept the threshold instead: the instant text would be wrong after a real human cancel, and the neutral text is too vague, so the model would have to guess what happened. With neutral text, the model also can't tell the user their client likely never showed a prompt. An added benefit to this update is we get the extra telemetry data wrt response times.

Verification

I ran a smoke test on the in-process server with real time and a stubbed platform, using execute_sql with a DROP TABLE. An immediate cancel got the instant text with elapsed_ms: 7, instant: true. A cancel after 1.6 s got the usual "SQL execution was cancelled." with elapsed_ms: 1603 and no instant. Both came back as { status: 'cancelled' }, and the SQL never ran.

Closes AI-1328

@barryroodt
barryroodt requested a review from a team as a code owner October 23, 2026 14:43
@coveralls

coveralls commented Oct 23, 2026 •

Copy link
Copy Markdown

Coverage Report for CI Build 40098459377

Warning

No base build found for commit 8aca22c 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.587%

Details

  • Patch coverage: 76 of 76 lines across 5 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: 5700
Covered Lines: 5593
Line Coverage: 98.12%
Relevant Branches: 1097
Covered Branches: 1040
Branch Coverage: 94.8%
Branches in Coverage %: Yes
Coverage Strength: 156.2 hits per line

💛 - Coveralls

@barryroodt barryroodt self-assigned this Oct 23, 2026
@barryroodt
barryroodt merged commit 5ad1a2a into main Oct 26, 2026
5 checks passed
@barryroodt
barryroodt deleted the barryroodt/ai-1328-detect-instant-elicitation-cancels-from-clients-that-answer branch October 26, 2026 13:24
@supabase-releaser supabase-releaser Bot mentioned this pull request Oct 24, 2026
barryroodt added a commit that referenced this pull request Oct 27, 2026
…ires (#490)

## What kind of change does this PR introduce?

Bug fix

## What is the current behavior?

If a client answers a confirmation form after the signed `requestState`
has expired, the SDK rejects the resume with a generic JSON-RPC `-32602`
"Invalid or expired requestState". The client can't tell the
confirmation timed out, and the model never gets a hint to retry, so to
the user it looks like our server is broken.

We saw this in a support ticket where Codex answered a `create_branch`
cost form about 21 minutes after the first call. The token only lasts 10
minutes. [AI-1337](https://linear.app/supabase/issue/AI-1337) and
[AI-1318](https://linear.app/supabase/issue/AI-1318) look like the same
thing from Codex.

## What is the new behavior?

Our verify hook now catches only the SDK's `expired` case and returns a
normal tool result with `isError: true` and `structuredContent: {
status: 'expired', message }`, with the same JSON in `content` (same
shape as #483). The model then reads something like:

> This confirmation expired after 10 minutes. Call `create_branch` again
to get a new confirmation.

The SDK checks expiry after the MAC, so only an authentic token reaches
this path. The lifetime in the message comes from the same TTL the codec
uses.

This covers all six tools that resume signed state: `create_project`,
`create_branch`, `execute_sql`, `apply_migration`, `run_notebook` and
`create_edge_function_secret`. The expired check runs before any other
routing, so an expired resume never runs anything, even when the client
swaps in a non-destructive query or drops form capability. We take the
tool name from the tool being called and never read the expired payload.

Malformed, bad-MAC and bind failures still get the SDK's `-32602`
unchanged. The TTL and the SDK stay the same. Confirmation tools now
record a `resume_validation` fact with `result: 'expired'`, so we can
finally see these.

## Verification

I ran a local smoke test on the in-process server with a mocked clock:

- expired `create_branch`: expired result, no branch created
- expired `execute_sql` resumed with a non-destructive `INSERT`: expired
result, SQL not run
- expired `execute_sql` from a client without form capability: expired
result, SQL not run
- tampered token: `-32602`
- valid resume inside the TTL: branch created

## Additional context

Closes [AI-1372](https://linear.app/supabase/issue/AI-1372)
barryroodt added a commit that referenced this pull request Oct 29, 2026
…ck (#500)

## What kind of change does this PR introduce?

Bug fix, test fixture only.

## What is the current behavior?

`pnpm test:packed-platform-consumer` has been failing on main since
#483. That PR added `elapsed_ms` to the `input_response` observation
fact, and the fixture's exact-shape `deepEqual` on the destructive-SQL
resume facts doesn't expect the key, so it throws there. Everything
after that line gets skipped for the packaged artifact, including the
privacy checks (no `PRIVATE_` value and no destructive-SQL
`requestState` token in the recorded observation scopes).
[CI](https://github.com/supabase/mcp/blob/c242e63b38ed1cea5d5bd2f32e49aa38d290776a/.github/workflows/tests.yml)
doesn't run this check, which is why nothing flagged it.

## What is the new behavior?

`scripts/fixtures/packed-platform-consumer/modern-call.mjs` accepts
`elapsed_ms` on that fact the same way it already accepts `durationMs`
on the `returned` operation fact. The shape check stays exact and the
value has to be a finite number >= 0, so a missing `elapsed_ms` or any
other extra key still fails.

## Verification

```sh
pnpm install --frozen-lockfile
pnpm test:packed-platform-consumer
```

The script builds both packages itself. With this change it prints
`[PASS] modern-mcp-call` and exits 0. On main it fails at the
resume-facts `deepStrictEqual`, with a diff showing the extra
`elapsed_ms` key.
Rodriguespn pushed a commit that referenced this pull request Oct 29, 2026
🤖 I have created a release *beep* *boop*
---


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

##
[0.15.0](mcp-server-supabase-v0.14.0...mcp-server-supabase-v0.15.0)
(2026-10-29)


### Features

* `submit_feedback` and `delete_feedback` tools
([#474](#474))
([f50318a](f50318a))
* mark client-caused tool errors as ToolCallerError
([#480](#480))
([4a619c1](4a619c1))
* **mcp-server-supabase:** detect instant elicitation cancels
([#483](#483))
([5ad1a2a](5ad1a2a))


### Bug Fixes

* **mcp-server-supabase:** return a tool error when a confirmation
expires ([#490](#490))
([5ab9a98](5ab9a98))
* **mcp-server-supabase:** use POSIX path resolution for edge function
filenames ([#393](#393))
([55d2d24](55d2d24))
* **mcp:** don't split an UPDATE on a semicolon inside a dollar-quoted
value ([#482](#482))
([9f07410](9f07410))
* **mcp:** don't split an UPDATE on a semicolon inside a quoted value
([#459](#459))
([6d93b50](6d93b50))
* **pg-meta:** order list_tables columns by ordinal position
([c242e63](c242e63))
* **pg-meta:** order primary key columns by key position and exclude
INCLUDE columns ([#382](#382))
([25d357c](25d357c))
</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