Skip to content

docs: add MCP server guide and surface the OAuth entry point in the skill - #154

Merged
raulb merged 2 commits into
mainfrom
raulb/docs-mcp
Sep 11, 2026
Merged

docs: add MCP server guide and surface the OAuth entry point in the skill#154
raulb merged 2 commits into
mainfrom
raulb/docs-mcp

Conversation

@raulb

@raulb raulb commented Sep 10, 2026

Copy link
Copy Markdown
Member

Part of AI-1009

Are documentations specifically about withOAuthProtectedResource() in the context of using it for MCP servers, clarifying its usage with Supabase Edge Functions or not.

Note: I also updated the library components usage here supabase/supabase#50215 which will ship as part of supabase/supabase#49579.

@raulb
raulb requested review from a team as code owners September 10, 2026 11:29
@pkg-pr-new

pkg-pr-new Bot commented Sep 10, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/@supabase/server@154

commit: 6595eab

@raulb
raulb marked this pull request as draft September 10, 2026 11:29
@mandarini

Copy link
Copy Markdown
Collaborator

A few additions from running this on a real hosted Edge Function (diabuddy, @supabase/server 1.6.0, Deno 2.9). Each would fit in one sentence:

  • Typed client for writes. withSupabase({ auth: 'user' }) without a generic gives SupabaseClient<unknown>. The sample only selects, but a tool that writes fails typecheck: insert({ title }) resolves the argument to never[]. Showing withSupabase<Database> (or <any>) in the sample avoids the first support question.
  • Factory errors are invisible. An exception thrown inside the createMcpHandler factory (a duplicate tool name, a failed schema fetch) comes back as a 500 with nothing in the function logs. A try/catch with console.error in the factory is worth showing.
  • OPTIONS on the metadata route. The entry also answers the preflight for {resource}/oauth-protected-resource with CORS headers. A third row in the table would document it for browser-based clients.
  • The limits are the handler's, not the library's. The one-request, one-response shape comes from building a McpServer per request with createMcpHandler; @supabase/server does not constrain the transport. Saying so avoids the impression that the entries rule out a stateful transport.
  • Root path without a slug. On a CLI older than 2.117 serving the function at /, derivation throws MISSING_RESOURCE_SERVER. One line here saves a support question.

Verified against 1.6.0: the inline-handler TS2345 reproduces exactly as described, and the (req, ctx) => handleMcp(req, ctx) form compiles.

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

Checked the page against origin/main (1.6.0), the URL derivation in src/oauth-protected-resource/url.ts, and a hosted Edge Function running this stack. Three factual fixes inline. The additions worth considering are in a separate comment.

Comment thread docs/mcp.md Outdated
Comment thread docs/mcp.md Outdated
Comment thread docs/mcp.md Outdated
@raulb

raulb commented Sep 11, 2026

Copy link
Copy Markdown
Member Author

@mandarini thank you for the feedback! You were right on all three. I'm currently running tests following across the library blocks supabase/supabase#50215 and future docs supabase/supabase#50218, so I'm hoping to leave this PR ready for review today.

@raulb
raulb requested a review from mandarini September 11, 2026 07:48
@raulb raulb self-assigned this Sep 11, 2026
@raulb
raulb marked this pull request as ready for review September 11, 2026 11:14
…kill

docs/mcp.md explains the pipeline form for MCP servers
(withOAuthProtectedResource before the withSupabase gate), how the
public URLs are derived on Edge Functions and configured elsewhere, the
Supabase Auth prerequisites, the inline-handler inference gotcha, and the
stateless limits.

The agent skill gains the @supabase/server/oauth-protected-resource entry
point and a docs-table row pointing at the new page.

docs(mcp): drop the private sandbox link, match the guide title

docs(mcp): address review on the MCP guide

- CLI 2.117.0 injects SUPABASE_FUNCTION_SLUG only; SUPABASE_PUBLIC_URL is
  honored when set but not set by the CLI.
- The asymmetric-key requirement comes from withSupabase verifying user
  JWTs against the JWKS, not from OAuth 2.1.
- Document OAuthProtectedResourceConfig, UrlOption, fromSupabaseUrl and the
  escape hatches in api-reference.md, and link there.
- Show withSupabase<Database> and a writing tool, the onerror hook for
  factory errors, the OPTIONS preflight row, the root-path-without-slug
  case, and that the one-shot limits belong to the handler, not the library.
@raulb
raulb merged commit 06da558 into main Sep 11, 2026
10 checks passed
@raulb
raulb deleted the raulb/docs-mcp branch September 11, 2026 15:06
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.

2 participants