Skip to main content
Use the Supabase provider when Supabase Auth is your OAuth authorization server. Supabase handles login, consent, Dynamic Client Registration, and token issuance. Your MCP server verifies Supabase tokens and can use the caller’s access token for Row Level Security. This guide covers the Supabase setup path. Use the auth providers API reference for exact oauthSupabaseProvider() options, defaults, and errors.

Configure Supabase

In the Supabase Dashboard:
  1. Go to Authentication > Sign In / Providers > OAuth Server.
  2. Enable the OAuth 2.1 server.
  3. Enable Allow Dynamic OAuth Apps so MCP clients can register.
  4. Set the consent screen URL to a route your app implements, such as http://localhost:3000/auth/consent.
  5. Enable at least one sign-in method for users.
  6. Copy the Project ID and publishable key.
Supabase redirects users to your consent screen with an authorization_id. Your app must implement that route. The consent route signs the user in, loads the authorization details, and submits approve or deny back to Supabase. Start from the mcp-oauth-supabase-template if you do not already have a consent UI. Do not deploy the MCP server without a working consent route.

Set environment variables

The provider reads the project ID. Your consent UI and tools that call Supabase use the publishable key. For local or self-hosted Supabase, set the Supabase URL instead of the hosted project ID:

Configure the MCP server

For local or self-hosted Supabase, pass the URL directly when you prefer not to use environment variables:
New Supabase projects use ES256 tokens and expose JWKS metadata. Legacy HS256 projects may need a JWT secret; use the API reference for that option.

Use Supabase RLS from tools

Create a Supabase client per request with the caller’s access token. This lets Row Level Security evaluate policies as the authenticated user. Install the Supabase client when your tools call Supabase:
Use this pattern only when the tool needs to call Supabase as the user. For server-owned operations, use a separate server credential and enforce your own authorization checks.

Verify the setup

Run the server and connect with an OAuth-capable MCP client.
Confirm these cases:
  • The client discovers Supabase OAuth metadata.
  • The user can sign in and approve consent.
  • Authenticated tool calls include ctx.auth.user.userId.
  • RLS-backed tools only return rows visible to the caller.

Next steps

Supabase OAuth template

Start from a consent UI wired for mcp-use and Supabase.

Supabase MCP Authentication

Review Supabase’s MCP authentication guide.

User Context

Use Supabase user data inside tools.

Supabase provider API reference

Look up exact provider options and defaults.