Skip to main content
Glama
ninad7007

Supabase MCP Server

by ninad7007

Supabase MCP 服务器

模型上下文协议 (MCP) 服务器,使 AI 工具能够与 Supabase 数据库交互。该服务器提供用于读取、创建、更新和删除 Supabase 表中记录的工具。

特征

  • 通过过滤和列选择从任何 Supabase 表中读取行

  • 在表中创建单个或多个记录

  • 根据过滤条件更新记录

  • 根据过滤条件删除记录

  • 人工智能模型理解的全面工具描述

  • 使用 Pydantic 进行类型安全的请求/响应处理

  • Docker 支持,轻松部署

Related MCP server: Supabase MCP Server

先决条件

  • Python 3.9+

  • Docker 和 Docker Compose

  • 具有服务角色密钥的 Supabase 项目

  • 兼容 FastMCP 的 AI IDE

安装

  1. 克隆存储库:

git clone https://github.com/yourusername/supabase-mcp.git
cd supabase-mcp
  1. 使用您的 Supabase 凭证创建一个.env文件:

cp .env.example .env
# Edit .env with your Supabase credentials:
# SUPABASE_URL=your-project-url
# SUPABASE_KEY=your-service-role-key
  1. 构建并启动容器:

# Build and start in detached mode
docker-compose up --build -d

# To view logs
docker-compose logs -f

# To stop the container
docker-compose down

该服务器将在http://localhost:8000上可用。

Docker 管理命令

# Start the container
docker-compose up

# Start in detached mode (background)
docker-compose up -d

# Stop the container
docker-compose down

# View logs
docker-compose logs -f

# Rebuild the container
docker-compose up --build

# Check container status
docker-compose ps

# Restart the container
docker-compose restart

Docker 问题故障排除

  1. 如果容器启动失败:

    # Check logs
    docker-compose logs -f
    
    # Check container status
    docker-compose ps
    
    # Remove and rebuild
    docker-compose down
    docker-compose up --build
  2. 如果遇到端口冲突:

    # Stop any existing containers using port 8000
    docker-compose down
    
    # Or modify the port in docker-compose.yml
    # ports:
    #   - "8000:8000"  # Change the first number to an available port
  3. 如果环境变量未加载:

    # Verify .env file exists and has correct values
    cat .env
    
    # Check environment variables in container
    docker-compose exec mcp-server env

在 AI IDE 中配置 MCP

常规配置步骤

  1. 打开你的 AI IDE 的设置/首选项

  2. 导航至 MCP 或 AI 设置部分

  3. 添加一个新的 MCP 服务器,配置如下:

{
  "name": "Supabase MCP",
  "command": "docker-compose",
  "args": ["up"],
  "cwd": "/path/to/supabase-mcp"
}

IDE 特定指令

光标

  1. 打开设置(⌘,或 Ctrl+,)

  2. 前往“AI”部分

  3. 在“MCP 服务器”下,点击“添加服务器”

  4. 使用上面的配置

  5. 重新启动 Cursor 以应用更改

带有 AI 扩展的 VS Code

  1. 打开命令面板(⌘⇧P 或 Ctrl+Shift+P)

  2. 搜索“MCP”或“AI 设置”

  3. 添加新的 MCP 服务器配置

  4. 使用上面的配置

  5. 重新加载 VS Code 窗口

带有 AI 插件的 JetBrains IDE

  1. 打开设置(⌘ 或 Ctrl+Alt+S)

  2. 导航至“工具”→“AI”→“MCP 服务器”

  3. 点击“+”添加新服务器

  4. 使用上面的配置

  5. 重新启动 IDE 以应用更改

验证 MCP 连接

  1. 检查 IDE 的状态栏以了解 MCP 服务器状态

  2. 寻找绿色指示灯或“MCP 已连接”消息

  3. 尝试使用需要数据库访问的 AI 功能

  4. 检查 Docker 日志是否存在任何连接问题:

    docker-compose logs -f

用法

  1. 启动 MCP 服务器:

docker-compose up
  1. 配置您的 AI 工具以使用 MCP 服务器:

{
  "mcpServers": {
    "supabase": {
      "command": "docker-compose",
      "args": ["up"]
    }
  }
}

可用工具

读取行

从 Supabase 表中读取行,并可选择过滤和列。

使用示例:

{
  "table_name": "users",
  "columns": ["id", "name"],
  "filters": { "age": { "gt": 18 } },
  "limit": 10
}

创建记录

在 Supabase 表中创建一个或多个记录。

使用示例:

{
  "table_name": "users",
  "records": [
    { "name": "John", "age": 30 },
    { "name": "Jane", "age": 25 }
  ]
}

更新记录

根据过滤条件更新 Supabase 表中的记录。

使用示例:

{
  "table_name": "users",
  "filters": { "status": "inactive" },
  "updates": { "status": "active" }
}

删除记录

根据过滤条件从 Supabase 表中删除记录。

使用示例:

{
  "table_name": "users",
  "filters": { "id": 1 }
}

安全注意事项

  • 始终在安全的环境中使用服务角色密钥

  • 切勿在客户端代码中公开服务角色密钥

  • 在 Supabase 中使用适当的行级安全策略

  • 考虑对生产用途实施速率限制

贡献

  1. 分叉存储库

  2. 创建功能分支

  3. 提交你的更改

  4. 推送到分支

  5. 创建拉取请求

执照

麻省理工学院

-
security - not tested
A
license - permissive license
-
quality - not tested

Resources

Looking for Admin?

Admins can modify the Dockerfile, update the server description, and track usage metrics. If you are the server author, to access the admin panel.

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/ninad7007/supabase-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server