Skip to content

Simplify hosted cost confirmation with SDK elicitation - #389

Closed
barryroodt wants to merge 3 commits into
barryroodt/ai-1091-tool-policy-foundationfrom
barryroodt/ai-1091-sdk-cost-confirmation
Closed

barryroodt wants to merge 3 commits into
barryroodt/ai-1091-tool-policy-foundationfrom
barryroodt/ai-1091-sdk-cost-confirmation

Conversation

@barryroodt

@barryroodt barryroodt commented Aug 28, 2026 •

Copy link
Copy Markdown
Contributor

Why

This replacement keeps the hosted cost-confirmation path small and on the public contracts we already approved: the official SDK’s inputRequired flow + mcp-utils ToolPolicy.

It’s a draft stacked on barryroodt/ai-1091-tool-policy-foundation at 9ecf0bd. It supersedes #378 and #379 as the path under review, while both stay open as paused drafts until slice 1 and hosted acceptance prove this approach. I’ll decide when to close them.

What changed

  • Added a package-private transport adapter for the SDK elicitation form and elicitUrl shapes, including the default and classic confirm_cost legacy shim paths.
  • Added the cost policy for initial/final rate reads, sealed request state, expiry, response handling, telemetry, zero-rate calls, stale terminal requests, and legacy lanes.
  • Added an optional neste d hosted elicitation block to createSupabaseMcpServer. When supplied, its dependencies are required and fail closed.
  • Kept the existing public entry points unchanged: no new entry point or runtime export, no SupabasePlatform rate methods, no v2 spec/type/API reader changes, and no mcp-utils diff.
  • Left the obsolete custom runtime, state, codec, recovery, capability, gate, and interaction modules behind rather than porting them.

A regression against the real SDK showed that the widened modern output schema stripped BranchResponse.with_data. The schema is now .loose(), preserving real API fields while accepted business output and the exact declined/cancelled structuredContent remain valid.

Per my 2026-08-28 decision, the kill switch falls back to the existing confirm_cost flow here. Hard-block behavior is deferred to the planned follow-up work.

Legacy project discovery, branch discovery, cost confirmation, and creation output still match the baseline. Stdio remains on its existing hardcoded l egacy path.

Verification

Charter gates are green at 9f7eef207043ea3dffc81f99fcbb631b71516c35:

  • Build: 3 packages
  • mcp-utils: 3 files, 53 tests
  • Supabase unit + integration: 17 files, 264 tests
  • Packed consumer: 3 assertions
  • Focused modern output-schema check: 1
  • Legacy project + branch byte checks: 1
  • Format: 97 files

Before merge

  • Review the security delta from the custom codec to the SDK codec, especially the floor-second expiry boundary.
  • Do an error-path UX pass.

Hosted cross-instance acceptance stays with the platform PR. The external plan now matches that sequence.

@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@9f7eef2
pnpm add https://pkg.pr.new/@supabase/mcp-server-supabase@9f7eef2
pnpm add https://pkg.pr.new/@supabase/mcp-utils@9f7eef2

commit: 9f7eef2

@barryroodt

Copy link
Copy Markdown
Contributor Author

Closing this as superseded by #391, which provides a fresh project-only implementation against main.

@barryroodt barryroodt closed this Aug 28, 2026
barryroodt added a commit that referenced this pull request Sep 3, 2026
## What kind of change does this PR introduce?

Feature.

Implements the `create_project` slice of
[AI-1091](https://linear.app/supabase/issue/AI-1091/ship-form-mode-cost-confirmation-stage-a-supabasemcp).

## 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](#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.
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.

1 participant