Skip to content

feat(mcp): add project cost confirmation elicitation - #391

Merged
barryroodt merged 10 commits into
mainfrom
feat/hosted-project-cost-elicitation
Sep 3, 2026
Merged

barryroodt merged 10 commits into
mainfrom
feat/hosted-project-cost-elicitation

Conversation

@barryroodt

@barryroodt barryroodt commented Aug 28, 2026 •

Copy link
Copy Markdown
Contributor

What kind of change does this PR introduce?

Feature.

Implements the create_project slice of AI-1091.

What is the current behavior?

create_project requires a valid confirm_cost_id before execution. Clients without elicitation capability keep this flow.

What is the new behavior?

When costConfirmation is configured with enabledTools: ['create_project'], form-capable clients can confirm the quoted cost inside create_project through the SDK-native inputRequired and inputResponse flow. The signed request state binds the method and authenticated principal, and carries tool: 'create_project', the project name, region, organization, and quoted cost.

The form has no properties. Consent lives in the elicitation action, so clients use their native accept, decline, and cancel controls. Accept creates the project. Decline or cancel returns a normal result without creating anything.

Argument mismatches are rejected, and cost drift starts confirmation again. A state signed for the wrong tool fails before argument or acceptance checks. Empty elicitation mode maps count as form-capable; URL-only or absent elicitation uses the legacy confirm_cost flow. A precomputed legacy ID cannot bypass confirmation for a form-capable request.

This PR covers create_project only. It does not change stdio, and there is no create_branch implementation in this PR.

How to Review

  1. Server setup

    • packages/mcp-server-supabase/src/server.ts
    • Inspect how costConfirmation, its enabledTools, and request state enter the server.
  2. Confirmation flow and executor seam

    • packages/mcp-server-supabase/src/tools/cost-confirmation.ts, packages/mcp-server-supabase/src/tools/account-tools.ts, packages/mcp-server-supabase/src/tools/util.ts, and packages/mcp-utils/src/server.ts
    • Inspect the private module that owns the project state discriminator, action-only schema, and capability helper, plus signed state, project creation behavior, request-state verification, and SDK result passthrough.
  3. Behavioral coverage

    • packages/mcp-server-supabase/src/server.test.ts
    • Inspect the modern and legacy paths.
  • Does capability detection select the right lane?
  • Is signed state bound to the right request, tool, and principal?
  • Do decline and cancel avoid project creation?
  • Does the legacy flow remain strict?

Verification

  • pnpm --filter @supabase/mcp-server-supabase test src/server.test.ts -t "create_project cost confirmation via elicitation" passed 8 tests.
  • pnpm --filter @supabase/mcp-server-supabase build passed.
  • pnpm test:packed-platform-consumer passed all 3 public-surface assertions.
  • biome ci . passed.

Additional context

This is a fresh, project-only implementation separate from the earlier draft in #389.

When confirmation is configured, the public schema makes confirm_cost_id optional so form-capable clients can call create_project directly. Capability-free execution still requires a valid ID.

Known limits remain: signed state has no single-use replay prevention, and the existing final cost-check concurrency race remains.

The platform PR will first pin the pkg.pr.new preview, then switch to the released npm version.

This implementation was AI-assisted. The verification evidence is above, and human review is required before merge.

@barryroodt
barryroodt requested a review from a team as a code owner August 28, 2026 19:41
@barryroodt barryroodt added the publish-preview Runs `publish-preview` workflow to publish preview packages via https://pkg.pr.new/ label Aug 28, 2026
@pkg-pr-new

pkg-pr-new Bot commented Aug 28, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

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

commit: f9831db

@coveralls

coveralls commented Aug 28, 2026 •

Copy link
Copy Markdown

Coverage Report for CI Build 33730956831

Coverage decreased (-0.3%) to 96.298%

Details

  • Coverage decreased (-0.3%) from the base build.
  • Patch coverage: 17 uncovered changes across 2 files (161 of 178 lines covered, 90.45%).
  • No coverage regressions found.

Uncovered Changes

File Changed Covered %
packages/mcp-server-supabase/src/tools/account-tools.ts 132 117 88.64%
packages/mcp-server-supabase/src/tools/cost-confirmation.ts 18 16 88.89%
Total (4 files) 178 161 90.45%

Coverage Regressions

No coverage regressions found.


Coverage Stats

Coverage Status
Relevant Lines: 3257
Covered Lines: 3155
Line Coverage: 96.87%
Relevant Branches: 444
Covered Branches: 409
Branch Coverage: 92.12%
Branches in Coverage %: Yes
Coverage Strength: 53.74 hits per line

💛 - Coveralls

Comment thread packages/mcp-utils/src/server.ts Resolved

@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.

Left some comments

@barryroodt

Copy link
Copy Markdown
Contributor Author

Left some comments

Thanks - all items should be addressed.

@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.

Tested locally one more time and everything seems ok. Left a non-blocking comment with. suggestion to reduce the dependency of platform on duplicated ellicitation requests - #391 (comment)

@gregnr gregnr left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Very clean, nice 👍

@barryroodt

Copy link
Copy Markdown
Contributor Author

Small text-only follow-up from the #394 review: create_project prompt shortened to 3 lines (rate + lifecycle + docs link + rate caveat), no behaviour change, tests unchanged (no assertion existed on the message).

- honor decline/cancel before re-checking cost drift, so a declined
  confirmation is never re-prompted when the quote shifted between
  rounds
- read the cost recurrence suffix from cost.recurrence instead of a
  hardcoded /month, so a non-monthly cost renders correctly
- use the SDK's schema-validated isCallToolResult instead of a
  content-array duck-type check, so ordinary tool data shaped like
  {content: [...]} is JSON-wrapped instead of passed through raw
Regression test for dc34da5: a tool result shaped like ordinary
business data with a content array (but not valid ContentBlocks)
must be JSON-wrapped, not mistaken for a passthrough CallToolResult.
@barryroodt
barryroodt force-pushed the feat/hosted-project-cost-elicitation branch from 171060b to f9831db Compare September 3, 2026 07:59
@barryroodt
barryroodt merged commit fb50882 into main Sep 3, 2026
7 checks passed
barryroodt added a commit that referenced this pull request Sep 3, 2026
Stacked on [#391](#391). Review that
first. This is part of
[AI-1091](https://linear.app/supabase/issue/AI-1091/ship-form-mode-cost-confirmation-stage-a-supabasemcp).

## What kind of change does this PR introduce?

Feature: add form-mode cost confirmation to `create_branch`.

## What is the current behavior?

#391 provides the shared confirmation codec/verifier, `ServerContext`,
result passthrough, and project flow. Branch creation still uses the
existing hash validation.

## What is the new behavior?

Modern form clients can call `create_branch` without `confirm_cost_id`.
They receive an action-only, property-less prompt for **$0.01344/hr**
(about **$9.68 over 30 days**).

Acceptance creates the branch from signed arguments. Missing responses
and changed costs re-prompt. A wrong-tool state or changed arguments
fail. Decline and cancel create no branch.

Capability-free and URL-only clients keep hash validation. A supplied
legacy ID cannot bypass the capable-client flow. Project-scoped
injection works, and existing output fields such as `with_data` remain.

## How to Review

1. **Server and shared state**
   - `packages/mcp-server-supabase/src/server.ts`
   - `packages/mcp-server-supabase/src/tools/cost-confirmation.ts`

2. **Branch handler and pricing**
   - `packages/mcp-server-supabase/src/tools/branching-tools.ts`
   - `packages/mcp-server-supabase/src/pricing.ts`

3. **Behavioral coverage**
   - `packages/mcp-server-supabase/src/server.test.ts`
- Inspect the capable, legacy, argument-binding, and project-scoped
paths.

- [ ] Is `create_branch` enabled only through the intended server path?
- [ ] Does the discriminated state bind project ID, branch name, and
`BranchCost`?
- [ ] Do capable clients always use elicitation, even with a legacy ID?
- [ ] Do accept, decline, cancellation, wrong-tool, and argument-change
outcomes look correct?

## Verification

- `pnpm --filter @supabase/mcp-server-supabase test src/server.test.ts
-t "create_(project|branch) cost confirmation via elicitation"` (17
passed)
- `pnpm --filter @supabase/mcp-server-supabase build` (typecheck + build
passed)
- `pnpm test:packed-platform-consumer` (3 assertions passed)
- `pnpm exec biome ci .` (passed)

## Additional context

Commit `24535f1 chore: refresh management API types` adds two generated
lines to `packages/mcp-server-supabase/src/management-api/types.ts`
because the CI generation gate detected upstream schema drift. Feature
behavior and verification remain unchanged.

This does not change `create_project`, `mcp-utils`, platform adapters,
stdio, pricing values, manifests, or docs.

Known limits: confirmations are not single-use, legacy IDs remain
precomputable, and the branch rate remains the existing package
constant.

AI-assisted; human review required.
@supabase-releaser supabase-releaser Bot mentioned this pull request Sep 2, 2026
barryroodt pushed a commit that referenced this pull request Sep 4, 2026
Makes `tools/list` adapt to `costConfirmation.enabledTools` to prevent
supported clients from getting prompted twice, from both the legacy
tools and elicitation strategy, surfaced when testing
supabase/platform#37717

The `tools` callback now receives the per-request `ServerContext` so
`tools/list` can vary by client:
- If both `create_project` and `create_branch` are in
`costConfirmation.enabledTools`, `get_cost` and `confirm_cost` are no
longer advertised. They stay callable, so a client that already knows
the names keeps working.
- If only one `create_` tool is enabled, the two cost tools are still
advertised because the other `create_` tool still needs a
`confirm_cost_id`, but their `type` argument is narrowed.
- `create_project` and `create_branch` drop `confirm_cost_id` when
they're in `enabledTools`, since a form-capable client confirms inline
and never needs it.

Legacy clients are unaffected.

## How to review

Run the server over HTTP w/ `costConfirmation` enabled for both tools
and connect a form-capable client (e.g. Claude Code w/ the SDK v2 flag
as described
[here](#394 (review))).
The tool list should have no `get_cost` or `confirm_cost`, and
`create_project` no longer has a `confirm_cost_id` argument. Connect
again without declaring `elicitation` and both tools are back.

## Notes

I renamed the test helper `setupFormCapable` to `setupModern` and made
its capabilities explicit via a `FORM_CAPABLE` constant, because
technically legacy clients can have form capabilities.

The #391 test "a supplied `confirm_cost_id` cannot bypass the form" is
now "is rejected". The field isn't in a form-capable client's schema
anymore, so strict arg parsing errors instead of routing to the form.
barryroodt pushed a commit that referenced this pull request Sep 4, 2026
🤖 I have created a release *beep* *boop*
---


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

##
[0.8.0](mcp-utils-v0.7.0...mcp-utils-v0.8.0)
(2026-09-04)


### Features

* **mcp:** add project cost confirmation elicitation
([#391](#391))
([fb50882](fb50882))
* **mcp:** hide legacy cost tools from form-capable clients
([#411](#411))
([2f04461](2f04461))
</details>

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

##
[0.12.0](mcp-server-supabase-v0.11.0...mcp-server-supabase-v0.12.0)
(2026-09-04)


### Features

* group lints in `get_advisors` response
([#390](#390))
([48d593a](48d593a))
* **mcp:** add branch cost confirmation elicitation
([#394](#394))
([867a160](867a160))
* **mcp:** add project cost confirmation elicitation
([#391](#391))
([fb50882](fb50882))
* **mcp:** hide legacy cost tools from form-capable clients
([#411](#411))
([2f04461](2f04461))


### Bug Fixes

* ensure correct escaping in advisor
([#407](#407))
([a6cf4a0](a6cf4a0))
* make server instructions intent-based instead of naming tools
([#372](#372))
([fc54ea2](fc54ea2))
</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 Oct 12, 2026
#467)

## What kind of change does this PR introduce?

Bug fix, but it only changes tool descriptions.

## What is the current behavior?

OpenAI's reworked plugin dashboard runs a new automatic scanner. It
flagged 4 of our tools with "This tool update needs further review
before it can go live" and gave no reason
([thread](https://supabase.slack.com/archives/C051L8U2EJF/p1791533910225779)).

- **`create_project` / `create_branch`** have *held updates*. The only
change in the held version is that `confirm_cost_id` is no longer
required, which came from the form-elicitation work (#391, #394, #411).
The scanner connects without form elicitation to a server that has it
configured, so it sees the optional field.
- **`confirm_cost` / `deploy_edge_function`** are flagged on their
*live* definitions, which we didn't change. So the scanner is
re-reviewing tools it already approved.

The held update breaks Codex users, who can't create projects through
the plugin. Codex validates against the old live schema, which requires
`confirm_cost_id`, but our server leaves that field out for form-capable
clients and rejects it
([AI-1303](https://linear.app/supabase/issue/AI-1303), #466). Once
OpenAI approves the held update, Codex's schema matches ours again.

The scanner gives no reason, so this is our read. The held change looks
like a weaker cost safeguard explained in protocol jargon, and neither
create tool says it makes a billed resource. `confirm_cost` says "Ask
the user to confirm" but only hashes its input, which goes against
OpenAI's
[descriptions-that-match-behavior](https://developers.openai.com/plugins/plugin-guidelines#descriptions-that-match-behavior)
guideline. `deploy_edge_function` never said a redeploy replaces the
live function, and its `verify_jwt` text used SHOULD ALWAYS/ONLY
instructions.

## What is the new behavior?

This PR only changes descriptions. The schemas, required fields and
annotations stay the same.

- The `create_project` / `create_branch` descriptions now say the
resource is billed and the user has to agree to the cost first.
- `confirm_cost_id` uses one shared description from
`tools/confirmation.ts`, without the elicitation jargon. It carries the
`get_cost` → `confirm_cost` steps, so only clients that receive the
field see them. Form-capable clients never get the field, and the
`create_*` descriptions no longer mention the hidden cost tools.
- `confirm_cost` now says it returns a confirmation ID for the quoted
cost, and that it should only be called after the user explicitly
agrees.
- `deploy_edge_function` now says a deploy replaces the live function
and serves it publicly right away. I rewrote `verify_jwt` as plain
guidance and left `openWorldHint: false` on purpose.

## How to Review

1. **Cost confirmation**
- `packages/mcp-server-supabase/src/tools/confirmation.ts`,
`account-tools.ts`, `branching-tools.ts`
- Check that the create tool and `confirm_cost` descriptions match what
the code does.
2. **Edge functions**
   - `packages/mcp-server-supabase/src/tools/edge-function-tools.ts`

**Review questions**

- [ ] Is `openWorldHint: false` still right for `deploy_edge_function`?

## Verification

I dumped `tools/list` before and after for three client shapes: no
elicitation, elicitation configured with a client that doesn't support
forms (what the scanner sees), and a form-capable client. With the
`description` keys removed, the before and after JSON is identical for
all three. Typecheck, Biome and the unit suite pass. No tests check this
wording.

## Additional context

After release I'll hit Rescan in the OpenAI dashboard, and only Appeal
if the tools are still flagged, since an appeal pauses scans. If they're
still flagged, we'll also ask #partner-openai-supabase for more detail.

Refs #466, AI-1303
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.

4 participants