Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
159 changes: 159 additions & 0 deletions server/mcp_server_supabase/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,159 @@
# Supabase MCP Server

English | [简体中文](README_zh.md)

> Supabase MCP server for AIDAP workspaces. It exposes workspace, branch, database, Edge Functions, storage, and TypeScript type generation capabilities through MCP.

| Item | Details |
| ---- | ---- |
| Version | v0.1.0 |
| Description | Supabase MCP server built on top of AIDAP workspaces |
| Category | Database / Developer Tools |
| Tags | Supabase, PostgreSQL, Edge Functions, Storage, AIDAP |

## Tools

### Workspace and Branch

| Tool | Description |
| ---- | ---- |
| `list_workspaces` | List all available Supabase workspaces in the current account |
| `get_workspace` | Get workspace details; branch IDs are also accepted |
| `create_workspace` | Create a new Supabase workspace |
| `pause_workspace` | Pause a workspace |
| `restore_workspace` | Resume a paused workspace |
| `get_workspace_url` | Get the API endpoint for a workspace or branch |
| `get_publishable_keys` | Get publishable, anon, and service role keys |
| `list_branches` | List branches under a workspace |
| `create_branch` | Create a development branch |
| `delete_branch` | Delete a development branch |
| `reset_branch` | Reset a branch to its baseline state |

### Database

| Tool | Description |
| ---- | ---- |
| `execute_sql` | Execute raw SQL against the Postgres database |
| `list_tables` | List tables in one or more schemas |
| `list_migrations` | List records from `supabase_migrations.schema_migrations` |
| `list_extensions` | List installed PostgreSQL extensions |
| `apply_migration` | Run migration SQL and record it in `supabase_migrations.schema_migrations` |
| `generate_typescript_types` | Generate TypeScript definitions from schema metadata |

### Edge Functions

| Tool | Description |
| ---- | ---- |
| `list_edge_functions` | List Edge Functions in a workspace or branch |
| `get_edge_function` | Get the source code and configuration of an Edge Function |
| `deploy_edge_function` | Create or update an Edge Function |
| `delete_edge_function` | Delete an Edge Function |

### Storage

| Tool | Description |
| ---- | ---- |
| `list_storage_buckets` | List storage buckets |
| `create_storage_bucket` | Create a new storage bucket |
| `delete_storage_bucket` | Delete a storage bucket |
| `get_storage_config` | Get storage configuration |

## Authentication

Use Volcengine AK/SK authentication. Obtain your credentials from the [Volcengine API Access Key console](https://console.volcengine.com/iam/keymanage/).

## Environment Variables

| Name | Required | Default | Description |
| ---- | ---- | ---- | ---- |
| `VOLCENGINE_ACCESS_KEY` | Yes | - | Volcengine access key |
| `VOLCENGINE_SECRET_KEY` | Yes | - | Volcengine secret key |
| `VOLCENGINE_REGION` | No | `cn-beijing` | Region used for the AIDAP API |
| `DEFAULT_WORKSPACE_ID` | No | - | Default target used when `workspace_id` is omitted |
| `READ_ONLY` | No | `false` | Set to `true` to block all mutating tools |
| `SUPABASE_WORKSPACE_SLUG` | No | `default` | Project slug used by Edge Functions APIs |
| `SUPABASE_ENDPOINT_SCHEME` | No | `http` | Endpoint scheme used when building workspace URLs |
| `PORT` | No | `8000` | Port used when running the server directly |

## Deployment

### Run from a local checkout

```bash
uv --directory /ABSOLUTE/PATH/TO/mcp-server/server/mcp_server_supabase run mcp-server-supabase
```

### MCP client config with local source

```json
{
"mcpServers": {
"supabase": {
"command": "uv",
"args": [
"--directory",
"/ABSOLUTE/PATH/TO/mcp-server/server/mcp_server_supabase",
"run",
"mcp-server-supabase"
],
"env": {
"VOLCENGINE_ACCESS_KEY": "<your-access-key>",
"VOLCENGINE_SECRET_KEY": "<your-secret-key>",
"VOLCENGINE_REGION": "cn-beijing",
"DEFAULT_WORKSPACE_ID": "ws-xxxxxxxx"
}
}
}
}
```

### MCP client config with `uvx`

```json
{
"mcpServers": {
"supabase": {
"command": "uvx",
"args": [
"--from",
"git+https://github.com/volcengine/mcp-server#subdirectory=server/mcp_server_supabase",
"mcp-server-supabase"
],
"env": {
"VOLCENGINE_ACCESS_KEY": "<your-access-key>",
"VOLCENGINE_SECRET_KEY": "<your-secret-key>",
"VOLCENGINE_REGION": "cn-beijing",
"DEFAULT_WORKSPACE_ID": "ws-xxxxxxxx"
}
}
}
}
```

### Direct Python entrypoint

```bash
python3 -m mcp_server_supabase.server --port 8000
```

The package exposes both `mcp-server-supabase` and `supabase-aidap`. The examples above use `mcp-server-supabase`.

## Usage Notes

- If `workspace_id` is omitted, the server falls back to `DEFAULT_WORKSPACE_ID` when configured.
- If a branch ID such as `br-xxxx` is provided, the server resolves the corresponding workspace automatically.
- `get_publishable_keys` resolves the default branch automatically when needed.
- `reset_branch` accepts `migration_version`, but the current AIDAP API ignores that value and performs a branch reset only.
- `deploy_edge_function` currently supports `native-node20/v1`, `native-python3.9/v1`, `native-python3.10/v1`, and `native-python3.12/v1`.

## Compatible Clients

- Cursor
- Claude Desktop
- Cline
- Trae
- Any MCP client that supports `stdio`

## License

volcengine/mcp-server is licensed under the [MIT License](https://github.com/volcengine/mcp-server/blob/main/LICENSE).
Copy link

Copilot AI Mar 6, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The README states the project is licensed under MIT, but pyproject.toml declares Apache-2.0. Please align the README and packaging metadata to reflect the actual license for this subproject.

Suggested change
volcengine/mcp-server is licensed under the [MIT License](https://github.com/volcengine/mcp-server/blob/main/LICENSE).
volcengine/mcp-server is licensed under the [Apache License 2.0](https://github.com/volcengine/mcp-server/blob/main/LICENSE).

Copilot uses AI. Check for mistakes.
159 changes: 159 additions & 0 deletions server/mcp_server_supabase/README_zh.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,159 @@
# Supabase MCP Server

[English](README.md) | 简体中文

> 面向 AIDAP workspace 的 Supabase MCP Server,通过 MCP 暴露工作区、分支、数据库、Edge Functions、Storage 和 TypeScript 类型生成能力。

| 项目 | 详情 |
| ---- | ---- |
| 版本 | v0.1.0 |
| 描述 | 基于 AIDAP workspace 的 Supabase MCP Server |
| 分类 | 数据库 / 开发工具 |
| 标签 | Supabase, PostgreSQL, Edge Functions, Storage, AIDAP |

## 工具列表

### 工作区与分支

| 工具 | 说明 |
| ---- | ---- |
| `list_workspaces` | 列出当前账号下可访问的 Supabase workspace |
| `get_workspace` | 查询 workspace 详情,也支持直接传 branch ID |
| `create_workspace` | 创建新的 Supabase workspace |
| `pause_workspace` | 暂停 workspace |
| `restore_workspace` | 恢复已暂停的 workspace |
| `get_workspace_url` | 获取 workspace 或 branch 的 API 地址 |
| `get_publishable_keys` | 获取 publishable、anon、service_role 等密钥 |
| `list_branches` | 列出 workspace 下的分支 |
| `create_branch` | 创建开发分支 |
| `delete_branch` | 删除开发分支 |
| `reset_branch` | 将分支重置到初始状态 |

### 数据库

| 工具 | 说明 |
| ---- | ---- |
| `execute_sql` | 在 Postgres 数据库上执行原始 SQL |
| `list_tables` | 列出一个或多个 schema 下的表 |
| `list_migrations` | 查询 `supabase_migrations.schema_migrations` 中的迁移记录 |
| `list_extensions` | 列出已安装的 PostgreSQL 扩展 |
| `apply_migration` | 执行迁移 SQL,并写入 `supabase_migrations.schema_migrations` |
| `generate_typescript_types` | 根据 schema 元数据生成 TypeScript 类型定义 |

### Edge Functions

| 工具 | 说明 |
| ---- | ---- |
| `list_edge_functions` | 列出 workspace 或 branch 下的 Edge Functions |
| `get_edge_function` | 获取 Edge Function 的代码和配置 |
| `deploy_edge_function` | 创建或更新 Edge Function |
| `delete_edge_function` | 删除 Edge Function |

### Storage

| 工具 | 说明 |
| ---- | ---- |
| `list_storage_buckets` | 列出存储桶 |
| `create_storage_bucket` | 创建新的存储桶 |
| `delete_storage_bucket` | 删除存储桶 |
| `get_storage_config` | 获取 Storage 配置 |

## 鉴权方式

使用火山引擎 AK/SK 鉴权。可在[火山引擎 API 访问密钥控制台](https://console.volcengine.com/iam/keymanage/)获取凭证。

## 环境变量

| 变量名 | 必需 | 默认值 | 说明 |
| ---- | ---- | ---- | ---- |
| `VOLCENGINE_ACCESS_KEY` | 是 | - | 火山引擎 Access Key |
| `VOLCENGINE_SECRET_KEY` | 是 | - | 火山引擎 Secret Key |
| `VOLCENGINE_REGION` | 否 | `cn-beijing` | AIDAP API 所在地域 |
| `DEFAULT_WORKSPACE_ID` | 否 | - | 未传 `workspace_id` 时使用的默认目标 |
| `READ_ONLY` | 否 | `false` | 设为 `true` 后会禁止所有写操作工具 |
| `SUPABASE_WORKSPACE_SLUG` | 否 | `default` | Edge Functions API 使用的项目 slug |
| `SUPABASE_ENDPOINT_SCHEME` | 否 | `http` | 生成 workspace URL 时使用的协议 |
| `PORT` | 否 | `8000` | 直接启动服务时监听的端口 |

## 部署

### 在本地代码仓库中运行

```bash
uv --directory /ABSOLUTE/PATH/TO/mcp-server/server/mcp_server_supabase run mcp-server-supabase
```

### 使用本地源码配置 MCP Client

```json
{
"mcpServers": {
"supabase": {
"command": "uv",
"args": [
"--directory",
"/ABSOLUTE/PATH/TO/mcp-server/server/mcp_server_supabase",
"run",
"mcp-server-supabase"
],
"env": {
"VOLCENGINE_ACCESS_KEY": "<your-access-key>",
"VOLCENGINE_SECRET_KEY": "<your-secret-key>",
"VOLCENGINE_REGION": "cn-beijing",
"DEFAULT_WORKSPACE_ID": "ws-xxxxxxxx"
}
}
}
}
```

### 使用 `uvx` 配置 MCP Client

```json
{
"mcpServers": {
"supabase": {
"command": "uvx",
"args": [
"--from",
"git+https://github.com/volcengine/mcp-server#subdirectory=server/mcp_server_supabase",
"mcp-server-supabase"
],
"env": {
"VOLCENGINE_ACCESS_KEY": "<your-access-key>",
"VOLCENGINE_SECRET_KEY": "<your-secret-key>",
"VOLCENGINE_REGION": "cn-beijing",
"DEFAULT_WORKSPACE_ID": "ws-xxxxxxxx"
}
}
}
}
```

### 直接使用 Python 入口启动

```bash
python3 -m mcp_server_supabase.server --port 8000
```

这个包同时暴露了 `mcp-server-supabase` 和 `supabase-aidap` 两个入口,示例统一使用 `mcp-server-supabase`。

## 使用说明

- 如果没有显式传入 `workspace_id`,且配置了 `DEFAULT_WORKSPACE_ID`,服务会自动使用这个默认目标。
- 如果传入的是 `br-xxxx` 这样的 branch ID,服务会自动解析所属 workspace。
- `get_publishable_keys` 在需要时会自动解析默认分支。
- `reset_branch` 虽然接收 `migration_version` 参数,但当前 AIDAP API 会忽略这个值,只执行分支重置。
- `deploy_edge_function` 当前支持 `native-node20/v1`、`native-python3.9/v1`、`native-python3.10/v1`、`native-python3.12/v1`。

## 可适配客户端

- Cursor
- Claude Desktop
- Cline
- Trae
- 所有支持 `stdio` 的 MCP Client

## License

volcengine/mcp-server is licensed under the [MIT License](https://github.com/volcengine/mcp-server/blob/main/LICENSE).
49 changes: 49 additions & 0 deletions server/mcp_server_supabase/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
[project]
name = "mcp-server-supabase"
version = "0.1.0"
description = "MCP server for Supabase/AIDAP"
readme = "README.md"
requires-python = ">=3.10"
license = { text = "Apache-2.0" }
authors = [
{ name = "Volcengine", email = "support@volcengine.com" }
]
dependencies = [
"mcp>=1.1.2",
"httpx>=0.27.0",
"pydantic>=2.0.0",
"volcengine-python-sdk @ git+https://github.com/sjcsjcsjc/volcengine-python-sdk.git",
]

[project.optional-dependencies]
dev = [
"pytest>=8.0.0",
"pytest-asyncio>=0.23.0",
"black>=24.0.0",
"ruff>=0.3.0",
]
legacy = [
"psycopg2-binary>=2.9.0",
]

[project.scripts]
mcp-server-supabase = "mcp_server_supabase.server:main"
supabase-aidap = "mcp_server_supabase.server:main"

[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"

[tool.hatch.build.targets.wheel]
packages = ["src/mcp_server_supabase"]

[tool.hatch.metadata]
allow-direct-references = true

[tool.black]
line-length = 100
target-version = ["py310"]

[tool.ruff]
line-length = 100
target-version = "py310"
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
"""Supabase MCP Server package."""

__version__ = "0.1.0"
Loading