# Supabase MCP工具
## 基本信息
- Slug: `dynamicendpoints-supabase-mcp`
- Source: modelscope
- Publisher: @DynamicEndpoints/supabase-mcp
- Categories: databases / cloud-storage
- Hosted: No
- License: MIT License
- Source URL: https://www.modelscope.cn/mcp/servers/@DynamicEndpoints/supabase-mcp
## 简介
一个提供与 Supabase 数据库、存储和边缘函数交互工具的 MCP 服务器。
## 安装提示

```bash
supabase-server/ ├── src/ │ ├── index.ts # Main server implementation │ └── types/ │ └── supabase.d.ts # Type definitions ├── package.json ├── tsconfig.json ├── config.json.example # Example configuration file └── .env.example # Environment variables template ``` ### 关键组件 - **Server 类**：实现 MCP 服务器接口并处理所有客户端请求 - **类型定义**：为所有操作提供全面的 TypeScript 定义 - **环境配置**：通过环境变量进行安全的配置管理 - **错误处理**：具有详细错误信息的强大错误处理 ## 前提条件 - Node.js 16.x 或更高版本 - 一个包含以下内容的 Supabase 项目： - 项目 URL - 服务角色密钥（用于管理员操作） - 访问令牌（用于管理操作） - MCP 兼容的客户端 ## 安装 ### 通过 Smithery 安装 要通过 [Smithery](https://smithery.ai/server/supabase-server) 自动安装适用于 Claude Desktop 的 Supabase 服务器：
```

## MCP Server 详情

# Supabase MCP 服务器

[![smithery 徽章](https://smithery.ai/badge/supabase-server)](https://smithery.ai/server/supabase-server)
这是一个 Model Context Protocol (MCP) 服务器，提供了与 Supabase 数据库、存储和边缘函数交互的全面工具。该服务器实现了 Supabase 服务与 MCP 兼容应用程序之间的无缝集成。

<a href="https://glama.ai/mcp/servers/vwi6nt8i80"><img width="380" height="200" src="https://glama.ai/mcp/servers/vwi6nt8i80/badge" alt="supabase-mcp MCP 服务器" /></a>

## 概览

Supabase MCP 服务器充当 MCP 客户端与 Supabase 服务套件之间的桥梁，提供以下功能：

- 带有丰富查询能力的数据库操作
- 文件和资产的存储管理
- 边缘函数调用
- 项目和组织管理
- 用户认证和管理
- 基于角色的访问控制

## 架构

该服务器使用 TypeScript 构建，并遵循模块化架构：

```
supabase-server/
├── src/
│   ├── index.ts              # Main server implementation
│   └── types/
│       └── supabase.d.ts     # Type definitions
├── package.json
├── tsconfig.json
├── config.json.example       # Example configuration file
└── .env.example             # Environment variables template
```


### 关键组件

- **Server 类**：实现 MCP 服务器接口并处理所有客户端请求
- **类型定义**：为所有操作提供全面的 TypeScript 定义
- **环境配置**：通过环境变量进行安全的配置管理
- **错误处理**：具有详细错误信息的强大错误处理

## 前提条件

- Node.js 16.x 或更高版本
- 一个包含以下内容的 Supabase 项目：
  - 项目 URL
  - 服务角色密钥（用于管理员操作）
  - 访问令牌（用于管理操作）
- MCP 兼容的客户端

## 安装

### 通过 Smithery 安装

要通过 [Smithery](https://smithery.ai/server/supabase-server) 自动安装适用于 Claude Desktop 的 Supabase 服务器：

```bash
npx -y @smithery/cli install supabase-server --client claude
```


1. 克隆仓库：
```bash
git clone https://github.com/DynamicEndpoints/supabase-mcp.git
cd supabase-mcp
```


2. 安装依赖项：
```bash
npm install
```


3. 创建环境配置：
```bash
cp .env.example .env
```


4. 配置环境变量：
```bash
SUPABASE_URL=your_project_url_here
SUPABASE_KEY=your_service_role_key_here
SUPABASE_ACCESS_TOKEN=your_access_token_here  # Required for management operations
```


5. 创建服务器配置：
```bash
cp config.json.example config.json
```


6. 构建服务器：
```bash
npm run build
```


## 配置

服务器通过环境变量和 `config.json` 文件支持广泛的配置选项。以下是配置选项的详细说明：

### 服务器配置
```json
{
  "server": {
    "name": "supabase-server",    // Server name
    "version": "0.1.0",           // Server version
    "port": 3000,                 // Port number (if running standalone)
    "host": "localhost"           // Host address (if running standalone)
  }
}
```


### Supabase 配置
```json
{
  "supabase": {
    "project": {
      "url": "your_project_url",
      "key": "your_service_role_key",
      "accessToken": "your_access_token"
    },
    "storage": {
      "defaultBucket": "public",           // Default storage bucket
      "maxFileSize": 52428800,            // Max file size in bytes (50MB)
      "allowedMimeTypes": [               // Allowed file types
        "image/*",
        "application/pdf",
        "text/*"
      ]
    },
    "database": {
      "maxConnections": 10,               // Max DB connections
      "timeout": 30000,                   // Query timeout in ms
      "ssl": true                         // SSL connection
    },
    "auth": {
      "autoConfirmUsers": false,          // Auto-confirm new users
      "disableSignup": false,             // Disable public signups
      "jwt": {
        "expiresIn": "1h",               // Token expiration
        "algorithm": "HS256"              // JWT algorithm
      }
    }
  }
}
```


### 日志配置
```json
{
  "logging": {
    "level": "info",                      // Log level
    "format": "json",                     // Log format
    "outputs": ["console", "file"],       // Output destinations
    "file": {
      "path": "logs/server.log",          // Log file path
      "maxSize": "10m",                   // Max file size
      "maxFiles": 5                       // Max number of files
    }
  }
}
```


### 安全配置
```json
{
  "security": {
    "cors": {
      "enabled": true,
      "origins": ["*"],
      "methods": ["GET", "POST", "PUT", "DELETE", "OPTIONS"],
      "allowedHeaders": ["Content-Type", "Authorization"]
    },
    "rateLimit": {
      "enabled": true,
      "windowMs": 900000,                 // 15 minutes
      "max": 100                          // Max requests per window
    }
  }
}
```


### 监控配置
```json
{
  "monitoring": {
    "enabled": true,
    "metrics": {
      "collect": true,
      "interval": 60000                   // Collection interval in ms
    },
    "health": {
      "enabled": true,
      "path": "/health"                   // Health check endpoint
    }
  }
}
```


请参阅 `config.json.example` 以获取完整的示例配置文件。

## MCP 集成

将服务器添加到您的 MCP 设置中（cline_mcp_settings.json）：

```json
{
  "mcpServers": {
    "supabase": {
      "command": "node",
      "args": ["path/to/supabase-server/build/index.js"],
      "env": {
        "SUPABASE_URL": "your_project_url",
        "SUPABASE_KEY": "your_service_role_key",
        "SUPABASE_ACCESS_TOKEN": "your_access_token"
      },
      "config": "path/to/config.json"  // Optional: path to configuration file
    }
  }
}
```


## 可用工具

### 数据库操作

#### create_record
在表中创建新记录，并支持返回特定字段。

```typescript
{
  table: string;
  data: Record<string, any>;
  returning?: string[];
}
```


示例：
```typescript
{
  table: "users",
  data: {
    name: "John Doe",
    email: "john@example.com"
  },
  returning: ["id", "created_at"]
}
```


#### read_records
读取带有高级过滤、连接和字段选择的记录。

```typescript
{
  table: string;
  select?: string[];
  filter?: Record<string, any>;
  joins?: Array<{
    type?: 'inner' | 'left' | 'right' | 'full';
    table: string;
    on: string;
  }>;
}
```


示例：
```typescript
{
  table: "posts",
  select: ["id", "title", "user.name"],
  filter: { published: true },
  joins: [{
    type: "left",
    table: "users",
    on: "posts.user_id=users.id"
  }]
}
```


#### update_record
更新带有过滤和返回功能的记录。

```typescript
{
  table: string;
  data: Record<string, any>;
  filter?: Record<string, any>;
  returning?: string[];
}
```


示例：
```typescript
{
  table: "users",
  data: { status: "active" },
  filter: { email: "john@example.com" },
  returning: ["id", "status", "updated_at"]
}
```


#### delete_record
删除带有过滤和返回功能的记录。

```typescript
{
  table: string;
  filter?: Record<string, any>;
  returning?: string[];
}
``…

