Supabase MCP server capabilities
The Supabase MCP server connects your AI coding agent directly to your Supabase projects. Once authenticated, it allows agents to query the database, manage migrations, deploy Edge Functions, and perform other operations listed in the available tools documentation.
Test MCP server with MCP Inspector
Use the official MCP Inspector to test MCP servers locally. Run: npx -y @modelcontextprotocol/inspector. Then use the local endpoint http://localhost:54321/functions/v1/mcp in the inspector UI to explore available tools and test them interactively.
Deploy MCP server to production
To deploy an MCP server to production, first link your Supabase project: supabase link --project-ref <your-project-ref>. Then deploy the function: supabase functions deploy --no-verify-jwt mcp. The MCP server will be available at https://<your-project-ref>.supabase.co/functions/v1/mcp. Update your MCP client configuration to use the production URL.
MCP frameworks compatible with Supabase Edge Functions
Alternative MCP frameworks compatible with Supabase Edge Runtime include mcp-lite (https://github.com/fiberplane/mcp-lite) and mcp-handler (https://github.com/vercel/mcp-handler).
MCP server example implementation repository
A simple unauthenticated MCP server example is available at: https://github.com/supabase/supabase/tree/master/examples/edge-functions/supabase/functions/mcp/simple-mcp-server.
MCP server deployment on Supabase Edge Functions
MCP (Model Context Protocol) servers can be built and deployed on Supabase using Edge Functions. This guide covers MCP servers that do not require authentication; authenticated MCP support is coming soon.
Prerequisites for MCP server development
To develop MCP servers on Supabase, you need: Docker or a compatible runtime installed and running (required for local development), Deno installed (Supabase Edge Functions runtime), Supabase CLI installed and authenticated, and Node.js 20 or later (required by Supabase CLI).
Initialize new MCP server project
Create a new Supabase project for MCP by running: mkdir my-mcp-server, cd my-mcp-server, supabase init. This creates a project directory with a supabase folder containing config.toml and an empty functions directory.
Create MCP server Edge Function
Generate a new Edge Function for your MCP server by running: supabase functions new mcp. This creates an edge function that can serve as the MCP server endpoint.
MCP TypeScript SDK implementation example
The MCP server function uses the official MCP TypeScript SDK (@modelcontextprotocol/sdk@1.25.3) with WebStandardStreamableHTTPServerTransport, along with Hono (@hono@^4.9.7) for HTTP handling and Zod (@zod@^4.1.13) for schema validation. The code creates an McpServer instance, registers tools, and handles MCP requests via Hono routes. Example implementation: Create Hono app, initialize McpServer with name and version, register tools with inputSchema, handle all requests with WebStandardStreamableHTTPServerTransport, and serve with Deno.serve(app.fetch).
MCP server tool registration example
Tools are registered on an MCP server using server.registerTool(name, schema, handler). Example: server.registerTool('add', {title: 'Addition Tool', description: 'Add two numbers together', inputSchema: {a: z.number(), b: z.number()}}, ({a, b}) => ({content: [{type: 'text', text: String(a + b)}]})).
MCP server function base path configuration
Within Edge Functions, paths are prefixed with the function name. If the function name is not 'mcp', configure Hono with a base path using: new Hono().basePath('/your-function-name').
Local MCP server development setup
Start the Supabase local development stack with: supabase start. In a separate terminal, serve your function with: supabase functions serve --no-verify-jwt mcp. The MCP server runs at http://localhost:54321/functions/v1/mcp. The --no-verify-jwt flag disables JWT verification so the MCP server can accept unauthenticated requests.
MCP server expected curl response format
MCP Streamable HTTP transport returns responses in Server-Sent Events (SSE) format. Example response: event: message followed by data: {"result":{"content":[{"type":"text","text":"8"}]},"jsonrpc":"2.0","id":1}.
Test MCP server with curl
Test MCP server tools using curl with a JSON-RPC 2.0 request. Example curl command to call the 'add' tool: curl -X POST 'http://localhost:54321/functions/v1/mcp' -H 'Content-Type: application/json' -H 'Accept: application/json, text/event-stream' -d '{"jsonrpc": "2.0", "id": 1, "method": "tools/call", "params": {"name": "add", "arguments": {"a": 5, "b": 3}}}'. The Accept header must include both 'application/json' and 'text/event-stream' to indicate support for both response formats.
MCP server tool groups and availability
The Supabase MCP server provides tools organized into feature groups. Database, Debugging, Development, Edge Functions, Docs, and Branching (experimental) are enabled by default. Storage is disabled by default. Account management tools (list_projects, get_project, create_project, pause_project, restore_project, list_organizations, get_organization, get_cost, confirm_cost) are disabled when using project-scoped mode with the project_ref parameter. Branching requires a paid plan.
Database MCP tools
The Database tool group includes: list_tables (list all tables in the database), list_extensions (list available/installed Postgres extensions), list_migrations (list database migrations), apply_migration (apply a database migration), and execute_sql (execute SQL queries).
Debugging MCP tools
The Debugging tool group includes: get_logs (retrieve service logs for API, Postgres, Edge Functions, Auth, Storage, and Realtime) and get_advisors (get security and performance advisors).
Development MCP tools
The Development tool group includes: get_project_url (get the API URL for a project), get_publishable_keys (get publishable and legacy anon API keys for a project), and generate_typescript_types (generate TypeScript types from schema).
Edge Functions MCP tools
The Edge Functions tool group includes: list_edge_functions (list all Edge Functions), get_edge_function (get a specific Edge Function), and deploy_edge_function (deploy an Edge Function).
Storage MCP tools
The Storage tool group (disabled by default) includes: list_storage_buckets (list storage buckets), and get_storage_config / update_storage_config (storage configuration management).
Branching MCP tools
The Branching tool group (experimental, requires paid plan) includes: create_branch, list_branches, delete_branch (branch management) and merge_branch, reset_branch, rebase_branch (branch operations).
MCP configuration URL query parameters
The Supabase MCP server supports three URL query parameters: read_only=true (execute all queries as a read-only Postgres user), project_ref=<id> (scope to a specific project and disable account tools), and features=<groups> (enable only specific tool groups as comma-separated values). Parameters can be combined.
MCP authentication methods
The Supabase MCP server supports two authentication methods: dynamic client registration (default, browser-based OAuth flow) and manual authentication. Manual authentication is needed for CI environments where browser-based OAuth is not possible, or when the MCP client requires an OAuth client ID and secret. For CI environments, create a personal access token (PAT) and pass it via the Authorization header. For clients requiring OAuth credentials, manually create an OAuth app in your Supabase organization and provide the client ID and secret to the MCP client.
MCP prompt injection attack risk
Prompt injection is the primary LLM-specific attack vector when connecting MCP to Supabase. An attacker could embed malicious commands in user-generated content (e.g., a support ticket description) that trick the LLM into executing unintended SQL queries or revealing sensitive data when a developer asks the MCP client to process that content.
MCP manual tool call approval recommendation
Most MCP clients like Cursor support manual approval of tool calls before execution. This setting should be kept enabled and users should review tool call details before executing them to reduce prompt injection risk. Supabase MCP wraps SQL results with additional instructions to discourage LLMs from following commands in the data, but this is not foolproof.
MCP security best practices
Best practices to mitigate security risks when using Supabase MCP: (1) Don't connect to production data; use only development projects with non-production or obfuscated data. (2) Don't give MCP to customers or end users; operate under developer permissions for internal use only. (3) Use read-only mode if connecting to real data. (4) Scope the MCP server to a specific project using project_ref to limit access to only that project's resources. (5) Use Supabase branching feature to create development branches for safe testing before production merging. (6) Restrict available tool groups using the features configuration option to reduce attack surface.
MCP feature
Model Context Protocol support is in public alpha status and fully available on self-hosted deployments.
Supabase MCP server for RedwoodJS AI integration
The Supabase MCP server connects AI assistants to Supabase projects. Configuration details are available in the MCP documentation.
Supabase MCP server log query tools
The Supabase MCP server provides query_logs and get_logs tools for accessing logs. The query_logs tool runs custom ClickHouse queries on hosted projects. The get_logs tool returns recent logs without SQL; it is deprecated on hosted projects but remains available for local and self-hosted projects.
Supabase MCP server for Rails projects
The Supabase MCP server connects AI assistants to Supabase, allowing them to interact with your projects on your behalf. More information is available in the MCP documentation.