Supabase MCP 服务器
用于与 Supabase 数据库交互的模型上下文协议 (MCP) 服务器。该服务器使用FastMCP Python SDK实现模型上下文协议,为大型语言模型 (LLM) 提供数据库操作工具。
特征
- 使用过滤、分页和排序功能从 Supabase 表中读取记录
- 在 Supabase 表中创建新记录(单个或批量)
- 根据过滤条件更新现有记录
- 根据过滤条件从表中删除记录
- 使用 MCP 的 Stdio 传输进行通信
先决条件
- Python 3.8 或更高版本
- 已设置表的 Supabase 项目
- Supabase 服务角色密钥用于身份验证
安装
- 克隆此存储库:
- 设置虚拟环境(推荐):
- 安装依赖项:
- 设置环境变量:
- 将
.env.example
文件复制到.env
: - 在
.env
文件中填写你的 Supabase URL 和服务角色键:
- 将
用法
启动服务器
确保您的虚拟环境已激活,然后运行服务器:
服务器使用 Stdio 传输,因此它将在标准输入上监听 MCP 请求并在标准输出上做出响应。
与 MCP 客户端集成
该服务器实现了模型上下文协议 (MCP),可以与任何兼容 MCP 的客户端集成。例如,您可以将其与支持 MCP 工具的 LLM 框架一起使用。
添加到 Windsurf/Cursor MCP 配置
要将此 MCP 服务器添加到您的 Windsurf 或 Cursor 配置:
- 找到您的
mcp_config.json
文件:- Windows:
C:\Users\<username>\.codeium\windsurf\mcp_config.json
- macOS:
~/.codeium/windsurf/mcp_config.json
- Linux:
~/.codeium/windsurf/mcp_config.json
- Windows:
- 将 Supabase MCP 服务器添加到
mcpServers
部分:
将/path/to/your/supabase-mcp/server.py
替换为您的 server.py 文件的绝对路径。
注意:为了更好地隔离,您可以使用虚拟环境中的 Python 可执行文件:
- 重新启动 Windsurf/Cursor 应用程序以应用更改。
- Supabase MCP 工具现在可供您的 AI 助手使用。
工具描述
该服务器提供以下工具:
1. 读取记录
使用灵活的查询选项从 Supabase 数据库表中读取记录。
参数:
table
(字符串,必需):要读取的表的名称columns
(字符串,可选,默认值:“*”):要选择的列(以逗号分隔或*表示全部)filters
(对象,可选):以键值对形式过滤条件limit
(整数,可选):返回的最大记录数offset
(整数,可选):分页时要跳过的记录数order_by
(对象,可选):以列:方向对的形式进行排序
例子:
2. 创建记录
在 Supabase 数据库表中创建一个或多个记录。
参数:
table
(字符串,必需):在其中创建记录的表的名称records
(对象或数组,必需):要创建的单个记录对象或记录对象数组
示例(单个记录):
示例(多条记录):
3. 更新记录
根据过滤条件更新 Supabase 数据库表中的现有记录。
参数:
table
(字符串,必需):要更新记录的表的名称updates
(对象,必需):要更新为键值对的字段filters
(对象,必需):用于识别要更新的记录的过滤条件
例子:
4. 删除记录
根据过滤条件从 Supabase 数据库表中删除记录。
参数:
table
(字符串,必需):要从中删除记录的表的名称filters
(对象,必需):用于确定要删除的记录的过滤条件
例子:
发展
项目结构
server.py
:主要 MCP 服务器实现supabase_client.py
:Supabase 客户端包装器requirements.txt
:Python 依赖项.env.example
:示例环境变量文件
添加新工具
要向服务器添加新工具:
- 在
server.py
中为该工具的请求参数定义一个 Pydantic 模型 - 向
SupabaseMCPServer
类添加处理程序方法 - 使用描述性名称和文档在
_register_tools
方法中注册该工具
执照
贡献
欢迎贡献代码!欢迎提交 Pull 请求。
This server cannot be installed
remote-capable server
The server can be hosted and run remotely because it primarily relies on remote services or has no dependency on the local environment.
实现模型上下文协议,为 LLM 提供与 Supabase 数据库交互的工具,支持读取、创建、更新和删除记录等操作,并具有过滤和分页功能。
Related MCP Servers
- AsecurityAlicenseAqualityA Model Context Protocol server that enables LLMs to interact with Salesforce data through SOQL queries, SOSL searches, and various API operations including record management.Last updated -1077PythonMIT License
- -securityAlicense-qualityA Model Context Protocol server that enables LLMs to interact directly with MongoDB databases, allowing users to query collections, inspect schemas, and manage data through natural language.Last updated -340TypeScriptMIT License
- -securityAlicense-qualityA Model Context Protocol server that enables LLMs to interact directly with MongoDB databases, allowing users to query collections, inspect schemas, and manage data through natural language.Last updated -340MIT License
- -securityAlicense-qualityA 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 -TypeScriptMIT License