使用说明
@mattjohnston/苏巴巴士·麦克普
MCP服务器,用于使用云存储凭据进行Supabase CLI操作。
概述
此MCP服务器允许从任何计算机上的任何目录进行Supabase CLI操作,而无需手动登录/注销。凭据安全地存储在中央云服务器(助理mcp)中,并在运行时获取。
特性
- 无需手动登录 -从助理mcp自动获取凭据
- 多账户支持 -为不同的辅助数据库帐户配置单独的实例
- 在全球范围内工作 -从任何驱动器上的任何项目目录使用
- 跨平台 -Windows、macOS、Linux
- 纸机横向 -在具有相同配置的所有计算机上工作相同
安装
选项1:使用npx(推荐)
无需安装-npx将自动下载并运行该软件包:
npx github:mrchevyceleb/supabase-mcp
选项2:克隆和链接(开发)
git clone https://github.com/mrchevyceleb/supabase-mcp.git
cd supabase-mcp
npm install
npm run build
npm link
配置
添加到您的 ~/.claude.json 在...之下 globalMcpServers:
{
"globalMcpServers": {
"supabase-elite": {
"command": "npx",
"args": ["-y", "github:mrchevyceleb/supabase-mcp"],
"env": {
"SUPABASE_ACCOUNT": "eliteteam",
"MCP_AUTH_TOKEN": "your-mcp-auth-token",
"ASSISTANT_MCP_URL": "https://assistant-mcp-production.up.railway.app"
}
},
"supabase-personal": {
"command": "npx",
"args": ["-y", "github:mrchevyceleb/supabase-mcp"],
"env": {
"SUPABASE_ACCOUNT": "personal",
"MCP_AUTH_TOKEN": "your-mcp-auth-token",
"ASSISTANT_MCP_URL": "https://assistant-mcp-production.up.railway.app"
}
}
}
}
环境变量
| 变量 | 描述 |
|---|---|
SUPABASE_ACCOUNT |
帐户标识符(用于从助理mcp获取凭据,作为 supabase_{account}) |
MCP_AUTH_TOKEN |
用于助理mcp身份验证的承载令牌(与您的助理mcp管理令牌相同) |
ASSISTANT_MCP_URL |
辅助mcp服务器的URL |
存储凭据
在使用此MCP之前,您必须将Supabase访问令牌存储在助手MCP中。
生成Supabase访问令牌
- 首选https://supabase.com/dashboard/account/tokens
- 点击“生成新令牌”
- 给它起个名字(例如,“克劳德代码-精英团队”)
- 复制令牌(您将不会再看到它!)
存储在助理mcp中
使用管理员API或curl存储凭据:
curl -X POST https://assistant-mcp-production.up.railway.app/admin/api/credentials \
-H "Authorization: Bearer YOUR_MCP_AUTH_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"service": "supabase_eliteteam",
"apiKey": "sbp_your_supabase_access_token",
"metadata": {
"project_refs": ["project-ref-1", "project-ref-2"],
"default_project": "project-ref-1"
}
}'
对每个帐户重复此操作(例如。, supabase_personal).
可用工具
所有工具都以帐户名作为前缀(例如。, eliteteam_db_push).
迁移
| 工具 | 说明 |
|---|---|
{account}_db_push |
将迁移推送到远程数据库 |
{account}_migrations_new |
创建新的迁移文件 |
{account}_migrations_list |
列出迁移状态 |
{account}_db_diff |
生成模式差异 |
{account}_migrations_repair |
修复迁移历史记录 |
{account}_migrations_squash |
壁球迁徙 |
数据库
| 工具 | 说明 |
|---|---|
{account}_db_execute_sql |
对远程数据库执行原始SQL(使用Suabase Management API) |
边缘功能
| 工具 | 说明 |
|---|---|
{account}_functions_deploy |
部署边缘功能 |
{account}_functions_list |
列出已部署的功能 |
{account}_functions_delete |
删除函数 |
{account}_functions_new |
创建新功能 |
{account}_functions_serve |
在当地提供服务 |
类型生成
| 工具 | 说明 |
|---|---|
{account}_gen_types |
从模式生成TypeScript类型 |
{account}_gen_types_api |
从OpenAPI规范生成类型 |
项目管理
| 工具 | 说明 |
|---|---|
{account}_projects_list |
列出帐户中的所有项目 |
{account}_link_project |
将目录链接到项目 |
{account}_status |
显示项目状态 |
{account}_init |
初始化新的Supabase项目 |
{account}_start |
启动本地Supabase堆栈 |
{account}_stop |
停止本地Supabase堆栈 |
{account}_db_reset |
重置本地数据库 |
{account}_db_pull |
拉取远程架构 |
{account}_db_dump |
转储数据库架构 |
{account}_db_lint |
Lint SQL文件 |
{account}_health |
检查CLI和凭据状态 |
{account}_refresh_credentials |
强制刷新凭据 |
使用示例
# List all EliteTeam projects (from any directory)
mcp__supabase-elite__eliteteam_projects_list()
# Push migrations from a specific project
mcp__supabase-elite__eliteteam_db_push({ project_path: "K:/EliteTeam/profit-wizard" })
# Generate types for personal account
mcp__supabase-personal__personal_gen_types({
project_path: "E:/Personal/my-saas",
output_path: "src/types/database.ts"
})
# Check health status
mcp__supabase-elite__eliteteam_health()
安全
- 凭据在助理mcp(AES-256-GCM)中静态加密
- 通过HTTPS使用承载令牌身份验证获取
- 从未本地存储在磁盘上
- 仅在内存中缓存(5分钟TTL)
- 记录所有凭证访问以供审核
先决条件
- Node.js 18+
- 已安装Supabase CLI(
npm install -g supabase) - 助理列车长(铁路)
- 存储在助理mcp中的凭据
多计算机设置
每台计算机都需要:
~/.claude.json使用globalMcpServers配置(复制完全相同的配置)- 已安装Supabase CLI(
npm install -g supabase) - 网络访问助理mcp URL
就是这样! 无需设置每台机器的凭据,也不需要Supabase登录。
在其他计算机上更新
当MCP服务器代码更新时(例如错误修复),每台计算机都会通过以下方式缓存旧版本 npx。要强制更新,请执行以下操作:
步骤1:清除npx缓存
Windows(Git Bash/PowerShell):
# Find which npx cache dir has supabase-mcp
for dir in ~/AppData/Local/npm-cache/_npx/*/; do
if grep -ql "supabase-mcp" "$dir/node_modules/.package-lock.json" 2>/dev/null; then
echo "Found: $dir"
rm -rf "$dir"
echo "Deleted!"
fi
done
macOS/Linux:
# Find which npx cache dir has supabase-mcp
for dir in ~/.npm/_npx/*/; do
if grep -ql "supabase-mcp" "$dir/node_modules/.package-lock.json" 2>/dev/null; then
echo "Found: $dir"
rm -rf "$dir"
echo "Deleted!"
fi
done
核选项(清除所有npx缓存):
npm cache clean --force
步骤2:重新启动Claude代码
关闭并重新打开Claude Code。MCP服务器将在下次启动时从GitHub重新下载最新版本。
步骤3:验证
使用健康检查工具确认MCP是否正常工作:
mcp__supabase-personal__personal_health()
建筑
┌─────────────────────┐ ┌──────────────────────┐ ┌─────────────────┐
│ Claude Code │ │ supabase-mcp │ │ assistant-mcp │
│ (MCP client) │────▶│ (this package) │────▶│ (Railway) │
│ │ │ │ │ │
│ Calls tools like │ │ 1. Fetches access │ │ Stores Supa- │
│ personal_db_push │ │ token from cloud │ │ base tokens │
│ eliteteam_gen_types│ │ 2. Runs supabase CLI │ │ encrypted │
│ personal_db_execute│ │ with that token │ │ (AES-256-GCM) │
└─────────────────────┘ │ 3. Returns results │ └─────────────────┘
└──────────┬────────────┘
│
┌──────────▼────────────┐
│ Supabase CLI │
│ (installed locally) │
│ │
│ Most tools use CLI: │
│ - functions deploy │
│ - db push │
│ - migration list │
│ │
│ db_execute_sql uses │
│ Management API │
│ directly (no CLI) │
└────────────────────────┘
如何 db_execute_sql 作品
与向Supabase CLI提供外壳的其他工具不同, db_execute_sql 呼叫 主管管理API 直接:
POST https://api.supabase.com/v1/projects/{project_ref}/database/query
Authorization: Bearer {supabase_access_token}
Content-Type: application/json
{"query": "SELECT * FROM auth.users LIMIT 5"}
这是因为Supabase CLI 不 有一个...,有... db execute 命令。管理API端点直接返回JSON结果。
项目参考决议: 如果你不通过 project_ref,工具从中读取 {project_path}/supabase/.temp/project-ref (跑步时创建 supabase link).
故障排除
“找不到凭据”
- 确保凭证存储在助理mcp中
supabase_{account} - 检查帐户名是否与您的配置匹配
“401未经授权”
- 验证MCP_AUTH_TOKEN是否与您的助理MCP令牌匹配
- 检查助手_MCP_URL是否正确
“suabase:找不到命令”
- 安装Supabase CLI:
npm install -g supabase
工具未出现
- 添加配置后重新启动Claude代码
- 检查
~/.claude.json语法是有效的JSON
db_execute_sql 返回“未知标志:--sql”
- 您正在运行旧的缓存版本。 按照上面的“在其他计算机上更新”步骤清除npx缓存并重新启动Claude Code。
- 旧版本试图使用
supabase db execute --sql这在Supabase CLI中不存在。修复程序(2026年2月)切换到Suabase Management API。
db_execute_sql return“未提供project_ref”
- 要么通过
project_ref明确地,或确保项目目录中有一个链接的项目(supabase link --project-ref YOUR_REF)
db_execute_sql 返回“spawn cmd.exe ENOENT”
- 与
--sql上面的错误--旧的缓存版本。清除npx缓存并重新启动。
其他工具工作,但 db_execute_sql 不
- 其他工具使用Supabase CLI(运行良好)。
db_execute_sql使用管理API,该API需要有效的访问令牌。跑{account}_health以检查凭据。
许可证
麻省理工学院
