Supabase-MCP 是一个功能强大的程序,可帮助用户轻松进行数据库操作、文件存储、边缘函数调用和用户管理等。以下将详细介绍其安装、配置、使用方法等内容。
要安装此程序,请执行以下命令:
npm install supabase-mcp
创建一个配置文件,并将其命名为supabase-mcp.config.js或.env,然后添加以下内容:
// 或者 .env 文件:
# 配置 Supabase 项目 ID
SUPABASE_PROJECT_ID=your_project_id
# 配置 Supabase 安排密钥
SUPABASE_ANON_KEY=your_anon_key
{
table: "users",
columns: ["id", "email", "created_at"],
where?: Record
}
示例:
{
table: "posts",
columns: ["id", "title", "content"],
where: { published: true }
}
{
table: "users",
data: {
email: "user@example.com",
password: "securepassword"
}
}
示例:
{
table: "posts",
data: {
title: "Hello World",
content: "This is my first post.",
user_id: 1
}
}
{
table: "users",
data: {
password: "newsecurepassword"
},
where: { email: "user@example.com" }
}
示例:
{
table: "posts",
data: { status: "draft" },
where: { id: 1 }
}
{
table: "users",
where: { email: "user@example.com" }
}
示例:
{
table: "posts",
where: { status: "deleted" }
}
{
bucket: "uploads",
path: "images/avatar.jpg",
file: selectedFile,
options?: {
cacheControl?: string;
contentType?: string;
upsert?: boolean;
};
}
示例:
{
bucket: "documents",
path: "reports/2023.pdf",
file: fileObject,
options: {
contentType: "application/pdf",
upsert: true
}
}
{
bucket: "uploads",
path: "images/avatar.jpg"
}
示例:
{
bucket: "downloads",
path: "files/report.docx"
}
{
function: "processData",
params?: {
key: string,
value: any
}[]
}
示例:
{
function: "calculateTotal",
params: [
{ key: "amount", value: 100 },
{ key: "taxRate", value: 0.15 }
]
}
{
email: "newuser@example.com",
password: "securepassword"
}
示例:
{
email: "admin@example.com",
password: "adminsecure"
}
程序返回的错误信息可能包括以下内容:
code: 错误代码message: 错误描述stack?: string:错误堆栈跟踪(如果有)示例:
{
code: "AUTHENTICATION_FAILED",
message: "Invalid API key provided."
}
要运行测试,请执行以下命令:
npm test supabase-mcp
要构建项目,请执行以下命令:
npm run build
要进行代码规范检查,请执行以下命令:
npm run lint
如果您希望为该项目做出贡献,请遵循以下步骤:
git checkout -b feature/your-featuregit commit -m "add your feature"git push origin feature/your-feature本项目受 MIT License 许可保护。
如果您遇到任何问题,请通过以下方式联系支持团队: