Deploy MCP servers
Build and deploy Model Context Protocol (MCP) servers on Supabase using Edge Functions.
This guide covers MCP servers that do not require authentication. Auth support for MCP on Edge Functions is coming soon.
Deploy your MCP server
Prerequisites
Before you begin, make sure you have:
- Docker installed (required for local Supabase development)
- Deno installed (Supabase Edge Functions runtime)
- Supabase CLI installed
Create a new project
Start by creating a new Supabase project:
1mkdir my-mcp-server2cd my-mcp-server3supabase initCreate the MCP server function
Create a new Edge Function for your MCP server:
1supabase functions new mcpCreate a deno.json file in supabase/functions/mcp/ with the required dependencies:
1{2 "imports": {3 "@hono/mcp": "npm:@hono/mcp@^0.1.1",4 "@modelcontextprotocol/sdk": "npm:@modelcontextprotocol/sdk@^1.24.3",5 "hono": "npm:hono@^4.9.2",6 "zod": "npm:zod@^4.1.13"7 }8}This tutorial uses the official MCP TypeScript SDK, but you can use any MCP framework that's compatible with the Edge Runtime, such as mcp-lite, mcp-use, or mcp-handler.
Replace the contents of supabase/functions/mcp/index.ts with:
1// Setup type definitions for built-in Supabase Runtime APIs2import 'jsr:@supabase/functions-js/edge-runtime.d.ts'34import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js'5import { StreamableHTTPTransport } from '@hono/mcp'6import { Hono } from 'hono'7import { z } from 'zod'89// Create Hono app10const app = new Hono()1112// Create your MCP server13const server = new McpServer({14 name: 'mcp',15 version: '0.1.0',16})1718// Register a simple addition tool19server.registerTool(20 'add',21 {22 title: 'Addition Tool',23 description: 'Add two numbers together',24 inputSchema: { a: z.number(), b: z.number() },25 },26 ({ a, b }) => ({27 content: [{ type: 'text', text: String(a + b) }],28 })29)3031// Handle MCP requests at the root path32app.all('/', async (c) => {33 const transport = new StreamableHTTPTransport()34 await server.connect(transport)35 return transport.handleRequest(c)36})3738Deno.serve(app.fetch)Local development
Start the Supabase local development stack:
1supabase startIn a separate terminal, serve your function:
1supabase functions serve --no-verify-jwt mcpYour MCP server is now running at:
1http://localhost:54321/functions/v1/mcpThe --no-verify-jwt flag disables JWT verification at the Edge Function layer so your MCP server can accept unauthenticated requests. Authenticated MCP support is coming soon.
Test your MCP server
Test your server with the official MCP Inspector:
1npx -y @modelcontextprotocol/inspectorUse the local endpoint http://localhost:54321/functions/v1/mcp in the inspector UI to explore available tools and test them interactively.
Deploy to production
When you're ready to deploy, link your project and deploy the function:
1supabase link --project-ref <your-project-ref>2supabase functions deploy --no-verify-jwt mcpYour MCP server will be available at:
1https://<your-project-ref>.supabase.co/functions/v1/mcpUpdate your MCP client configuration to use the production URL.
Adding more tools
Extend your MCP server by registering additional tools. Here's an example that queries your Supabase database:
1import { createClient } from 'jsr:@supabase/supabase-js@2'23// Create Supabase client4const supabase = createClient(5 Deno.env.get('SUPABASE_URL')!,6 Deno.env.get('SUPABASE_SERVICE_ROLE_KEY')!7)89server.registerTool(10 'list_users',11 {12 title: 'List Users',13 description: 'Get a list of users from the database',14 inputSchema: { limit: z.number().optional().default(10) },15 },16 async ({ limit }) => {17 const { data, error } = await supabase18 .from('users')19 .select('id, email, created_at')20 .limit(limit)2122 if (error) {23 return {24 content: [{ type: 'text', text: `Error: ${error.message}` }],25 isError: true,26 }27 }2829 return {30 content: [{ type: 'text', text: JSON.stringify(data, null, 2) }],31 }32 }33)Examples
You can find ready-to-use MCP server implementations here: