@aliyun-rds/supabase-mcp-server 1.0.2 → 1.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/README.md +207 -10
  2. package/dist/index.js +1254 -353
  3. package/package.json +6 -3
package/README.md CHANGED
@@ -4,10 +4,29 @@ MCP (Model Context Protocol) server for self-hosted Supabase instances. Allows A
4
4
 
5
5
  Originally developed by [HenkDz](https://github.com/HenkDz), now maintained by lemontreen.
6
6
 
7
+ ## 🚀 Two Modes of Operation
8
+
9
+ This server supports two modes:
10
+
11
+ ### 1. **Alibaba Cloud Mode** (Recommended for Alibaba Cloud RDS AI users)
12
+ - Automatically fetches Supabase credentials from Alibaba Cloud OpenAPI
13
+ - Only requires Alibaba Cloud AccessKey (AK) and SecretKey (SK)
14
+ - Supports multiple Supabase instances with interactive selection
15
+ - No need to manually configure `anon-key`, `service-key`, or `jwt-secret`
16
+
17
+ ### 2. **Legacy Mode** (For standard self-hosted Supabase)
18
+ - Requires manual configuration of Supabase URL and keys
19
+ - Compatible with any self-hosted Supabase instance
20
+
7
21
  ## Features
8
22
 
9
23
  This server exposes a rich set of tools for interacting with your self-hosted Supabase instance:
10
24
 
25
+ * **Alibaba Cloud Management** (Alibaba Cloud Mode only)
26
+ * `list_aliyun_supabase_instances`: Lists all Supabase instances from Alibaba Cloud RDS AI.
27
+ * `connect_to_supabase_instance`: Connects to a specific Supabase instance by name.
28
+ * `get_current_supabase_instance`: Shows the currently connected instance.
29
+ * `disconnect_supabase_instance`: Disconnects from the current instance.
11
30
  * **Database Schema**
12
31
  * `list_tables`: Lists all tables in the `public` schema.
13
32
  * `list_extensions`: Lists installed PostgreSQL extensions.
@@ -15,7 +34,7 @@ This server exposes a rich set of tools for interacting with your self-hosted Su
15
34
  * `get_database_stats`: Gets database statistics (e.g., table sizes).
16
35
  * **Migrations & SQL**
17
36
  * `list_migrations`: Lists applied migrations from the `supabase_migrations` schema.
18
- * `apply_migration`: Applies a new SQL migration (Requires direct DB access).
37
+ * `apply_migration`: Applies a new SQL migration via RPC.
19
38
  * `execute_sql`: Executes arbitrary SQL (Requires helper function in DB or direct DB access).
20
39
  * `generate_typescript_types`: Generates TypeScript types from the database schema.
21
40
  * **Project Configuration**
@@ -28,9 +47,9 @@ This server exposes a rich set of tools for interacting with your self-hosted Su
28
47
  * **Auth User Management**
29
48
  * `list_auth_users`: Lists users from `auth.users`.
30
49
  * `get_auth_user`: Retrieves details for a specific user.
31
- * `create_auth_user`: Creates a new user (Requires direct DB access, insecure password handling).
32
- * `delete_auth_user`: Deletes a user (Requires direct DB access).
33
- * `update_auth_user`: Updates user details (Requires direct DB access, insecure password handling).
50
+ * `create_auth_user`: Creates a new user using Supabase Admin API.
51
+ * `delete_auth_user`: Deletes a user using Supabase Admin API.
52
+ * `update_auth_user`: Updates user details using Supabase Admin API.
34
53
  * **Storage Insights**
35
54
  * `list_storage_buckets`: Lists all storage buckets.
36
55
  * `list_storage_objects`: Lists objects within a specific bucket.
@@ -51,12 +70,98 @@ For example, when you ask an AI assistant "List all tables in my database", it w
51
70
 
52
71
  ## Setup and Installation
53
72
 
54
- ### Method 1: Using npx (Recommended)
73
+ ### Alibaba Cloud Mode Setup
74
+
75
+ #### Quick Start with npx
76
+
77
+ ```bash
78
+ npx @aliyun-rds/supabase-mcp-server \
79
+ --aliyun-ak YOUR_ACCESS_KEY_ID \
80
+ --aliyun-sk YOUR_ACCESS_KEY_SECRET \
81
+ --aliyun-region cn-hangzhou
82
+ ```
83
+
84
+ **Important**: The `--aliyun-region` parameter is **required**. Without it, the API will return empty instance lists even though no error is reported. Common regions include:
85
+ - `cn-hangzhou` (China East 1)
86
+ - `cn-beijing` (China North 2)
87
+ - `cn-shanghai` (China East 2)
88
+ - `cn-shenzhen` (China South 1)
89
+
90
+ #### Configuration for Claude Desktop
91
+
92
+ Add to your `claude_desktop_config.json`:
93
+
94
+ ```json
95
+ {
96
+ "mcpServers": {
97
+ "aliyun-supabase": {
98
+ "command": "npx",
99
+ "args": [
100
+ "@aliyun-rds/supabase-mcp-server",
101
+ "--aliyun-ak", "YOUR_ACCESS_KEY_ID",
102
+ "--aliyun-sk", "YOUR_ACCESS_KEY_SECRET",
103
+ "--aliyun-region", "cn-hangzhou"
104
+ ]
105
+ }
106
+ }
107
+ }
108
+ ```
109
+
110
+ **With RAG Agent integration:**
111
+
112
+ ```json
113
+ {
114
+ "mcpServers": {
115
+ "aliyun-supabase": {
116
+ "command": "npx",
117
+ "args": [
118
+ "@aliyun-rds/supabase-mcp-server",
119
+ "--aliyun-ak", "YOUR_ACCESS_KEY_ID",
120
+ "--aliyun-sk", "YOUR_ACCESS_KEY_SECRET",
121
+ "--aliyun-region", "cn-hangzhou",
122
+ "--enable-rag-agent"
123
+ ]
124
+ }
125
+ }
126
+ }
127
+ ```
128
+
129
+ Or use environment variables:
130
+
131
+ ```json
132
+ {
133
+ "mcpServers": {
134
+ "aliyun-supabase": {
135
+ "command": "npx",
136
+ "args": [
137
+ "@aliyun-rds/supabase-mcp-server",
138
+ "--enable-rag-agent"
139
+ ],
140
+ "env": {
141
+ "ALIYUN_ACCESS_KEY_ID": "YOUR_ACCESS_KEY_ID",
142
+ "ALIYUN_ACCESS_KEY_SECRET": "YOUR_ACCESS_KEY_SECRET",
143
+ "ALIYUN_REGION": "cn-hangzhou"
144
+ }
145
+ }
146
+ }
147
+ }
148
+ ```
149
+
150
+ #### Usage Workflow
151
+
152
+ 1. **List instances**: Use `list_aliyun_supabase_instances` to see all your Supabase instances
153
+ 2. **Connect**: Use `connect_to_supabase_instance` with the instance name
154
+ 3. **Use tools**: Now you can use all Supabase tools (list_tables, execute_sql, etc.)
155
+ 4. **Disconnect** (optional): Use `disconnect_supabase_instance` to switch instances
156
+
157
+ ### Legacy Mode Setup
158
+
159
+ #### Method 1: Using npx (Recommended)
55
160
 
56
161
  The easiest way to use this server is via npx, which requires no installation:
57
162
 
58
163
  ```bash
59
- npx @lemontreen/rds-supabase-mcp-server --url http://localhost:8000 --anon-key YOUR_ANON_KEY
164
+ npx @aliyun-rds/supabase-mcp-server --url http://localhost:8000 --anon-key YOUR_ANON_KEY
60
165
  ```
61
166
 
62
167
  ### Method 2: Installing via Smithery
@@ -72,7 +177,7 @@ npx -y @smithery/cli install @HenkDz/selfhosted-supabase-mcp --client claude
72
177
  Install the package globally:
73
178
 
74
179
  ```bash
75
- npm install -g @lemontreen/rds-supabase-mcp-server
180
+ npm install -g @aliyun-rds/supabase-mcp-server
76
181
  supabase-mcp --url http://localhost:8000 --anon-key YOUR_ANON_KEY
77
182
  ```
78
183
 
@@ -107,6 +212,16 @@ If you want to build from source:
107
212
 
108
213
  The server requires configuration details for your Supabase instance. These can be provided via command-line arguments or environment variables. CLI arguments take precedence.
109
214
 
215
+ ### Alibaba Cloud Mode Parameters
216
+
217
+ **Required:**
218
+
219
+ * `--aliyun-ak <key>` or `ALIYUN_ACCESS_KEY_ID=<key>`: Your Alibaba Cloud Access Key ID.
220
+ * `--aliyun-sk <secret>` or `ALIYUN_ACCESS_KEY_SECRET=<secret>`: Your Alibaba Cloud Access Key Secret.
221
+ * `--aliyun-region <region>` or `ALIYUN_REGION=<region>`: **Required**. The Alibaba Cloud region where your Supabase instances are deployed (e.g., `cn-hangzhou`, `cn-beijing`). Without this parameter, the API will return empty instance lists.
222
+
223
+ ### Legacy Mode Parameters
224
+
110
225
  **Required:**
111
226
 
112
227
  * `--url <url>` or `SUPABASE_URL=<url>`: The main HTTP URL of your Supabase project (e.g., `http://localhost:8000`).
@@ -118,11 +233,53 @@ The server requires configuration details for your Supabase instance. These can
118
233
  * `--db-url <url>` or `DATABASE_URL=<url>`: The direct PostgreSQL connection string for your Supabase database (e.g., `postgresql://postgres:password@localhost:5432/postgres`). Required for tools needing direct database access or transactions (`apply_migration`, Auth tools, Storage tools, querying `pg_catalog`, etc.).
119
234
  * `--jwt-secret <secret>` or `SUPABASE_AUTH_JWT_SECRET=<secret>`: Your Supabase project's JWT secret. Needed for tools like `verify_jwt_secret`.
120
235
  * `--tools-config <path>`: Path to a JSON file specifying which tools to enable (whitelist). If omitted, all tools defined in the server are enabled. The file should have the format `{"enabledTools": ["tool_name_1", "tool_name_2"]}`.
236
+ * `--enable-rag-agent` or `ENABLE_RAG_AGENT=true`: Enable RAG Agent MCP integration. When enabled, this server will connect to a rag-agent MCP server and expose its tools alongside the Supabase tools. The host and port are extracted from `--url`, and `--anon-key` is used as the API key for rag-agent.
237
+
238
+ ### RAG Agent Integration
239
+
240
+ This server can integrate with [rag-agent-mcp](https://pypi.org/project/rag-agent-mcp/) to provide RAG (Retrieval-Augmented Generation) capabilities alongside your Supabase database tools.
241
+
242
+ **How it works:**
243
+ - When `--enable-rag-agent` is set, the server automatically connects to a rag-agent MCP server
244
+ - The host and port are extracted from your `--url` parameter (e.g., `http://your-server:8080` → host: `your-server`, port: `8080`)
245
+ - The `--anon-key` value is used as the API key for authenticating with rag-agent
246
+ - All rag-agent tools are prefixed with `rag_` to avoid naming conflicts (e.g., `rag_create_collection`, `rag_add_documents`, `rag_query`)
247
+
248
+ **Example configuration:**
249
+ ```bash
250
+ npx @aliyun-rds/supabase-mcp-server \
251
+ --url http://your-supabase-url:port \
252
+ --anon-key "your-anon-key-here" \
253
+ --service-key "your-service-key-here" \
254
+ --enable-rag-agent
255
+ ```
256
+
257
+ **Alibaba Cloud Mode with RAG Agent:**
258
+ ```bash
259
+ npx @aliyun-rds/supabase-mcp-server \
260
+ --aliyun-ak YOUR_ACCESS_KEY_ID \
261
+ --aliyun-sk YOUR_ACCESS_KEY_SECRET \
262
+ --aliyun-region cn-hangzhou \
263
+ --enable-rag-agent
264
+ ```
265
+
266
+ **Requirements:**
267
+ - `uvx` must be installed on your system
268
+ - `rag-agent-mcp` package must be available via `uvx`
269
+ - The rag-agent service must be running at the specified host and port
270
+
271
+ **Behavior Differences:**
272
+ - **Legacy Mode**: RAG Agent tools are initialized immediately and available after server startup
273
+ - **Alibaba Cloud Mode**: RAG Agent tools are listed at startup but only become functional after connecting to a Supabase instance using `connect_to_supabase_instance` tool
121
274
 
122
275
  ### Important Notes:
123
276
 
124
277
  * **`execute_sql` Helper Function:** Many tools rely on a `public.execute_sql` function within your Supabase database for secure and efficient SQL execution via RPC. The server attempts to check for this function on startup. If it's missing *and* a `service-key` (or `SUPABASE_SERVICE_ROLE_KEY`) *and* `db-url` (or `DATABASE_URL`) are provided, it will attempt to create the function and grant necessary permissions. If creation fails or keys aren't provided, tools relying solely on RPC may fail.
125
278
  * **Direct Database Access:** Tools interacting directly with privileged schemas (`auth`, `storage`) or system catalogs (`pg_catalog`) generally require the `DATABASE_URL` to be configured for a direct `pg` connection.
279
+ * **Database URL Special Characters:** If your database password or username contains special characters (such as `#`, `$`, etc.), they need to be properly URL encoded to prevent connection issues. The server automatically handles common special characters in the database URL:
280
+ * `#` is automatically encoded as `%23`
281
+ * `$` is automatically encoded as `%24`
282
+ * Note: The `@` symbol is not encoded as it serves as a delimiter in the URL between credentials and hostname
126
283
 
127
284
  ## Using with AI Assistant Tools
128
285
 
@@ -134,10 +291,10 @@ The server requires configuration details for your Supabase instance. These can
134
291
  ```json
135
292
  {
136
293
  "mcpServers": {
137
- "selfhosted-supabase": {
294
+ "selfhosted-supabase": {
138
295
  "command": "npx",
139
296
  "args": [
140
- "@lemontreen/rds-supabase-mcp-server",
297
+ "@aliyun-rds/supabase-mcp-server",
141
298
  "--url",
142
299
  "<your-supabase-url>", // e.g., "http://localhost:8000"
143
300
  "--anon-key",
@@ -151,13 +308,53 @@ The server requires configuration details for your Supabase instance. These can
151
308
  "<your-jwt-secret>",
152
309
  // Optional - Whitelist specific tools
153
310
  "--tools-config",
154
- "<path-to-tools-config.json>"
311
+ "<path-to-tools-config.json>",
312
+ // Optional - Enable RAG Agent integration
313
+ "--enable-rag-agent"
155
314
  ]
156
315
  }
157
316
  }
158
317
  }
159
318
  ```
160
319
 
320
+ **Example with RAG Agent integration:**
321
+
322
+ If you want to use this server with both Supabase and RAG Agent tools, configure it like this:
323
+
324
+ ```json
325
+ {
326
+ "mcpServers": {
327
+ "remote-selfhosted-supabase": {
328
+ "command": "ssh",
329
+ "args": [
330
+ "user@your-server-ip",
331
+ "cd /path/to/selfhosted-supabase-mcp && node dist/index.js",
332
+ "--url",
333
+ "http://your-supabase-url:port",
334
+ "--anon-key",
335
+ "your-anon-key-here",
336
+ "--service-key",
337
+ "your-service-key-here",
338
+ "--enable-rag-agent"
339
+ ]
340
+ }
341
+ }
342
+ }
343
+ ```
344
+
345
+ In this configuration:
346
+ - The server runs on a remote machine via SSH
347
+ - It connects to Supabase at the specified URL
348
+ - `--enable-rag-agent` enables RAG Agent integration
349
+ - RAG Agent will automatically connect to the same host:port extracted from `--url`
350
+ - Both Supabase and RAG Agent tools will be available to your AI assistant
351
+
352
+ **Important Notes for RAG Agent:**
353
+ - In **Legacy Mode**: RAG Agent tools are available immediately after server startup
354
+ - In **Alibaba Cloud Mode**: RAG Agent tools are listed at startup but only work after connecting to a Supabase instance using `connect_to_supabase_instance`
355
+ - All RAG Agent tools are prefixed with `rag_` (e.g., `rag_create_collection`, `rag_add_documents`, `rag_query`)
356
+ ```
357
+
161
358
  ### Claude for Desktop
162
359
 
163
360
  For Claude Desktop, you can add the following to your configuration: