New in version: 2.14.0
This guide shows you how to secure your FastMCP server using Supabase Auth. This integration uses the Remote OAuth pattern, where Supabase handles user authentication and your FastMCP server validates the tokens.
Configuration
Prerequisites
Before you begin, you will need:- A Supabase Account with a project
- Your FastMCP server’s URL (can be localhost for development, e.g.,
http://localhost:8000
)
Step 1: Get Supabase Project URL
In your Supabase Dashboard:- Go to Project Settings
- Copy your Project URL (e.g.,
https://abc123.supabase.co
)
Step 2: FastMCP Configuration
Create your FastMCP server using theSupabaseProvider
:
server.py
Testing
Running the Server
Start your FastMCP server with HTTP transport to enable OAuth flows:Testing with a Client
Create a test client that authenticates with your Supabase-protected server:client.py
- Your browser will open to Supabase’s authorization page
- After you authorize, you’ll be redirected back
- The client receives the token and can make authenticated requests
Environment Variables
For production deployments, use environment variables instead of hardcoding credentials.Provider Selection
Setting this environment variable allows the Supabase provider to be used automatically without explicitly instantiating it in code.Set to
fastmcp.server.auth.providers.supabase.SupabaseProvider
to use Supabase authentication.Supabase-Specific Configuration
These environment variables provide default values for the Supabase provider, whether it’s instantiated manually or configured viaFASTMCP_SERVER_AUTH
.
Your Supabase project URL (e.g.,
https://abc123.supabase.co
)Public URL of your FastMCP server (e.g.,
https://your-server.com
or http://localhost:8000
for development)Comma-, space-, or JSON-separated list of required OAuth scopes (e.g.,
openid email
or ["openid", "email"]
).env
file:
server.py