Getting Started

Deploy MCP servers


Build and deploy Model Context Protocol (MCP) servers on Supabase using Edge Functions.

Prerequisites

Before you begin, make sure you have:

  • Docker or a compatible runtime installed and running (required for local development)
  • Deno installed (Supabase Edge Functions runtime)
  • Supabase CLI installed and authenticated
  • Node.js 20 or later (required by Supabase CLI)

Deploy your MCP server

Step 1: Create a new project

Start by creating a new Supabase project:

1
mkdir my-mcp-server
2
cd my-mcp-server
3
supabase init

Step 2: Create the MCP server function

Create a new Edge Function for your MCP server:

1
supabase functions new mcp

Replace the contents of supabase/functions/mcp/index.ts with:

supabase/functions/mcp/index.ts
1
// Setup type definitions for built-in Supabase Runtime APIs
2
import 'jsr:@supabase/functions-js/edge-runtime.d.ts'
3
4
import { McpServer } from 'npm:@modelcontextprotocol/sdk@1.25.3/server/mcp.js'
5
import { WebStandardStreamableHTTPServerTransport } from 'npm:@modelcontextprotocol/sdk@1.25.3/server/webStandardStreamableHttp.js'
6
import { Hono } from 'npm:hono@^4.9.7'
7
import { z } from 'npm:zod@^4.1.13'
8
9
// Create Hono app
10
const app = new Hono()
11
12
// Create your MCP server
13
const server = new McpServer({
14
name: 'mcp',
15
version: '0.1.0',
16
})
17
18
// Register a simple addition tool
19
server.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
)
30
31
// Handle MCP requests
32
app.all('*', async (c) => {
33
const transport = new WebStandardStreamableHTTPServerTransport()
34
await server.connect(transport)
35
return transport.handleRequest(c.req.raw)
36
})
37
38
Deno.serve(app.fetch)

Step 3: Test locally

Start the Supabase local development stack:

1
supabase start

In a separate terminal, serve your function:

1
supabase functions serve --no-verify-jwt mcp

Your MCP server is now running at:

1
http://localhost:54321/functions/v1/mcp

Test with curl

You can also test your MCP server directly with curl. Call the add tool:

1
curl -X POST 'http://localhost:54321/functions/v1/mcp' \
2
-H 'Content-Type: application/json' \
3
-H 'Accept: application/json, text/event-stream' \
4
-d '{
5
"jsonrpc": "2.0",
6
"id": 1,
7
"method": "tools/call",
8
"params": {
9
"name": "add",
10
"arguments": {
11
"a": 5,
12
"b": 3
13
}
14
}
15
}'

Expected response:

The response uses Server-Sent Events (SSE) format:

1
event: message
2
data: {"result":{"content":[{"type":"text","text":"8"}]},"jsonrpc":"2.0","id":1}

Test with MCP Inspector

Test your server with the official MCP Inspector:

1
npx -y @modelcontextprotocol/inspector

Use the local endpoint http://localhost:54321/functions/v1/mcp in the inspector UI to explore available tools and test them interactively.

Step 4: Deploy to production

When you're ready to deploy, link your project and deploy the function:

1
supabase link --project-ref <your-project-ref>
2
supabase functions deploy --no-verify-jwt mcp

Your MCP server will be available at:

1
https://<your-project-ref>.supabase.co/functions/v1/mcp

Update your MCP client configuration to use the production URL.

Examples

You can find ready-to-use MCP server implementations here:

Resources