Repository navigation
feat: add --oauth login for the --http local entry - #404
Open
barryroodt wants to merge 1 commit into
Open
barryroodt wants to merge 1 commit into
barryroodt wants to merge 1 commit into
Conversation
barryroodt
force-pushed
the
feat/local-http-oauth
branch
2 times, most recently
from
September 3, 2026 09:01
3ba6f78 to
41dbecd
Compare
commit: |
5 tasks
barryroodt
force-pushed
the
feat/local-http-oauth
branch
from
September 3, 2026 12:02
41dbecd to
6a4af2c
Compare
Coverage Report for CI Build 45984885641Coverage decreased (-1.0%) to 97.237%Details
Uncovered Changes
Coverage RegressionsNo coverage regressions found. Coverage Stats💛 - Coveralls |
barryroodt
force-pushed
the
feat/local-http-oauth
branch
2 times, most recently
from
September 4, 2026 11:52
d2ff583 to
1661479
Compare
mattrossman
reviewed
Sep 4, 2026
| }, | ||
| "dependencies": { | ||
| "@mjackson/multipart-parser": "^0.10.1", | ||
| "@modelcontextprotocol/client": "catalog:", |
Collaborator
There was a problem hiding this comment.
Note @modelcontextprotocol/client becomes a runtime dep with my changes so --oauth can use the SDK's auth() flow. Platform already has it at the same catalog version as a devDependency of mgmt-api, so the next bump will pull it (plus some small transitives) into the image as install weight. Platform doesn't reach the code that uses it though.
Collaborator
|
Pushed changes to trim this PR, though might be good to check the @modelcontextprotocol/client dep decision w/ platform team in case they object. We already get a nice DX boost from #401 alone so not the end of the world if we don't get OAuth in near term. Tested w/ |
mattrossman
approved these changes
Sep 4, 2026
Rodriguespn
pushed a commit
that referenced
this pull request
Sep 7, 2026
## What kind of change does this PR introduce? Feature: a local Streamable HTTP entry (`--http`) for the MCP server. ## What is the current behavior? The local server is stdio only. It needs a PAT in the client config, cannot show elicitation dialogs, and the hosted handler only runs inside platform. Matt asked for a local HTTP entry [here](https://supabase.slack.com/archives/C051L8U2EJF/p1788277668621589). ## What is the new behavior? - `--http` on the primary bin serves the tools over Streamable HTTP on `http://127.0.0.1:3111/mcp`. - The client sends a bearer PAT per request in `Authorization`; the server stores nothing and has no token flag or env var. - Runs with `legacy: 'stateless'`, so 2025-era clients keep working; one stderr line per request names the protocol era. - The startup banner prints a ready-to-paste `.mcp.json` snippet using `${SUPABASE_ACCESS_TOKEN}`. - Modern form-capable clients get cost-confirmation dialogs for `create_project` and `create_branch`; legacy clients keep `get_cost` / `confirm_cost`. - `CONTRIBUTING.md` recommends `--http` for local development; stdio stays documented as the alternative. ## How to Review 1. **CLI entry** - `packages/mcp-server-supabase/src/cli.ts` - The `--http` branch: flag parsing, the `--access-token` rejection, and the hand-off to the entry. 2. **Per-request pipeline** - `packages/mcp-server-supabase/src/transports/local-http-entry.ts` - Bearer extraction, the 401 shape, the era log line, the banner, and the `costConfirmation` wiring. 3. **Body cap and node adapter** - `packages/mcp-server-supabase/src/transports/local-http-entry.ts` - `readJsonBody` owns the 4 MiB cap (413) and the -32700 parse-error envelope for malformed JSON; `toNodeHandler` from `@modelcontextprotocol/node` adapts the fetch handler to `node:http`. 4. **Shared handler option** - `packages/mcp-server-supabase/src/transports/http.ts` - The new `legacy` option; the hosted handler must still default to `reject`. 5. **Tests** - `packages/mcp-server-supabase/src/transports/local-http-entry.test.ts` - Bearer handling, 401 without a challenge, Host guard, path routing, 4 MiB cap, malformed JSON, dropped-client resilience. 6. **Docs** - `CONTRIBUTING.md` - The `--http` steps and the `.mcp.json` snippet match what the banner prints. **Review questions** - [ ] Is the `--http` flag surface (flags, port, path) the minimal one we want to support long term? - [ ] Does `legacy: 'stateless'` here leave the hosted handler's `reject` posture untouched? - [ ] Is the 401 without `WWW-Authenticate` the right call given the Claude Code discovery behaviour? - [ ] Are loopback binding plus the Host guard enough for a per-request PAT that is never stored? - [ ] Do the tests cover the observable contract (status codes, headers, era line) rather than internals? ## Verification Commands on `5b86dd4` (CI on 5b86dd4 pending): - `packages/mcp-utils tsup --clean`: ok - `pnpm --filter @supabase/mcp-server-supabase test src/transports`: 26/26 pass - `pnpm --filter @supabase/mcp-server-supabase typecheck`: clean - `pnpm --filter @supabase/mcp-server-supabase build`: ok - `node dist/cli.js --version`: 0.11.0 - `node dist/cli.js --http --port 0`: banner printed - `pnpm test:packed-platform-consumer`: 3/3 pass - `pnpm exec biome ci .`: clean How to test: 1. `npx https://pkg.pr.new/@supabase/mcp-server-supabase@5b86dd4 --http` (or `pnpm build`, then `node packages/mcp-server-supabase/dist/cli.js --http`). `--project-ref` is optional; without it `create_project` is available too. 2. `export SUPABASE_ACCESS_TOKEN=<pat>` and paste the printed snippet into `.mcp.json`. 3. Start Claude Code with `MCP_SDK_GENERATION=v2 MCP_PROTOCOL_NEGOTIATION=auto` and ask for a preview branch: expect the cost dialog and a `modern` era line on stderr. 4. Repeat with stable Claude Code: no dialog, `get_cost` / `confirm_cost` guidance, `legacy` era line. Verified by Barry on 2026-09-03 on staging through the #404 stack at d397277 (hand-rolled bridge): OAuth login, project list, $0 project created directly, branch cost dialog shown in Claude Code 2.1.258 with a `modern 2026-07-28` era line. The toNodeHandler head (5b86dd4) has not had a staging run yet. ## Additional context - The entry uses `toNodeHandler` from `@modelcontextprotocol/node`. The 4 MiB body cap is entry-owned because the SDK collects request bodies unbounded. `hono` arrives as a transitive of `@hono/node-server` and is never loaded on this path. `packages/mcp-server-supabase/src/transports/local-http-entry.ts`. - 401 without `WWW-Authenticate`: a challenge sends Claude Code into OAuth discovery against localhost. `packages/mcp-server-supabase/src/transports/local-http-entry.ts`. - Loopback only (`127.0.0.1`), SDK Host guard, `/mcp` only; other paths get 404. `packages/mcp-server-supabase/src/transports/local-http-entry.ts`. - Scoping through the same flags as stdio (`--project-ref`, `--read-only`, `--features`, `--api-url`), not query params; `--access-token` with `--http` exits 1. `packages/mcp-server-supabase/src/cli.ts`. - Cost-confirmation `requestState` principal is the SHA-256 of the bearer. `packages/mcp-server-supabase/src/transports/local-http-entry.ts`. - OAuth sign-in is out of scope here; it arrives in #404, stacked on this PR. - This PR absorbs the `--http` entrypoint shape from #402. - The `check` job is red from upstream management-API types drift; it fails on `main` too. Closes AI-1166 --------- Co-authored-by: Matt Rossman <[email protected]>
Rebuilt on current main from the OAuth-only part of the original branch. The --http entry itself reached main in #401, so the earlier commits that built it are dropped. --oauth signs in with Supabase OAuth in the browser, stores the session in ~/.supabase/mcp-oauth.json and attaches the token to every request, so the client config needs no Authorization header. The entry now also rejects requests that carry a browser Origin.
barryroodt
force-pushed
the
feat/local-http-oauth
branch
from
November 27, 2026 10:46
9f140f0 to
db7a018
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What kind of change does this PR introduce?
Adds browser sign-in to this repo's local
--httpdev server.What is the current behavior?
Each developer creates and stores a PAT so their client can send it in every request's
Authorizationheader.What is the new behavior?
--http --oauthopens Supabase sign-in through the MCP SDK, using the hosted MCP server matching--api-urland a callback at127.0.0.1:3112. The entry attaches the token, so clients can omitheaders. Concurrent requests share one refresh because refresh tokens are single use.Registration and tokens persist in
~/.supabase/mcp-oauth.json(mode0600).SUPABASE_HOMEoverrides the directory. Delete the file to sign out.Both modes now return 403 for requests with a browser
Origin, alongside the existingHostcheck. OAuth has no per-request gate. The trade-off is that any local process that can reach the port can use your scopes.How to Review
In the diff, start with
oauth-client.tsfor sign-in and refresh. Inlocal-http-entry.ts, the principal stays stable across refreshes so pending confirmations still work.cli.tshandles failed sign-in with exit code 1. Seelocal-http-entry.test.tsfor request coverage andCONTRIBUTING.mdfor usage.@modelcontextprotocol/clientas a runtime dependency.Verification
On the rebuild,
tsc --noEmitandpnpm format:checkpassed. All 1,054 tests passed across 36 files, including 66 local HTTP tests. Each new test failed when its corresponding behavior was removed.Nobody has run a real sign-in on the rebuilt commit. Pedro verified September's version on staging and production.
oauth-client.tshas no dedicated tests.Additional context
I replaced the 20 commits with one on current main since #401 merged the HTTP entry.
oauth-client.tsis byte-identical to the previous head. Matt approved before the rebuild, so I'd welcome a fresh review. Pedro closed #421 in favour of this PR.Part of AI-1166