跳到主要内容

Supabase 扩展

本教程介绍如何将 Supabase MCP 服务器 添加为 zai 扩展,以便与你的 Supabase 项目交互、管理表、查询数据、部署 Edge Functions,并直接与你的 Supabase 后端交互。

快速安装

配置​

Supabase 远程 MCP​

Supabase MCP 服务器由 Supabase 托管,并提供基于 OAuth 的身份验证。连接时,你会被重定向到 supabase.com 登录自己的账户。

  1. Launch the installer
  2. Click Yes to confirm the installation
  3. Click the button in the top-left to open the sidebar
  4. Navigate to the chat

OAuth 流程​

首次通过 zai 连接 Supabase MCP 服务器时,浏览器会打开一个 OAuth 窗口。请按照提示授权访问你的 Supabase 项目。

安全提示

Supabase MCP 服务器会授予对你数据库以及项目管理能力的访问权限。在执行之前,请务必审查 LLM 请求的操作,并确认你当前工作在正确的环境(development、staging、production)中。

使用示例​

示例 1:列出你的 Supabase 项目​

概览你的所有 Supabase 项目及其配置。

zai 提示词​

List all my Supabase projects

zai 输出​

桌面版
Here are your Supabase projects:

1. my project (ID: abc123xyz789defg)
- Region: US West 1
- Created: October 30, 2025
- Status: ACTIVE_HEALTHY
- Database: PostgreSQL 17.6.1.031 (Engine v17)
- Host: db.abc123xyz789defg.supabase.co

2. new project (ID: jkl456mno012pqrs)
- Region: US West 1
- Created: October 31, 2025
- Status: INACTIVE
- Database: PostgreSQL 17.6.1.032 (Engine v17)
- Host: db.jkl456mno012pqrs.supabase.co

Would you like more detailed information about any specific project?

示例 2:查询数据库表​

发现并查询 Supabase 项目中的表。

zai 提示词​

What tables exist in my project?

zai 输出​

桌面版
Tables in my project (public schema):

1. users
- RLS Enabled: Yes
- Row count: 150
- Columns: id (uuid), email (text), name (text), created_at (timestamptz), role (text)
- Primary Key: id
- Foreign Keys: Referenced by posts.user_id, profiles.user_id

2. posts
- RLS Enabled: Yes
- Row count: 342
- Columns: id (uuid), user_id (uuid), title (text), content (text), created_at (timestamptz)
- Primary Key: id
- Foreign Keys: References users.id, referenced by comments.post_id

3. comments
- RLS Enabled: Yes
- Row count: 1089
- Columns: id (uuid), post_id (uuid), user_id (uuid), content (text), created_at (timestamptz)
- Primary Key: id
- Foreign Keys: References posts.id, references users.id

4. profiles
- RLS Enabled: Yes
- Row count: 150
- Columns: id (uuid), user_id (uuid), bio (text), avatar_url (text), updated_at (timestamptz)
- Primary Key: id
- Foreign Keys: References users.id

5. categories
- RLS Enabled: No
- Row count: 12
- Columns: id (uuid), name (text), description (text), created_at (timestamptz)
- Primary Key: id

Would you like to query data from any of these tables?

示例 3:部署 Edge Function​

直接通过 zai 部署和管理 Supabase Edge Functions。

zai 提示词​

Deploy a new Edge Function called 'hello-world' that returns a simple JSON response

zai 输出​

桌面版
Edge Function deployed successfully!

Function Name: hello-world
Version: 1
Status: ACTIVE
Function ID: c4e03748-3e72-45e2-bdca-03f7e4800874
Project: my project (tabowbdrhvtlvzvfyinw)
Entrypoint: index.ts
JWT Verification: Enabled
Created: November 8, 2025

Function code:
~~~typescript
Deno.serve(async (req) => {
return new Response(
JSON.stringify({ message: "Hello World!" }),
{ headers: { "Content-Type": "application/json" } },
)
})
~~~

Endpoint:
https://tabowbdrhvtlvzvfyinw.supabase.co/functions/v1/hello-world

You can test the function by sending a request to the endpoint above.

其他资源​

欲了解更多关于 Supabase MCP 服务器及其能力的信息,请访问: