这是一个用于与Supabase数据库交互的模型上下文协议(MCP)服务器。该服务器提供了通过MCP接口查询表和生成TypeScript类型的工具。
查询表:支持对任何表执行查询,包括:
类型生成:为您的数据库生成TypeScript类型:
git clone https://github.com/yourusername/supabase-mcp-server.git
cd supabase-mcp-server
npm install
# 使用npm
npm install -g supabase
# 或在macOS上使用Homebrew
brew install supabase/tap/supabase
获取您的Supabase凭证:
对于托管项目:
对于本地项目:
配置环境变量:
# 创建一个.env文件(此文件将被git忽略)
echo "SUPABASE_URL=your_project_url
SUPABASE_KEY=your_service_role_key" > .env
npm run build
打开Claude Desktop设置:
~/Library/Application Support/Claude/claude_desktop_config.json%APPDATA%\Claude\claude_desktop_config.json~/.config/Claude/claude_desktop_config.json添加服务器配置:
{
"mcpServers": {
"supabase": {
"command": "node",
"args": ["/绝对路径/to/supabase-mcp-server/build/index.js"],
"env": {
"SUPABASE_URL": "your_project_url",
"SUPABASE_KEY": "your_service_role_key"
}
}
}
}
打开VSCode设置:
~/Library/Application Support/Code/User/globalStorage/saoudrizwan.claude-dev/settings/cline_mcp_settings.json%APPDATA%\Code\User\globalStorage\saoudrizwan.claude-dev\settings\cline_m _mcp_settings.json~/.config/Code/User/globalStorage/saoudrizwan.claude-dev/settings/cline_mcp_settings.json添加服务器配置(与Claude Desktop相同格式)。
// 带有模式选择和where子句的查询
<use_mcp_tool>
<server_name>supabase</server_name>
<tool_name>query_table</tool_name>
<arguments>
{
"schema": "public",
"table": "users",
"select": "id,name,email",
"where": [
{
"column": "is_active",
"operator": "eq",
"value": true
}
]
}
</arguments>
</use_mcp_tool>
// 为公共模式生成类型
<use_mcp_tool>
<server_name>supabase</server_name>
<tool_name>generate_types</tool_name>
<arguments>
{
"schema": "public"
}
</arguments>
</use_mcp_tool>
查询特定表,支持模式选择和where子句。
参数:
schema(可选):数据库模式(默认为公共)table(必需):要查询的表名select(可选):逗号分隔的列列表where(可选):条件数组,包含:
column:列名operator:其中之一:eq, neq, gt, gte, lt, lte, like, ilike, isvalue:比较值为您的Supabase数据库模式生成TypeScript类型。
参数:
schema(可选):数据库模式(默认为公共)supabase --version
对于本地项目:
对于托管项目:
git checkout -b feature/my-featuregit commit -am '添加我的功能'git push origin feature/my-featureMIT许可证 - 查看LICENSE文件获取详细信息