Self-Hosted Supabase MCP Server for Cursor

Hey guys,

Just wanted to share something I built for my own workflow: an MCP server for your self-hosted Supabase instances (like the one running locally with supabase start or a VPS hosted one).

It gives Cursor tools to:

  • Peek at your database schema (tables, extensions) and manage migrations.

  • Run SQL queries and check DB connections/stats.

  • Manage auth users (list, get, create, delete - careful with the create/update ones!).

  • Look at storage buckets and objects.

  • Check Realtime publications.

  • Generate TypeScript types.

If you’re running Supabase yourself and want to hook it up to Cursor, check it out:

:right_arrow: GitHub Repo: GitHub - HenkDz/selfhosted-supabase-mcp

The README has config examples for setting it up in Cursor’s .cursor/mcp.json. You basically just point it to the built server file (dist/index.js) and provide your Supabase URL/keys.

Hope someone else finds it useful!

1 Like

What I love about building MCPs, with cursor is that I can build and test in the same chat, the only thing I do manually is restart the MCP server, Imagine the Agent can build and then restart the MCP? can we have that?

Hello, I have been trying to use this MCP in my setup.

I have a Hetzner VPS with Coolify installed on top of it, from Coolify I downloaded Supabase which is right now working fine, I connected a public domain and can access it.

But when trying to connect this mcp to that instance of supabase I always get the same error:

root@supabase-n8n-coolify:~/selfhosted-supabase-mcp# node dist/index.js
Initializing Self-Hosted Supabase MCP Server…
Initializing SelfhostedSupabaseClient…
Checking for public.execute_sql RPC function…
‘public.execute_sql’ function not found (Code: PGRST202). Attempting creation…
Creating ‘public.execute_sql’ function using direct DB connection…
Initializing pg pool…
Failed to connect pg pool: Error: read ECONNRESET
at /root/selfhosted-supabase-mcp/node_modules/pg-pool/index.js:45:11
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async _SelfhostedSupabaseClient.ensurePgPool (file:///root/selfhosted-supabase-mcp/dist/index.js:183:22)
at async _SelfhostedSupabaseClient.executeSqlWithPg (file:///root/selfhosted-supabase-mcp/dist/index.js:149:5)
at async _SelfhostedSupabaseClient.checkAndCreateRpcFunction (file:///root/selfhosted-supabase-mcp/dist/index.js:254:11)
at async _SelfhostedSupabaseClient.initialize (file:///root/selfhosted-supabase-mcp/dist/index.js:78:7)
at async _SelfhostedSupabaseClient.create (file:///root/selfhosted-supabase-mcp/dist/index.js:68:5)
at async main (file:///root/selfhosted-supabase-mcp/dist/index.js:1710:30) {
errno: -104,
code: ‘ECONNRESET’,
syscall: ‘read’
}
Failed to create ‘public.execute_sql’ function or notify PostgREST: Error: Failed to connect pg pool: read ECONNRESET
at _SelfhostedSupabaseClient.ensurePgPool (file:///root/selfhosted-supabase-mcp/dist/index.js:190:13)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async _SelfhostedSupabaseClient.executeSqlWithPg (file:///root/selfhosted-supabase-mcp/dist/index.js:149:5)
at async _SelfhostedSupabaseClient.checkAndCreateRpcFunction (file:///root/selfhosted-supabase-mcp/dist/index.js:254:11)
at async _SelfhostedSupabaseClient.initialize (file:///root/selfhosted-supabase-mcp/dist/index.js:78:7)
at async _SelfhostedSupabaseClient.create (file:///root/selfhosted-supabase-mcp/dist/index.js:68:5)
at async main (file:///root/selfhosted-supabase-mcp/dist/index.js:1710:30)
Exception during RPC function check/creation: Error: Failed to create execute_sql function/notify: Failed to connect pg pool: read ECONNRESET
at _SelfhostedSupabaseClient.checkAndCreateRpcFunction (file:///root/selfhosted-supabase-mcp/dist/index.js:265:17)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async _SelfhostedSupabaseClient.initialize (file:///root/selfhosted-supabase-mcp/dist/index.js:78:7)
at async _SelfhostedSupabaseClient.create (file:///root/selfhosted-supabase-mcp/dist/index.js:68:5)
at async main (file:///root/selfhosted-supabase-mcp/dist/index.js:1710:30)
Error during client initialization: Error: Exception during RPC function check/creation: Failed to create execute_sql function/notify: Failed to connect pg pool: read ECONNRESET
at _SelfhostedSupabaseClient.checkAndCreateRpcFunction (file:///root/selfhosted-supabase-mcp/dist/index.js:281:13)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async _SelfhostedSupabaseClient.initialize (file:///root/selfhosted-supabase-mcp/dist/index.js:78:7)
at async _SelfhostedSupabaseClient.create (file:///root/selfhosted-supabase-mcp/dist/index.js:68:5)
at async main (file:///root/selfhosted-supabase-mcp/dist/index.js:1710:30)
Initialization complete.
Supabase client initialized successfully.
No valid --tools-config specified or error loading config, enabling all available tools.
Initializing MCP Server…
Starting MCP Server in stdio mode…
MCP Server connected to stdio.

Supposedly the MCP initializes but without the ability to run SQL functions, but that’s basically the point of it, being able to run the functions to create tables and so on.

So just wanted to ask what could be the main issue, I have been troubleshooting for some time, and just wanted to see if you had any possible explanation from your experience developing it.

Thank you

1 Like