<div align="center"> <img src="https://miro.medium.com/v2/resize:fit:1400/1*pnSzmFJRCJztS7tkSJXYuQ.jpeg" alt="Supabase" width="600"/> </div>🔥 一个强大的模型上下文协议(MCP)服务器,通过Cursor的Composer和Codeium的Cascade提供了对您的Supabase PostgreSQL数据库的全面管理控制。此工具具备完整的表操作、记录管理、模式修改等功能,实现了无缝的数据库管理。
# 克隆仓库
git clone https://github.com/Quegenx/supabase-mcp-server.git
cd supabase-mcp-server
# 安装依赖
npm install
# 构建项目
npm run build
安装依赖并构建项目:
npm install
npm run build
在Cursor的MCP设置中,添加服务器时使用以下命令:
/opt/homebrew/bin/node /path/to/dist/index.js postgresql://postgres.[PROJECT-ID]:[PASSWORD]@aws-0-eu-central-1.pooler.supabase.com:5432/postgres
替换:
/path/to/dist/index.js 为您实际的路径[PROJECT-ID] 为您的Supabase项目ID[PASSWORD] 为您的数据库密码注意:请确保数据库凭据的安全性,并且不要将其提交到版本控制系统中。
模型上下文协议(MCP)允许您在Cursor中提供自定义工具给代理LLM。此服务器可以与Cursor的Composer功能集成,通过自然语言命令直接访问所有数据库管理工具。
打开Cursor设置 > 功能 > MCP
点击“+ 添加新MCP服务器”按钮
填写模态表单:
command(stdio传输)首先构建项目:
npm install
npm run build
获取您的Node.js路径:
# 在Mac/Linux上
which node
# 在Windows上
where node
添加服务器命令:
/path/to/node /path/to/dist/index.js postgresql://postgres.[PROJECT-ID]:[PASSWORD]@aws-0-eu-central-1.pooler.supabase.com:5432/postgres
替换:
/path/to/node 为您实际的Node.js路径(来自步骤5)/path/to/dist/index.js 为您实际的已构建JavaScript文件路径[PROJECT-ID] 为您的Supabase项目ID[PASSWORD] 为您的数据库密码点击“添加服务器”,然后点击右上角的刷新按钮
Composer代理会自动检测并使用相关工具来描述您的数据库任务。例如:
当代理使用一个工具时,您会看到:
注意:对于像这样的stdio服务器,命令应该是一个有效的shell命令。如果您需要环境变量,请考虑使用包装脚本。
此MCP服务器还支持Codeium的Cascade(Windsurf)集成。请注意,此功能目前仅适用于付费个人用户(不适用于团队或企业用户)。
创建或编辑 ~/.codeium/windsurf/mcp_config.json:
{
"mcpServers": {
"supabase-mcp": {
"command": "/path/to/node",
"args": [
"/path/to/dist/index.js",
"postgresql://postgres.[PROJECT-ID]:[PASSWORD]@aws-0-eu-central-1.pooler.supabase.com:5432/postgres"
]
}
}
}
快速访问配置:
在配置中替换:
/path/to/node 为您实际的Node.js路径/path/to/dist/index.js 为您实际的路径[PROJECT-ID] 为您的Supabase项目ID[PASSWORD] 为您的数据库密码在Cascade中:
list_tables, create_table, drop_table, rename_tableadd_column, drop_column, alter_columnfetch_records, create_record, update_record, delete_recordlist_indexes, create_index, delete_index, update_indexlist_constraints, add_constraint, remove_constraint, update_constraintlist_functions, create_function, update_function, delete_functionlist_triggers, create_trigger, update_trigger, delete_triggerlist_policies, create_policy, update_policy, delete_policylist_roles, create_role, update_role, delete_rolelist_buckets, create_bucket, delete_bucketdelete_file, bulk_delete_fileslist_folderslist_enumerated_types, create_enumerated_type, update_enumerated_type, delete_enumerated_typelist_publications, create_publication, update_publication, delete_publicationlist_realtime_policies, create_realtime_policy, update_realtime_policy, delete_realtime_policylist_realtime_channels, manage_realtime_channels, send_realtime_message, get_realtime_messagesmanage_realtime_status, manage_realtime_viewslist_users, create_user, update_user, delete_userquery - 执行自定义SQL查询supabase-mcp-server/
├── dist/ # 编译后的JavaScript文件
│ ├── index.d.ts # TypeScript声明
│ └── index.js # 主JavaScript文件
├── src/ # 源代码
│ └── index.ts # 主TypeScript文件
├── package.json # 项目配置
├── package-lock.json # 依赖锁定文件
└── tsconfig.json # TypeScript配置
一旦配置完成,MCP服务器将通过Cursor的Composer提供所有数据库管理工具。只需描述您想要对数据库进行的操作,AI将使用相应的命令。
示例:
Node.js路径问题
which node找到正确的路径where node找到正确的路径/usr/local/bin/node 为您实际的Node.js路径文件路径问题
pwd获取完整路径cd获取完整路径/Users/username/projects/supabase-mcp-server/dist/index.jsMCP未检测到工具
权限问题
dist目录存在(运行npm run build)chmod +x)npm install在命令前添加DEBUG=true以查看详细的日志:
DEBUG=true /usr/local/bin/node /path/to/dist/index.js [connection-string]
# 使用此格式的命令
"C:\\Program Files\\nodejs\\node.exe" "C:\\path\\to\\dist\\index.js" "postgresql://..."
# 查找Node.js路径
which node
# 将脚本设为可执行
chmod +x /path/to/dist/index.js
如果仍然遇到问题,请打开一个问题,并提供:
node --version)欢迎贡献!请随时提交Pull Request。