mcp服务器数据库示例
本项目演示了如何使用 模型上下文协议(MCP) 使用Supabase后端。它为MCP、Supabase和Postgres的实验提供了一个本地开发环境。
特性
- 本地Supabase堆栈(Postgres、Auth、存储、Studio等)
- 用户、团队和帖子的示例模式和种子数据
- 用于直接访问数据库的MCP服务器配置
- 随时可用 光标 或任何MCP兼容客户端
入门指南
先决条件
- 码头工人 (用于在本地运行Supabase)
- Supabase命令行界面 (
brew install supabase/tap/supabase) - (通过npx用于MCP服务器)
- 光标 (可选,用于对话式数据库访问)
设置
- 克隆存储库:
git clone https://github.com/walshe/mcp-server-supabase.git
cd mcp-server-supabase- 在本地启动Supabase:
supabase start- 应用迁移和种子数据:
supabase db reset- 配置MCP服务器:
- 这 .cursor/mcp.json 文件已预先配置为使用Postgres MCP服务器:
{
"mcpServers": {
"supabase": {
"command": "npx",
"args": [
"-y",
"@modelcontextprotocol/server-postgres",
"postgresql://postgres:postgres@127.0.0.1:54322/postgres"
]
}
}
}- 使用光标连接:
- 打开光标,确保MCP工具为绿色(已连接)。 - 现在,您可以使用以下对话命令:
how many users are in my users table?示例架构
public.users:用户配置文件public.teams:团队public.team_members:团队成员public.posts:帖子
种子数据见 supabase/seed.sql.
故障排除
- 如果Cursor中的MCP工具为黄色或红色,请检查您的Supabase实例,并
.cursor/mcp.json配置。 - 确保Docker正在运行,并且端口未被其他服务使用。
许可证
麻省理工学院
