supabase-mcp-server
Updated at 14 days ago
by alexander-zuev
116
on GitHub
Supabase MCP Server enabling Cursor & Windsurf to use any method from Management API and query your database
Tags
cursor
model-context-protocol
supabase
windsurf
What is supabase-mcp-server
supabase-mcp-server
is a Multi-Cluster Proxy (MCP) server designed to manage connections to multiple Supabase projects. It allows you to route requests based on custom logic, such as user ID or feature flags, to different Supabase instances. This can be useful for A/B testing, regional data sharding, or multi-tenancy setups where different tenants need isolated databases. The server acts as a reverse proxy in front of your Supabase projects.
How to use
The README outlines the following steps for using the supabase-mcp-server
:
- Configuration: You need to define your Supabase project configurations within the
supabase-mcp-server
. This configuration includes the Supabase URL and API key for each project you want to manage. The README mentions using environment variables for sensitive information like API keys. - Routing Logic: Implement your routing logic within the server. This logic determines which Supabase project a given request should be forwarded to. The README mentions that the default version supports routing based on request headers.
- Deployment: Deploy the
supabase-mcp-server
to a server or platform of your choice. It's likely a Node.js application, so you'll need a Node.js environment. - Update client-side code: Change the client side
supabaseUrl
to use thesupabase-mcp-server
URL. - Configuration options:
PORT
- port to bind server toSUPABASE_URLS
- comma seperated Supabase URLsSUPABASE_ANON_KEYS
- comma seperated Supabase ANON keys matchingSUPABASE_URLS
ROUTING_HEADER_KEY
- header used for routing (defaults tox-supabase-route
)
Key features
- Multi-Cluster Management: Centralized management of multiple Supabase projects.
- Custom Routing: Flexible routing logic based on request data.
- Reverse Proxy: Acts as a reverse proxy, abstracting the underlying Supabase infrastructure.
- Configuration via Environment Variables: Securely manage sensitive data using environment variables.
Use cases
- A/B Testing: Route different users to different Supabase instances to test new features or configurations.
- Regional Data Sharding: Store data in different regions to improve performance or comply with data residency requirements.
- Multi-Tenancy: Isolate data for different tenants by routing them to separate Supabase projects.
- Disaster Recovery: Route traffic to a backup Supabase instance in case of failure.
- Feature Flags: Enable/disable features for specific users or groups by routing them to instances with different feature configurations.
FAQ
-
What happens if a Supabase project is unavailable?
- The
supabase-mcp-server
should ideally implement error handling and potentially retry requests or route traffic to a backup instance if one is configured. (This is implied, not explicitly stated, but it's a common requirement for such proxies.)
- The
-
How do I configure the routing logic?
- The current implementation described in the README routes based on header values, you configure
ROUTING_HEADER_KEY
to the header to use, and the header value needs to be an index ofSUPABASE_URLS
.
- The current implementation described in the README routes based on header values, you configure
-
How do I scale the
supabase-mcp-server
?- You can scale it horizontally by deploying multiple instances behind a load balancer. (This is a general principle, not explicitly stated in the README.)