Skip to main content
Glama
Supabase MCP Server

Supabase MCP Server

by NightTrek

Supabase MCP 服务器

用于与 Supabase 数据库交互的模型上下文协议 (MCP) 服务器。该服务器提供通过 MCP 接口查询表和生成 TypeScript 类型的工具。

特征

  • 查询表:对任何表执行查询,支持以下内容:

    • 模式选择

    • 列过滤

    • 具有多个运算符的 Where 子句

    • 分页

    • 错误处理

  • 类型生成:为您的数据库生成 TypeScript 类型:

    • 支持任何模式(公共、授权、API 等)

    • 适用于本地和远程 Supabase 项目

    • 直接输出到控制台

    • 自动项目参考检测

Related MCP server: SchemaFlow MCP Server

先决条件

  1. Node.js(v16 或更高版本)

  2. Supabase 项目(本地或托管)

  3. Supabase CLI(用于类型生成)

安装

  1. 克隆存储库:

git clone https://github.com/yourusername/supabase-mcp-server.git
cd supabase-mcp-server
  1. 安装依赖项:

npm install
  1. 安装 Supabase CLI(类型生成所需):

# Using npm
npm install -g supabase

# Or using Homebrew on macOS
brew install supabase/tap/supabase

配置

  1. 获取您的 Supabase 凭证:

    • 对于托管项目:

      1. 转到您的 Supabase 项目仪表板

      2. 导航至项目设置 > API

      3. 复制项目 URL 和 service_role 密钥(不是 anon 密钥)

    • 对于本地项目:

      1. 启动本地 Supabase 实例

      2. 使用本地 URL(通常为http://localhost:54321 )

      3. 使用本地 service_role 密钥

  2. 配置环境变量:

# Create a .env file (this will be ignored by git)
echo "SUPABASE_URL=your_project_url
SUPABASE_KEY=your_service_role_key" > .env
  1. 构建服务器:

npm run build

与 Claude Desktop 集成

  1. 打开Claude桌面设置:

    • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json

    • Windows: %APPDATA%\Claude\claude_desktop_config.json

    • Linux: ~/.config/Claude/claude_desktop_config.json

  2. 添加服务器配置:

{
  "mcpServers": {
    "supabase": {
      "command": "node",
      "args": ["/absolute/path/to/supabase-mcp-server/build/index.js"],
      "env": {
        "SUPABASE_URL": "your_project_url",
        "SUPABASE_KEY": "your_service_role_key"
      }
    }
  }
}

与 VSCode 扩展集成

  1. 打开 VSCode 设置:

    • macOS: ~/Library/Application Support/Code/User/globalStorage/saoudrizwan.claude-dev/settings/cline_mcp_settings.json

    • Windows: %APPDATA%\Code\User\globalStorage\saoudrizwan.claude-dev\settings\cline_mcp_settings.json

    • Linux: ~/.config/Code/User/globalStorage/saoudrizwan.claude-dev/settings/cline_mcp_settings.json

  2. 添加服务器配置(与 Claude Desktop 相同的格式)。

使用示例

查询表

// Query with schema selection and where clause
<use_mcp_tool>
<server_name>supabase</server_name>
<tool_name>query_table</tool_name>
<arguments>
{
  "schema": "public",
  "table": "users",
  "select": "id,name,email",
  "where": [
    {
      "column": "is_active",
      "operator": "eq",
      "value": true
    }
  ]
}
</arguments>
</use_mcp_tool>

生成类型

// Generate types for public schema
<use_mcp_tool>
<server_name>supabase</server_name>
<tool_name>generate_types</tool_name>
<arguments>
{
  "schema": "public"
}
</arguments>
</use_mcp_tool>

可用工具

查询表

使用模式选择和 where 子句支持查询特定表。

参数:

  • schema (可选):数据库模式(默认为公共)

  • table (必填):要查询的表的名称

  • select (可选):以逗号分隔的列列表

  • where (可选):条件数组,包含:

    • column :列名

    • operator :eq、neq、gt、gte、lt、lte、like、ilike、is 之一

    • value :要比较的值

生成类型

为您的 Supabase 数据库模式生成 TypeScript 类型。

参数:

  • schema (可选):数据库模式(默认为公共)

故障排除

类型生成问题

  1. 确保已安装 Supabase CLI:

supabase --version
  1. 对于本地项目:

    • 确保您的本地 Supabase 实例正在运行

    • 验证您的 service_role 键是否正确

  2. 对于托管项目:

    • 确认您的项目参考正确(从 URL 中提取)

    • 验证您使用的是 service_role 密钥,而不是 anon 密钥

查询问题

  1. 检查您的架构和表名称

  2. 验证 select 和 where 子句中的列名

  3. 确保您的 service_role 密钥具有必要的权限

贡献

  1. 分叉存储库

  2. 创建你的功能分支: git checkout -b feature/my-feature

  3. 提交您的更改: git commit -am 'Add my feature'

  4. 推送到分支: git push origin feature/my-feature

  5. 提交拉取请求

执照

MIT 许可证 - 详情请参阅许可证文件

Available Tools

2 tools
generate_typesB

Generate TypeScript types for your Supabase database schema

Inputs: schema.

query_tableC

Query a specific table with schema selection and where clause support

Inputs: table (required), schema, select, where.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    B3.1/5.0

    Scored across 2 tools

    Disambiguation5/5

    The two tools have clearly distinct purposes: generate_types focuses on TypeScript type generation from the database schema, while query_table handles data retrieval from specific tables with filtering. There is no overlap or ambiguity between these functions.

    Naming Consistency5/5

    Both tools follow a consistent verb_noun naming pattern (generate_types and query_table), using snake_case throughout. The naming is predictable and readable without any deviations.

    Tool Count2/5

    With only 2 tools, the server feels under-scoped for a Supabase integration, which typically involves operations like create, update, delete, and schema management beyond just querying and type generation. This limited set may hinder agent workflows.

    Completeness2/5

    The server lacks essential CRUD operations (e.g., insert, update, delete) and other Supabase features like authentication or real-time subscriptions, making it severely incomplete for typical database interactions. Agents will face significant gaps in functionality.

    Maintenance

    ActivityMaintained
    ResponsivenessOutdated data

    Related MCP Connectors

    Related MCP Servers

    • F
      license
      Not graded
      quality
      D
      maintenance
      Implements the Model Context Protocol to provide LLMs with tools for interacting with Supabase databases, supporting operations like reading, creating, updating, and deleting records with filtering and pagination capabilities.
      -
    • A
      license
      Not graded
      quality
      D
      maintenance
      Provides AI-IDEs with real-time access to PostgreSQL and Supabase database schemas through the Model Context Protocol, enabling smarter code generation in tools like Cursor, Windsurf, and VS Code + Cline.
      10
      MIT
    • A
      license
      A
      quality
      D
      maintenance
      A Model Context Protocol server that enables interaction with self-hosted Supabase instances, allowing developers to query database schemas, manage migrations, inspect statistics, and interact with Supabase features directly from MCP-compatible development environments.
      21
      1
      ISC
    • A
      license
      Not graded
      quality
      D
      maintenance
      Connects AI assistants to Supabase projects to manage databases, execute SQL queries, and handle project configurations. It enables tasks like table management, edge function deployment, and log retrieval through the Model Context Protocol.
      Apache 2.0