Skip to content

feat: URL-mode secret collection for create_edge_function_secret - #412

Merged
barryroodt merged 13 commits into
mainfrom
feat/url-mode-secret-collection
Sep 17, 2026
Merged

barryroodt merged 13 commits into
mainfrom
feat/url-mode-secret-collection

Conversation

@barryroodt

@barryroodt barryroodt commented Sep 3, 2026 •

Copy link
Copy Markdown
Contributor

Why

Add an Edge Function’s third-party API key without pasting it into the conversation.

What changed

  • Secret values are entered only in Dashboard, never the AI client/model. Local HTTP enables this by default.
  • Discovery requires modern per-request URL capability; existing functions, read-only, auth and platform-support gates remain.
  • Breaking: move confirmation signing to elicitation.requestState:{key,principal,ttlSeconds?} (requestStateKey becomes key).
  • Optional elicitation.confirmation:{enabledTools:readonly ElicitationToolName[]} selects unified cost/SQL forms; enabledTools is explicit, with no implicit library all-tools default, and [] disables forms.
  • elicitation.secretCollection:{connectUrlTemplate} is independently optional.

How to test

Optional manual checks—not reported as run. Use existing credentials and authorized test resources. Accepting cost/SQL actions or saving a secret makes real writes and may incur costs.

Follow setup, install dependencies, then run pnpm dev:http --port 3111 --api-url https://api.supabase.green.

Connect Inspector 2.5.0 Modern with both form and URL support to http://127.0.0.1:3111/mcp?project_ref=REF&read_only=false with Authorization: Bearer <PAT>; omit features and skip_elicitations for normal local defaults.

  • Cost: remove project_ref for an unscoped connection with account tools available. On an eligible billable create_project path, inspect and decline the confirmation to avoid creating a project. Restore project_ref=REF for the SQL and secret checks.
  • SQL: use disposable project/data you are authorized to modify. Inspect and decline destructive execute_sql/apply_migration confirmations.
  • Secret: with Dashboard authentication/write permission and the matching deployed route, call create_edge_function_secret with a fresh name (no value). Save only in Dashboard, return to Inspector and accept within 120s; expect stored:true. Legacy/non-URL clients should not list the tool.

Trade-offs

  • Local HTTP signed state lasts 120s; omitted library TTL remains 600s.
  • Separate timestamp-based fresh-call recovery checks for updates within 600s; it does not extend signed-state validity or describe URL validity.
  • Original-request acceptance checks updated_at>=issued_at; stored:true is not a receipt; another collaborator’s write can satisfy it.
  • Recovery can return recent success; a fresh name avoids that shortcut.
  • Custom API origins require --secret-url-template.

@coveralls

coveralls commented Sep 3, 2026 •

Copy link
Copy Markdown

Coverage Report for CI Build 35218446589

Coverage increased (+0.2%) to 97.055%

Details

  • Coverage increased (+0.2%) from the base build.
  • Patch coverage: 4 uncovered changes across 1 file (359 of 363 lines covered, 98.9%).
  • No coverage regressions found.

Uncovered Changes

File Changed Covered %
packages/mcp-server-supabase/src/tools/secret-tools.ts 219 215 98.17%
Total (6 files) 363 359 98.9%

Coverage Regressions

No coverage regressions found.


Coverage Stats

Coverage Status
Relevant Lines: 4174
Covered Lines: 4072
Line Coverage: 97.56%
Relevant Branches: 681
Covered Branches: 640
Branch Coverage: 93.98%
Branches in Coverage %: Yes
Coverage Strength: 89.82 hits per line

💛 - Coveralls

@barryroodt barryroodt added the publish-preview Runs `publish-preview` workflow to publish preview packages via https://pkg.pr.new/ label Sep 4, 2026
@pkg-pr-new

pkg-pr-new Bot commented Sep 4, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

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

commit: bdb744f

…collection

# Conflicts:
#	packages/mcp-server-supabase/src/server.test.ts
The dashboard route puts the project ref in the path
(/dashboard/project/{ref}/mcp/secrets), so the connect URL is now a
template with {ref} and {name} placeholders instead of a base URL plus
appended query parameters.
The signing fields now live in one `elicitation` block. `requestState`
is required inside it, so the type guarantees every elicitation feature
has the signed-state config. The runtime guard "secretCollection
requires costConfirmation" and its test are removed.

Before (0.12.0):

  costConfirmation: {
    requestStateKey, principal, ttlSeconds?, enabledTools
  }

After:

  elicitation: {
    requestState: { key, principal, ttlSeconds? },
    costConfirmation?: { enabledTools },
    secretCollection?: { connectUrlTemplate },
  }

Runtime behaviour for existing callers is unchanged: one HMAC codec
created lazily when a feature that mints state is enabled, bound to
method + principal, with TTL, tool/project/name scoping and reissue
semantics as before. Removing the guard also allows a new shape: a
host can now enable URL-mode secret collection without cost
confirmation.

BREAKING CHANGE: costConfirmation.requestStateKey, .principal and
.ttlSeconds are removed. Pass elicitation.requestState and keep
enabledTools under elicitation.costConfirmation. Hosted callers migrate
with their package bump; the exact 0.12.0 pin protects them until then.
`replace: true` skips the 10 minute resume-by-key shortcut and issues
the dashboard URL elicitation again. Default false keeps the current
behaviour: a recent update is reported as stored without asking again.
The unsupported-client check and accept/reissue recovery are unchanged,
and `replace` is not part of the signed state.

Result text changes:

- decline and cancel: "Not confirmed. If you already saved it in the
  dashboard, it is stored." The structured result drops `stored: false`
  and keeps `status`.
- accept: "The dashboard reports an update to <name> since this
  request."
- fresh call within 10 minutes: "The dashboard reports an update to
  <name> <N> seconds ago."

Other structured results are unchanged. One focused test covers
`replace: true`.
kemaldotearth added a commit to supabase/supabase that referenced this pull request Sep 8, 2026
## I have read the
[CONTRIBUTING.md](https://github.com/supabase/supabase/blob/master/CONTRIBUTING.md)
file.

YES

## What kind of change does this PR introduce?

Initial build of the URL mode interstitial. Has complete mock data to be
able to view different states (this will be stripped out in the end). A
starting point for us to use as an intercept.

This is linked with @barryroodt ticket in the MCP project.
supabase/mcp#412


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

- **New Features**
- Added an authenticated MCP Secrets page for securely storing API
secrets requested by AI tools.
- Added provider-aware guidance for OpenAI, Anthropic, Resend, and
Stripe keys, including validation warnings and dashboard links.
- Added clear success, cancellation, expiration, error, and
wrong-account states with account switching.
- Added loading placeholders, secret visibility controls, overwrite
warnings, and accessibility announcements.
- **Bug Fixes**
- Improved interstitial animations to respect reduced-motion
preferences.
- Preserved return destinations and related parameters during sign-in
flows.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
@barryroodt
barryroodt marked this pull request as ready for review September 9, 2026 08:48
@barryroodt
barryroodt requested a review from a team as a code owner September 9, 2026 08:48
@mattrossman

Copy link
Copy Markdown
Collaborator

Should create_edge_function_secret be hidden when the client doesn't declare elicitation.url? Latest Claude Code 2.1.267 (which sends elicitation: {}) sees the tool, calls it, and always gets the "cannot open a browser page" error. For the cost confirmation elicitations we hide the legacy confirmation tools on capable modern clients, seems like we could do the opposite here.

CleanShot 2026-09-09 at 17 40 22@2x

@mattrossman

Copy link
Copy Markdown
Collaborator

Couple feedback items on the UX side, neither seems blocking for this MCP-side code, just unexpected:

First, the UI says:

Go back to your AI client and choose "I've completed it" to finish the tool call.

That wording seems specific to the MCP Inspector's UI, are we sure other clients will show the same button, or even require user confirmation? Seems like this should be more generic.

Second, I notice that if I click "Reopen in browser" after submitting a secret, it allows me to input the secret again. That seems innocent from a security POV, but it is a little confusing UX because I can't tell from looking at the page if the elicitation was fulfilled (other than the warning about overwriting an existing secret). I'd expect this flow to feel similar to one-time login links, where you get feedback about whether a link was already used. I see there is a placeholder already-stored page in the dashboard code but nothing points to it currently. Sounds like this will be handled in AI-1170 but one other short-term improvement could be to pass along the issued_at to browser so it can show already stored screen if secret was updated after elicitation issued (though I recognize that's not perfect, since someone else could update the secret outside of elicitation flow).

@mattrossman

Copy link
Copy Markdown
Collaborator

Other UX quirk, if you pass a ?name= with SUPABASE_ prefix it shows the link as "expired", whereas if you make up a different name it lets you submit the secret. Based on the tool schema I gather the intention is for SUPABASE_ prefix variables to be reserved, so the rejection screen saying "expired" is a little unexpected.

made up name=FOOBAR made up name=SUPABASE_FOOBAR
CleanShot 2026-09-10 at 12 02 23 PM@2x CleanShot 2026-09-10 at 12 02 31 PM@2x

@mattrossman mattrossman left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I tested this in the MCP Inspector since AFACT no current coding agents implement URL mode elicitations w/ modern protocol properly, and it generally worked as expected 👍

As long as it's behind a flag for us to test first I'm okay to proceed, comments above are generally non blocking but some are worth discussing.

@barryroodt barryroodt self-assigned this Sep 17, 2026
@barryroodt
barryroodt merged commit fb88629 into main Sep 17, 2026
7 checks passed
@supabase-releaser supabase-releaser Bot mentioned this pull request Sep 17, 2026
barryroodt pushed a commit that referenced this pull request Sep 17, 2026
🤖 I have created a release *beep* *boop*
---


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

##
[0.13.0](mcp-server-supabase-v0.12.0...mcp-server-supabase-v0.13.0)
(2026-09-17)


### ⚠ BREAKING CHANGES

* **mcp:** confirm destructive SQL via elicitation and rename
costConfirmation option
([#408](#408))

### Features

* add --http local HTTP entry to mcp-server-supabase
([#401](#401))
([ff063b4](ff063b4))
* **management:** add v2 api client
([#419](#419))
([02ca542](02ca542))
* **mcp:** confirm destructive SQL via elicitation and rename
costConfirmation option
([#408](#408))
([c9c4e3f](c9c4e3f))
* support skip_elicitations in the local HTTP server
([#434](#434))
([9442e82](9442e82))
* URL-mode secret collection for create_edge_function_secret
([#412](#412))
([fb88629](fb88629))


### Bug Fixes

* discourage host-filesystem access in raw-SQL tool descriptions
([#410](#410))
([641ed1e](641ed1e))
</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

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