Skip to content

fix(mcp-server-supabase): skip cost confirmation for $0 projects on clients without forms - #608

Merged
myerekapan merged 2 commits into
mainfrom
mertyerekapan/growth-1182-skip-zero-cost-confirm
Nov 25, 2026
Merged

myerekapan merged 2 commits into
mainfrom
mertyerekapan/growth-1182-skip-zero-cost-confirm

Conversation

@myerekapan

@myerekapan myerekapan commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

What kind of change does this PR introduce?

Bug fix

What is the current behavior?

A free org on a client without form support (ChatGPT and most others) has to "confirm" a $0 project:

  1. create_project fails with "first confirm the cost"
  2. get_cost returns $0
  3. confirm_cost with $0
  4. create_project again with the ID, and it works

Some agents get lost in that loop. In the last 3 weeks about 4.5K users never got a project because of it. It also logs ~26K confirmation_required errors a week, 89% of them on free orgs where the cost is $0.

Form-capable clients already skip confirmation when the cost is $0.

What is the new behavior?

Clients without forms get the same rule: if the next project costs $0, create_project creates it on the first call. Paid projects still need confirm_cost_id, unchanged.

If cost confirmation isn't configured, the schema still requires confirm_cost_id, so that path doesn't change.

How to Review

  1. Legacy path in create_project

    • packages/mcp-server-supabase/src/tools/account-tools.ts
    • The $0 check now runs before the missing or mismatched confirm_cost_id checks, and records bypass / zero_cost like the form-capable path.
  2. Tests

    • packages/mcp-server-supabase/src/server.account.test.ts: new $0 cases (no ID, stale ID). The mismatch test moved to a paid org.
    • packages/mcp-server-supabase/src/server.functions.test.ts: the URL-only legacy-lane test moved to a paid org, so it still exercises the confirmation steps.

Review questions

  • Is it fine that a wrong confirm_cost_id is ignored when the cost is $0? Same as the form-capable path.
  • Do paid projects still always need confirmation?

Verification

  • CI=1 pnpm vitest run --project unit src/ in packages/mcp-server-supabase: 976 passed
  • tsc --noEmit and biome check are clean
  • Manual, on staging: ran pnpm dev:http --api-url https://api.supabase.green and connected MCP Inspector without --protocol-era modern, so it's treated as a client without forms. confirm_cost_id shows as optional. Called create_project on a free org with no confirm_cost_id, and the project was created on the first call (ACTIVE_HEALTHY).

@myerekapan
myerekapan requested a review from a team as a code owner November 25, 2026 08:42
@coveralls

coveralls commented Nov 25, 2026 •

Copy link
Copy Markdown

Coverage Report for CI Build 45603159969

Coverage increased (+0.004%) to 98.36%

Details

  • Coverage increased (+0.004%) from the base build.
  • Patch coverage: 12 of 12 lines across 1 file 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: 6401
Covered Lines: 6321
Line Coverage: 98.75%
Relevant Branches: 1403
Covered Branches: 1355
Branch Coverage: 96.58%
Branches in Coverage %: Yes
Coverage Strength: 298.99 hits per line

💛 - Coveralls

@barryroodt barryroodt left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for fixing this!

// Legacy clients only: form-capable clients returned above. Without
// this, a missing ID would hit the opaque hash-mismatch error below.
// Legacy clients only: form-capable clients returned above.
const cost = await getNextProjectCost(account, organization_id);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we hoist getNextProjectCost and a single if (cost.amount === 0 && !ctx.mcpReq.requestState<unknown>()) bypass above if (confirmation && isFormCapable(ctx))? That avoids duplicating the $0 block and keeps the !state guard in both lanes so a declined requestState retry can't slip through if the quote drops to $0.

// Legacy clients only: form-capable clients returned above.
const cost = await getNextProjectCost(account, organization_id);
if (cost.amount === 0) {
observation?.record({

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Recording bypass / zero_cost here widens the meaning of mcp_observer_confirmation_decisions_total{route="bypass", reason="zero_cost"} in platform from form-capable clients only to all lanes (there's no client/era label on that counter). Would be good to add a legacy $0 assertion in observation-confirmation.test.ts to pin this behavior, and flag the metric semantics change if anything tracks form-capable bypasses separately.

@@ -787,6 +793,66 @@ describe('tools', () => {
]);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small test catch just above this hunk (server.account.test.ts:726): capability-free client still succeeds via get_cost -> confirm_cost -> create_project uses a free org ($0), so it now hits the bypass and no longer exercises confirm_cost_id verification. Might be worth moving it to createOrganizationWithBillableNextProject() + PROJECT_COST_MONTHLY, same as the server.functions.test.ts update.

@Rodriguespn Rodriguespn left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@barryroodt already approved, so leaving these notes here as non-blocking suggestions regardless.

Worth noting for rollout: on remote MCP, confirm_cost_id is only optional when EnableMcpCostConfirmationElicitation is enabled and create_project isn't in skip_elicitations, so users with that flag off will still hit Zod validation before reaching this bypass.

@myerekapan

Copy link
Copy Markdown
Contributor Author

@barryroodt already approved, so leaving these notes here as non-blocking suggestions regardless.

Worth noting for rollout: on remote MCP, confirm_cost_id is only optional when EnableMcpCostConfirmationElicitation is enabled and create_project isn't in skip_elicitations, so users with that flag off will still hit Zod validation before reaching this bypass.

Thanks, yeah that's intentional for now, this covers the flag-on path where all the confirmation_required errors come from. If the flag-off share turns out to be meaningful I'll follow up with making it optional there too.

@myerekapan
myerekapan merged commit 50cfc37 into main Nov 25, 2026
6 of 7 checks passed
@supabase-releaser supabase-releaser Bot mentioned this pull request Nov 25, 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.

4 participants