Prerequisites
- Supabase CLI: Install from Supabase CLI Installation Guide
- Supabase Account
- Docker Required to solve bug https://github.com/orgs/supabase/discussions/32815
- Node.js/Bun: For building your MCP server
Create your mcp-use project
your-project-name with a basic MCP server setup.
Install dependencies
Init supabase project
supabase with a basic Supabase project setup.
Quick Deployment
Deploy your MCP server to Supabase in one command using our automated deployment script:What the script does
The deployment script automatically:- ✅ Validates Supabase CLI installation and authentication
- ✅ Checks if the project is initialized and linked
- ✅ Patches
config.tomlwith your project ID - ✅ Builds your MCP application with the correct
MCP_URLandMCP_SERVER_URL - ✅ Copies build artifacts to the function directory
- ✅ Sets
MCP_URLandCSP_URLS(Supabase project URL) environment variables - ✅ Deploys the function to Supabase Edge Functions
- ✅ Uploads widgets to the storage bucket
Prerequisites for the script - Supabase CLI installed (
npm install -g supabase) - Logged in to Supabase (supabase login) - Docker running (for
deployment)Manual Deployment
Setting Up Your MCP Server for Supabase
1. Initialize a Supabase Project
If you don’t have a Supabase project yet:2. Create an Edge Function
supabase/functions/mcp-server/.
3. Adapt your MCP Server to use Deno (required for Supabase Edge Functions)
Widgets in the resources folder are automatically registered. Additional widgets can be registered manually. (see UI Widgets)Complete ExampleA full working example is available in the repository: Supabase Example
4. Widgets assets
Widget assets should be served from a CDN, for example Supabase Storage. Upload the content of the dist/resources/widgets folder to Supabase Storage and set the MCP_URL environment variable to the URL of the dist folder. E.g if you created a bucket called “widgets” in Supabase Storage:URLs Required: Supabase deployments need these URLs because widget files are served from static storage while API calls go to the edge function:
MCP_URL: Where widget assets are storedMCP_SERVER_URL: Enables build-time URL injection for static deploymentsCSP_URLS: Whitelists the Supabase project domain in the Content Security Policy (use base URL without path)
5. Build the mcp-use app
6. Copy the dist folder to the function directory
7. Configure the function in config.toml
8. Set Environment Variables for CSP
Set environment variables before deploying so the MCP server can configure Content Security Policy (CSP) to allow widgets to make API calls and load assets:Environment Variables:
MCP_URL: Whitelists the edge function domain for API calls from widgetsCSP_URLS: Whitelists the Supabase project URL (without path) for widget assets (JS/CSS) and storage access. Use the base project URL likehttps://nnpumlykjksvxivhywwo.supabase.co(no/storage/*or other paths needed). Supports comma-separated values for multiple domains.
appsSdkMetadata['openai/widgetCSP'] instead of using the global CSP_URLS environment variable. See UI Widgets documentation for examples.9. Deploy the Function
Using the MCP Server
You can connect to the MCP Server from any MCP client. Below are examples for browser and Node.js using themcp-use library.
The MCP Server URL
Browser/Client-Side Usage
Node.js Usage
CORS Issues
- Ensure your CORS headers are correctly configured
- Check that the Accept header is included in requests
- Verify your Authorization header has the correct token
”Initialising login role…” Appears Multiple Times
During deployment, you’ll seeInitialising login role... appear 2-3 times. This is normal behavior - the Supabase CLI authenticates separately for:
- Project linking
- Widget file upload to storage
- Public file upload to storage
Deployment Stuck on “Initialising login role…”
If the deployment script hangs atInitialising login role... (no progress for several minutes) or you see authentication errors, Supabase may have temporarily banned your IP address. This is a known issue tracked on GitHub.
Solution:
- Go to your database settings:
https://supabase.com/dashboard/project/{PROJECT_ID}/database/settings#banned-ips - Check if your IP is listed under “Banned IPs”
- Click “Unban” to restore access
- Retry the deployment
This typically happens after multiple failed connection attempts or when the connection is interrupted unexpectedly. The ban is temporary and automatic.