这是一个模型上下文协议(MCP)服务器,提供与Supabase数据库、存储和边缘函数交互的全面工具。该服务器实现了Supabase服务与MCP兼容应用程序之间的无缝集成。
<a href="https://glama.ai/mcp/servers/vwi6nt8i80"><img width="380" height="200" src="https://gips3.baidu.com/it/u=3068627635,1138314719&fm=3081&app=3081&f=PNG?w=760&h=400" alt="supabase-mcp MCP 服务器" /></a>
Supabase MCP服务器作为MCP客户端与Supabase服务套件之间的桥梁,提供了以下功能:
服务器使用TypeScript构建,并遵循模块化架构:
supabase-server/
├── src/
│ ├── index.ts # 主服务器实现
│ └── types/
│ └── supabase.d.ts # 类型定义
├── package.json
├── tsconfig.json
├── config.json.example # 示例配置文件
└── .env.example # 环境变量模板
要通过Smithery自动安装Supabase服务器到Claude桌面:
npx -y @smithery/cli install supabase-server --client claude
git clone https://github.com/DynamicEndpoints/supabase-mcp.git
cd supabase-mcp
npm install
cp .env.example .env
SUPABASE_URL=your_project_url_here
SUPABASE_KEY=your_service_role_key_here
SUPABASE_ACCESS_TOKEN=your_access_token_here # 管理操作所需
cp config.json.example config.json
npm run build
服务器支持通过环境变量和config.json文件进行广泛的配置。以下是配置选项的详细分解:
{
"server": {
"name": "supabase-server", // 服务器名称
"version": "0.1.0", // 服务器版本
"port": 3000, // 端口号(如果独立运行)
"host": "localhost" // 主机地址(如果独立运行)
}
}
{
"supabase": {
"project": {
"url": "your_project_url",
"key": "your_service_role_key",
"accessToken": "your_access_token"
},
"storage": {
"defaultBucket": "public", // 默认存储桶
"maxFileSize": 52428800, // 最大文件大小(字节,50MB)
"allowedMimeTypes": [ // 允许的文件类型
"image/*",
"application/pdf",
"text/*"
]
},
"database": {
"maxConnections": 10, // 最大数据库连接数
"timeout": 30000, // 查询超时时间(毫秒)
"ssl": true // SSL连接
},
"auth": {
"autoConfirmUsers": false, // 自动确认新用户
"disableSignup": false, // 禁用公共注册
"jwt": {
"expiresIn": "1h", // 令牌过期时间
"algorithm": "HS256" // JWT算法
}
}
}
}
{
"logging": {
"level": "info", // 日志级别
"format": "json", // 日志格式
"outputs": ["console", "file"], // 输出目标
"file": {
"path": "logs/server.log", // 日志文件路径
"maxSize": "10m", // 最大文件大小
"maxFiles": 5 // 最多文件数量
}
}
}
{
"security": {
"cors": {
"enabled": true,
"origins": ["*"],
"methods": ["GET", "POST", "PUT", "DELETE", "OPTIONS"],
"allowedHeaders": ["Content-Type", "Authorization"]
},
"rateLimit": {
"enabled": true,
"windowMs": 900000, // 15分钟
"max": 100 // 每窗口最大请求数
}
}
}
{
"monitoring": {
"enabled": true,
"metrics": {
"collect": true,
"interval": 60000 // 收集间隔(毫秒)
},
"health": {
"enabled": true,
"path": "/health" // 健康检查端点
}
}
}
查看config.json.example以获取完整的示例配置文件。
在您的MCP设置(cline_mcp_settings.json)中添加服务器:
{
"mcpServers": {
"supabase": {
"command": "node",
"args": ["path/to/supabase-server/build/index.js"],
"env": {
"SUPABASE_URL": "your_project_url",
"SUPABASE_KEY": "your_service_role_key",
"SUPABASE_ACCESS_TOKEN": "your_access_token"
},
"config": "path/to/config.json" // 可选:配置文件路径
}
}
}
创建表中的新记录,支持返回特定字段。
{
table: string;
data: Record<string, any>;
returning?: string[];
}
示例:
{
table: "users",
data: {
name: "John Doe",
email: "john@example.com"
},
returning: ["id", "created_at"]
}
读取记录,支持高级过滤、连接和字段选择。
{
table: string;
select?: string[];
filter?: Record<string, any>;
joins?: Array<{
type?: 'inner' | 'left' | 'right' | 'full';
table: string;
on: string;
}>;
}
示例:
{
table: "posts",
select: ["id", "title", "user.name"],
filter: { published: true },
joins: [{
type: "left",
table: "users",
on: "posts.user_id=users.id"
}]
}
更新记录,支持过滤和返回。
{
table: string;
data: Record<string, any>;
filter?: Record<string, any>;
returning?: string[];
}
示例:
{
table: "users",
data: { status: "active" },
filter: { email: "john@example.com" },
returning: ["id", "status", "updated_at"]
}
删除记录,支持过滤和返回。
{
table: string;
filter?: Record<string, any>;
returning?: string[];
}
示例:
{
table: "posts",
filter: { status: "draft" },
returning: ["id", "title"]
}
上传文件到Supabase存储,支持可配置选项。
{
bucket: string;
path: string;
file: File | Blob;
options?: {
cacheControl?: string;
contentType?: string;
upsert?: boolean;
};
}
示例:
{
bucket: "avatars",
path: "users/123/profile.jpg",
file: imageBlob,
options: {
contentType: "image/jpeg",
upsert: true
}
}
从Supabase存储下载文件。
{
bucket: string;
path: string;
}
示例:
{
bucket: "documents",
path: "reports/annual-2023.pdf"
}
调用Supabase边缘函数,支持参数和自定义选项。
{
function: string;
params?: Record<string, any>;
options?: {
headers?: Record<string, string>;
responseType?: 'json' | 'text' | 'arraybuffer';
};
}
示例:
{
function: "process-image",
params: {
url: "https://example.com/image.jpg",
width: 800
},
options: {
responseType: "json"
}
}
列出用户,支持分页。
{
page?: number;
per_page?: number;
}
创建新用户,带有元数据。
{
email: string;
password: string;
data?: Record<string, any>;
}
更新用户详情。
{
user_id: string;
email?: string;
password?: string;
data?: Record<string, any>;
}
删除用户。
{
user_id: string;
}
为用户分配角色。
{
user_id: string;
role: string;
}
移除用户的某个角色。
{
user_id: string;
role: string;
}
服务器为常见场景提供了详细的错误消息:
错误以标准化格式返回:
{
code: ErrorCode;
message: string;
details?: any;
}
npm test
npm run build
npm run lint
Evals包加载了一个mcp客户端,然后运行index.ts文件,因此在测试之间无需重新构建。您可以通过前缀npx命令来加载环境变量。完整文档可以在这里找到。
OPENAI_API_KEY=your-key npx mcp-eval src/evals/evals.ts src/index.ts
MIT许可证 - 详情见LICENSE
对于支持,请: