Supabase MCP Server

by ninad7007
MIT License

Integrations

  • Uses .env files for securely managing Supabase credentials and configuration settings for the MCP server.

  • Supports containerized deployment with Docker and Docker Compose, allowing for easy setup, management and troubleshooting of the MCP server environment.

  • Utilizes Pydantic for type-safe request/response handling, ensuring data validation and consistent interactions with the Supabase database.

Supabase MCP 服务器

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

特征

  • 通过过滤和列选择从任何 Supabase 表中读取行
  • 在表中创建单个或多个记录
  • 根据过滤条件更新记录
  • 根据过滤条件删除记录
  • 人工智能模型理解的全面工具描述
  • 使用 Pydantic 进行类型安全的请求/响应处理
  • Docker 支持,轻松部署

先决条件

  • 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

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

  1. 特征
    1. 先决条件
      1. 安装
        1. Docker 管理命令
        2. Docker 问题故障排除
      2. 在 AI IDE 中配置 MCP
        1. 常规配置步骤
        2. IDE 特定指令
        3. 验证 MCP 连接
      3. 用法
        1. 可用工具
          1. 读取行
          2. 创建记录
          3. 更新记录
          4. 删除记录
        2. 安全注意事项
          1. 贡献
            1. 执照

              Related MCP Servers

              • A
                security
                F
                license
                A
                quality
                A Model Context Protocol (MCP) server that provides programmatic access to the Supabase Management API. This server allows AI models and other clients to manage Supabase projects and organizations through a standardized interface.
                Last updated -
                8
                84
                27
                JavaScript
              • -
                security
                A
                license
                -
                quality
                A Model Context Protocol server optimized for integrating Supabase with the Windsurf Editor, providing database interactions through natural language with enhanced error handling and response formatting.
                Last updated -
                2
                TypeScript
                MIT License
              • -
                security
                F
                license
                -
                quality
                A Model Context Protocol server that enables querying feature suggestions from a Supabase database, allowing AI tools like Cursor and Claude to access and display feature request data.
                Last updated -
                TypeScript
              • -
                security
                A
                license
                -
                quality
                A Model Context Protocol server that enables Claude and other LLMs to perform database operations and invoke Edge Functions within Supabase through natural language.
                Last updated -
                TypeScript
                MIT License

              View all related MCP servers

              ID: 909joay3vo