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

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 (2) hide show
  1. package/README.md +303 -400
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -1,400 +1,303 @@
1
- # Self-Hosted Supabase MCP Server
2
-
3
- MCP (Model Context Protocol) server for self-hosted Supabase instances. Allows AI assistants like Claude to interact with your self-hosted Supabase database.
4
-
5
- Originally developed by [HenkDz](https://github.com/HenkDz), now maintained by lemontreen.
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
-
21
- ## Features
22
-
23
- This server exposes a rich set of tools for interacting with your self-hosted Supabase instance:
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.
30
- * **Database Schema**
31
- * `list_tables`: Lists all tables in the `public` schema.
32
- * `list_extensions`: Lists installed PostgreSQL extensions.
33
- * `get_database_connections`: Retrieves current database connection information.
34
- * `get_database_stats`: Gets database statistics (e.g., table sizes).
35
- * **Migrations & SQL**
36
- * `list_migrations`: Lists applied migrations from the `supabase_migrations` schema.
37
- * `apply_migration`: Applies a new SQL migration via RPC.
38
- * `execute_sql`: Executes arbitrary SQL (Requires helper function in DB or direct DB access).
39
- * `generate_typescript_types`: Generates TypeScript types from the database schema.
40
- * **Project Configuration**
41
- * `get_project_url`: Returns the configured Supabase project URL.
42
- * `get_anon_key`: Returns the configured Supabase Anon Key.
43
- * `get_service_key`: Returns the configured Supabase Service Role Key (if provided).
44
- * `verify_jwt_secret`: Verifies the provided JWT secret against the database (Requires direct DB access).
45
- * **Infrastructure**
46
- * `rebuild_hooks`: Attempts to restart the `pg_net` worker (if used).
47
- * **Auth User Management**
48
- * `list_auth_users`: Lists users from `auth.users`.
49
- * `get_auth_user`: Retrieves details for a specific user.
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.
53
- * **Storage Insights**
54
- * `list_storage_buckets`: Lists all storage buckets.
55
- * `list_storage_objects`: Lists objects within a specific bucket.
56
- * **Realtime Inspection**
57
- * `list_realtime_publications`: Lists PostgreSQL publications (often `supabase_realtime`).
58
-
59
- *(Note: `get_logs` was initially planned but skipped due to implementation complexities in a self-hosted environment).*
60
-
61
- ## How It Works
62
-
63
- This MCP server works with AI assistant tools like Claude Desktop, Cursor, and other MCP-compatible applications. Once configured, these AI assistants can automatically use the tools provided by this server to interact with your self-hosted Supabase instance.
64
-
65
- For example, when you ask an AI assistant "List all tables in my database", it will:
66
- 1. Recognize it needs to use a database tool
67
- 2. Call the `list_tables` tool from this server
68
- 3. Execute the tool against your Supabase instance
69
- 4. Present the results in a human-readable format
70
-
71
- ## Setup and Installation
72
-
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)
160
-
161
- The easiest way to use this server is via npx, which requires no installation:
162
-
163
- ```bash
164
- npx @aliyun-rds/supabase-mcp-server --url http://localhost:8000 --anon-key YOUR_ANON_KEY
165
- ```
166
-
167
- ### Method 2: Installing via Smithery
168
-
169
- To install Self-Hosted Supabase MCP Server for Claude Desktop automatically via [Smithery](https://smithery.ai/server/@HenkDz/selfhosted-supabase-mcp):
170
-
171
- ```bash
172
- npx -y @smithery/cli install @HenkDz/selfhosted-supabase-mcp --client claude
173
- ```
174
-
175
- ### Method 3: Global Installation
176
-
177
- Install the package globally:
178
-
179
- ```bash
180
- npm install -g @aliyun-rds/supabase-mcp-server
181
- supabase-mcp --url http://localhost:8000 --anon-key YOUR_ANON_KEY
182
- ```
183
-
184
- ### Method 4: Local Installation and Build
185
-
186
- If you want to build from source:
187
-
188
- #### Prerequisites
189
-
190
- * Node.js (Version 18.x or later recommended)
191
- * npm (usually included with Node.js)
192
- * Access to your self-hosted Supabase instance (URL, keys, potentially direct DB connection string).
193
-
194
- #### Steps
195
-
196
- 1. **Clone the repository:**
197
- ```bash
198
- git clone <repository-url>
199
- cd selfhosted-supabase-mcp
200
- ```
201
- 2. **Install dependencies:**
202
- ```bash
203
- npm install
204
- ```
205
- 3. **Build the project:**
206
- ```bash
207
- npm run build
208
- ```
209
- This compiles the TypeScript code to JavaScript in the `dist` directory.
210
-
211
- ## Configuration
212
-
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.
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
-
225
- **Required:**
226
-
227
- * `--url <url>` or `SUPABASE_URL=<url>`: The main HTTP URL of your Supabase project (e.g., `http://localhost:8000`).
228
- * `--anon-key <key>` or `SUPABASE_ANON_KEY=<key>`: Your Supabase project's anonymous key.
229
-
230
- **Optional (but Recommended/Required for certain tools):**
231
-
232
- * `--service-key <key>` or `SUPABASE_SERVICE_ROLE_KEY=<key>`: Your Supabase project's service role key. Needed for operations requiring elevated privileges, like attempting to automatically create the `execute_sql` helper function if it doesn't exist.
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.).
234
- * `--jwt-secret <secret>` or `SUPABASE_AUTH_JWT_SECRET=<secret>`: Your Supabase project's JWT secret. Needed for tools like `verify_jwt_secret`.
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
274
-
275
- ### Important Notes:
276
-
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.
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
283
-
284
- ## Using with AI Assistant Tools
285
-
286
- ### Cursor
287
-
288
- 1. Create or open the file `.cursor/mcp.json` in your project root.
289
- 2. Add the following configuration:
290
-
291
- ```json
292
- {
293
- "mcpServers": {
294
- "selfhosted-supabase": {
295
- "command": "npx",
296
- "args": [
297
- "@aliyun-rds/supabase-mcp-server",
298
- "--url",
299
- "<your-supabase-url>", // e.g., "http://localhost:8000"
300
- "--anon-key",
301
- "<your-anon-key>",
302
- // Optional - Add these if needed by the tools you use
303
- "--service-key",
304
- "<your-service-key>",
305
- "--db-url",
306
- "<your-db-url>", // e.g., "postgresql://postgres:password@host:port/postgres"
307
- "--jwt-secret",
308
- "<your-jwt-secret>",
309
- // Optional - Whitelist specific tools
310
- "--tools-config",
311
- "<path-to-tools-config.json>",
312
- // Optional - Enable RAG Agent integration
313
- "--enable-rag-agent"
314
- ]
315
- }
316
- }
317
- }
318
- ```
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
-
358
- ### Claude for Desktop
359
-
360
- For Claude Desktop, you can add the following to your configuration:
361
-
362
- 1. Open Claude Desktop Settings
363
- 2. Go to "Developer" and enable "Custom MCP Servers"
364
- 3. Add a new server with the following configuration:
365
-
366
- ```json
367
- {
368
- "name": "Self-Hosted Supabase",
369
- "command": "npx",
370
- "args": [
371
- "@aliyun-rds/supabase-mcp-server",
372
- "--url",
373
- "http://localhost:8000",
374
- "--anon-key",
375
- "YOUR_ANON_KEY_HERE"
376
- ]
377
- }
378
- ```
379
-
380
- ### Other MCP-Compatible Tools
381
-
382
- Most MCP-compatible tools follow similar configuration patterns. The general format is:
383
- - Command: `npx`
384
- - Arguments: `[@aliyun-rds/supabase-mcp-server, --url, YOUR_URL, --anon-key, YOUR_ANON_KEY, ...]`
385
-
386
- ## Development
387
-
388
- To develop and contribute to this project:
389
-
390
- 1. Clone the repository
391
- 2. Run `npm install`
392
- 3. Make your changes
393
- 4. Run `npm run build` to compile
394
- 5. Test with `node dist/index.js` or directly with an MCP client
395
-
396
- ## License
397
-
398
- This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
399
-
400
- Originally developed by [HenkDz](https://github.com/HenkDz), now maintained by lemontreen.
1
+ # Aliyun RDS Supabase MCP Server
2
+
3
+ MCP (Model Context Protocol) server for Supabase instances running on Aliyun RDS. Enables AI assistants like Claude to interact with your Supabase instance hosted on Aliyun cloud infrastructure.
4
+
5
+ Adapted from the original self-hosted version by [HenkDz](https://github.com/HenkDz), optimized for Aliyun RDS deployment.
6
+
7
+ ## Alibaba Cloud Operation
8
+
9
+ This server is purpose-built for Supabase instances that run on Aliyun RDS AI. Key capabilities:
10
+
11
+ - Automatically fetches Supabase credentials from Alibaba Cloud OpenAPI
12
+ - Only requires Alibaba Cloud AccessKey (AK) and SecretKey (SK)
13
+ - Supports multiple Supabase instances with interactive selection
14
+ - No need to manually configure `anon-key`, `service-key`, or `jwt-secret`
15
+
16
+ ## Features
17
+
18
+ This server exposes a rich set of tools for interacting with your Supabase instances running on Aliyun RDS:
19
+
20
+ * **Alibaba Cloud Management** (Alibaba Cloud Mode only)
21
+ * `list_aliyun_supabase_instances`: Lists all Supabase instances from Alibaba Cloud RDS AI.
22
+ * `connect_to_supabase_instance`: Connects to a specific Supabase instance by name.
23
+ * `get_current_supabase_instance`: Shows the currently connected instance.
24
+ * `disconnect_supabase_instance`: Disconnects from the current instance.
25
+ * **Database Schema**
26
+ * `list_tables`: Lists all tables in the `public` schema.
27
+ * `list_extensions`: Lists installed PostgreSQL extensions.
28
+ * `get_database_connections`: Retrieves current database connection information.
29
+ * `get_database_stats`: Gets database statistics (e.g., table sizes).
30
+ * **Migrations & SQL**
31
+ * `list_migrations`: Lists applied migrations from the `supabase_migrations` schema.
32
+ * `apply_migration`: Applies a new SQL migration via RPC.
33
+ * `execute_sql`: Executes arbitrary SQL (Requires helper function in DB or direct DB access).
34
+ * `install_execute_sql_function`: Installs the `execute_sql` RPC function into the database.
35
+ * `generate_typescript_types`: Generates TypeScript types from the database schema.
36
+ * **Project Configuration**
37
+ * `get_project_url`: Returns the configured Supabase project URL.
38
+ * `get_anon_key`: Returns the configured Supabase Anon Key.
39
+ * `get_service_key`: Returns the configured Supabase Service Role Key (if provided).
40
+ * `verify_jwt_secret`: Verifies the provided JWT secret against the database (Requires direct DB access).
41
+ * **Infrastructure**
42
+ * `rebuild_hooks`: Attempts to restart the `pg_net` worker (if used).
43
+ * **Auth User Management**
44
+ * `list_auth_users`: Lists users from `auth.users`.
45
+ * `get_auth_user`: Retrieves details for a specific user.
46
+ * `create_auth_user`: Creates a new user using Supabase Admin API.
47
+ * `delete_auth_user`: Deletes a user using Supabase Admin API.
48
+ * `update_auth_user`: Updates user details using Supabase Admin API.
49
+ * **Storage Insights**
50
+ * `list_storage_buckets`: Lists all storage buckets.
51
+ * `list_storage_objects`: Lists objects within a specific bucket.
52
+ * **Realtime Inspection**
53
+ * `list_realtime_publications`: Lists PostgreSQL publications (often `supabase_realtime`).
54
+ * **Documentation**
55
+ * `search_docs`: Searches Supabase official documentation using GraphQL queries.
56
+ * **RAG Agent Tools** (when `--enable-rag-agent` is set)
57
+ * All RAG Agent tools are dynamically loaded and prefixed with `rag_` (e.g., `rag_check_health`, `rag_list_datasets`, `rag_get_dataset`, `rag_query_dataset`, `rag_query_multi_datasets`).
58
+ * These tools provide Retrieval-Augmented Generation capabilities for semantic search and document management.
59
+ * Available after connecting to a Supabase instance in Alibaba Cloud Mode.
60
+
61
+ *(Note: `get_logs` was initially planned but skipped due to implementation complexities observed in the upstream self-hosted environment).*
62
+
63
+ ## How It Works
64
+
65
+ This MCP server works with AI assistant tools like Claude Desktop, Cursor, and other MCP-compatible applications. Once configured, these AI assistants can automatically use the tools provided by this server to interact with your Aliyun RDS-hosted Supabase instance.
66
+
67
+ For example, when you ask an AI assistant "List all tables in my database", it will:
68
+ 1. Recognize it needs to use a database tool
69
+ 2. Call the `list_tables` tool from this server
70
+ 3. Execute the tool against your Supabase instance
71
+ 4. Present the results in a human-readable format
72
+
73
+ ## Setup and Installation
74
+
75
+ ### Alibaba Cloud Mode Setup
76
+
77
+ #### Quick Start with npx
78
+
79
+ ```bash
80
+ npx @aliyun-rds/supabase-mcp-server \
81
+ --aliyun-ak YOUR_ACCESS_KEY_ID \
82
+ --aliyun-sk YOUR_ACCESS_KEY_SECRET \
83
+ --aliyun-region cn-hangzhou
84
+ ```
85
+
86
+ **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:
87
+ - `cn-hangzhou` (China East 1)
88
+ - `cn-beijing` (China North 2)
89
+ - `cn-shanghai` (China East 2)
90
+ - `cn-shenzhen` (China South 1)
91
+
92
+ The CLI flag defines the default region for automatic discovery. When you need to inspect instances in other regions, call the `list_aliyun_supabase_instances` tool and provide its optional `region_id` argument (e.g., `cn-beijing`) to override the default for that request.
93
+
94
+ #### Configuration for Claude Desktop
95
+
96
+ Add to your `claude_desktop_config.json`:
97
+
98
+ ```json
99
+ {
100
+ "mcpServers": {
101
+ "aliyun-supabase": {
102
+ "command": "npx",
103
+ "args": [
104
+ "@aliyun-rds/supabase-mcp-server",
105
+ "--aliyun-ak", "YOUR_ACCESS_KEY_ID",
106
+ "--aliyun-sk", "YOUR_ACCESS_KEY_SECRET",
107
+ "--aliyun-region", "cn-hangzhou"
108
+ ]
109
+ }
110
+ }
111
+ }
112
+ ```
113
+
114
+ **With RAG Agent integration:**
115
+
116
+ ```json
117
+ {
118
+ "mcpServers": {
119
+ "aliyun-supabase": {
120
+ "command": "npx",
121
+ "args": [
122
+ "@aliyun-rds/supabase-mcp-server",
123
+ "--aliyun-ak", "YOUR_ACCESS_KEY_ID",
124
+ "--aliyun-sk", "YOUR_ACCESS_KEY_SECRET",
125
+ "--aliyun-region", "cn-hangzhou",
126
+ "--enable-rag-agent"
127
+ ]
128
+ }
129
+ }
130
+ }
131
+ ```
132
+
133
+ Or use environment variables:
134
+
135
+ ```json
136
+ {
137
+ "mcpServers": {
138
+ "aliyun-supabase": {
139
+ "command": "npx",
140
+ "args": [
141
+ "@aliyun-rds/supabase-mcp-server",
142
+ "--enable-rag-agent"
143
+ ],
144
+ "env": {
145
+ "ALIYUN_ACCESS_KEY_ID": "YOUR_ACCESS_KEY_ID",
146
+ "ALIYUN_ACCESS_KEY_SECRET": "YOUR_ACCESS_KEY_SECRET",
147
+ "ALIYUN_REGION": "cn-hangzhou"
148
+ }
149
+ }
150
+ }
151
+ }
152
+ ```
153
+
154
+ #### Usage Workflow
155
+
156
+ 1. **List instances**: Use `list_aliyun_supabase_instances` to see all your Supabase instances
157
+ 2. **Connect**: Use `connect_to_supabase_instance` with the instance name
158
+ 3. **Use tools**: Now you can use all Supabase tools (list_tables, execute_sql, etc.)
159
+ 4. **Disconnect** (optional): Use `disconnect_supabase_instance` to switch instances
160
+
161
+ ### Additional Installation Options
162
+
163
+ #### Install via Smithery
164
+
165
+ Install the Aliyun RDS Supabase MCP Server for Claude Desktop automatically via [Smithery](https://smithery.ai/server/@HenkDz/selfhosted-supabase-mcp):
166
+
167
+ ```bash
168
+ npx -y @smithery/cli install @HenkDz/selfhosted-supabase-mcp --client claude
169
+ ```
170
+
171
+ #### Global Installation
172
+
173
+ ```bash
174
+ npm install -g @aliyun-rds/supabase-mcp-server
175
+ supabase-mcp \
176
+ --aliyun-ak YOUR_ACCESS_KEY_ID \
177
+ --aliyun-sk YOUR_ACCESS_KEY_SECRET \
178
+ --aliyun-region cn-hangzhou
179
+ ```
180
+
181
+ ## Configuration
182
+
183
+ The server now relies exclusively on Alibaba Cloud credentials. Provide them via command-line arguments or environment variables (CLI arguments take precedence). Once authenticated, the MCP server automatically retrieves the Supabase URL, anon key, service key, database connection string, and JWT secret for the selected Aliyun RDS instance—no manual entry is needed.
184
+
185
+ ### Required Parameters
186
+
187
+ * `--aliyun-ak <key>` or `ALIYUN_ACCESS_KEY_ID=<key>`: Alibaba Cloud Access Key ID.
188
+ * `--aliyun-sk <secret>` or `ALIYUN_ACCESS_KEY_SECRET=<secret>`: Alibaba Cloud Access Key Secret.
189
+ * `--aliyun-region <region>` or `ALIYUN_REGION=<region>`: **Mandatory** region where your Supabase instances live (e.g., `cn-hangzhou`, `cn-beijing`). Without this, the OpenAPI call cannot list instances. This value becomes the default region, but tools like `list_aliyun_supabase_instances` accept a `region_id` parameter so you can query other regions on demand.
190
+
191
+ ### Optional Parameters
192
+
193
+ * `--tools-config <path>`: JSON file specifying which tools to enable (whitelist). Format: `{"enabledTools": ["tool_name_1", "tool_name_2"]}`.
194
+ * `--enable-rag-agent` or `ENABLE_RAG_AGENT=true`: Enable RAG Agent MCP integration. When enabled, the server resolves the Supabase host/port from the selected instance and uses the retrieved anon key as the API key for rag-agent; no manual `--url` or `--anon-key` flags are needed.
195
+
196
+ Legacy CLI options (`--url`, `--anon-key`, `--service-key`, `--db-url`, `--jwt-secret`) have been removed from the user-facing surface because Aliyun RDS now supplies those details automatically.
197
+
198
+ ### RAG Agent Integration
199
+
200
+ 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.
201
+
202
+ **How it works:**
203
+ - When `--enable-rag-agent` is set, the server automatically connects to a rag-agent MCP server after you select an Aliyun RDS Supabase instance.
204
+ - The Supabase host/port is derived from the instance metadata returned by Aliyun OpenAPI.
205
+ - The anon key retrieved for the connected instance is reused as the API key for rag-agent (no manual secret sharing required).
206
+ - All rag-agent tools are prefixed with `rag_` to avoid naming conflicts (e.g., `rag_create_collection`, `rag_add_documents`, `rag_query`).
207
+
208
+ **Example configuration:**
209
+ ```bash
210
+ npx @aliyun-rds/supabase-mcp-server \
211
+ --aliyun-ak YOUR_ACCESS_KEY_ID \
212
+ --aliyun-sk YOUR_ACCESS_KEY_SECRET \
213
+ --aliyun-region cn-hangzhou \
214
+ --enable-rag-agent
215
+ ```
216
+
217
+ **Requirements:**
218
+ - `uvx` must be installed on your system
219
+ - `rag-agent-mcp` package must be available via `uvx`
220
+ - The rag-agent service must be reachable at the host/port reported by your Supabase instance
221
+
222
+ **Behavior Notes:**
223
+ - RAG Agent tools are advertised at startup but become fully functional only after running `connect_to_supabase_instance`.
224
+ - Because the host/port comes from Supabase metadata, ensure your Aliyun credentials can fetch instance connection details.
225
+
226
+ ### Important Notes:
227
+
228
+ * **`execute_sql` Helper Function:** Many tools rely on a `public.execute_sql` function for secure SQL execution via RPC. After you connect to an Aliyun RDS instance, the server checks for this function and—if your AK/SK grants the required privileges—automatically creates it and assigns permissions when missing.
229
+ * **Direct Database Access:** Tools that touch privileged schemas (`auth`, `storage`) or `pg_catalog` still require direct database connectivity. The connection string is pulled from Aliyun; ensure your credentials can retrieve it or those tools will be unavailable.
230
+ * **Database URL Special Characters:** When Aliyun returns database URLs containing characters like `#` or `$`, the server automatically URL-encodes them (`#` `%23`, `$` → `%24`). The `@` symbol remains unescaped because it separates credentials from the hostname.
231
+
232
+ ## Using with AI Assistant Tools
233
+
234
+ ### Cursor
235
+
236
+ 1. Create or open the file `.cursor/mcp.json` in your project root.
237
+ 2. Add the following configuration:
238
+
239
+ ```json
240
+ {
241
+ "mcpServers": {
242
+ "aliyun-supabase": {
243
+ "command": "npx",
244
+ "args": [
245
+ "@aliyun-rds/supabase-mcp-server",
246
+ "--aliyun-ak",
247
+ "<your-access-key-id>",
248
+ "--aliyun-sk",
249
+ "<your-access-key-secret>",
250
+ "--aliyun-region",
251
+ "cn-hangzhou",
252
+ "--enable-rag-agent"
253
+ ],
254
+ "env": {
255
+ // Optional: whitelist tools or toggle features
256
+ "TOOLS_CONFIG": "<path-to-tools-config.json>",
257
+ "ENABLE_RAG_AGENT": "true"
258
+ }
259
+ }
260
+ }
261
+ }
262
+ ```
263
+
264
+ **Important Notes for RAG Agent:**
265
+ - RAG Agent tools stay inactive until you call `connect_to_supabase_instance` and select an Aliyun RDS Supabase project.
266
+ - Switching instances automatically re-initializes the rag-agent connection with the new host/port.
267
+ - All RAG Agent tools are prefixed with `rag_` (e.g., `rag_create_collection`, `rag_add_documents`, `rag_query`).
268
+
269
+ ### Claude for Desktop
270
+
271
+ For Claude Desktop, you can add the following to your configuration:
272
+
273
+ 1. Open Claude Desktop Settings
274
+ 2. Go to "Developer" and enable "Custom MCP Servers"
275
+ 3. Add a new server with the following configuration:
276
+
277
+ ```json
278
+ {
279
+ "name": "Aliyun Supabase",
280
+ "command": "npx",
281
+ "args": [
282
+ "@aliyun-rds/supabase-mcp-server",
283
+ "--aliyun-ak",
284
+ "YOUR_ACCESS_KEY_ID",
285
+ "--aliyun-sk",
286
+ "YOUR_ACCESS_KEY_SECRET",
287
+ "--aliyun-region",
288
+ "cn-hangzhou"
289
+ ]
290
+ }
291
+ ```
292
+
293
+ ### Other MCP-Compatible Tools
294
+
295
+ Most MCP-compatible tools follow similar configuration patterns. The general format is:
296
+ - Command: `npx`
297
+ - Arguments: `[@aliyun-rds/supabase-mcp-server, --aliyun-ak, YOUR_ACCESS_KEY_ID, --aliyun-sk, YOUR_ACCESS_KEY_SECRET, --aliyun-region, YOUR_REGION, ...]`
298
+
299
+ ## License
300
+
301
+ This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
302
+
303
+ Originally developed by [HenkDz](https://github.com/HenkDz), now maintained by Aliyun RDS.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aliyun-rds/supabase-mcp-server",
3
- "version": "1.0.4",
3
+ "version": "1.0.5",
4
4
  "description": "MCP (Model Context Protocol) server for self-hosted Supabase instances. Allows AI assistants to interact with your self-hosted Supabase database.",
5
5
  "main": "dist/index.js",
6
6
  "bin": {