@@ -81,7 +81,7 @@ pnpm build
8181 "command" : " node" ,
8282 "args" : [
8383 " /path/to/supabase-mcp/packages/mcp-server-supabase/dist/transports/stdio.js" ,
84- " --api-url" , " https://your-project. supabase.co " ,
84+ " --api-url" , " https://your-polardb- supabase-ip:port " ,
8585 " --service-role-key" , " your-service-role-key" ,
8686 " --anon-key" , " your-anon-key" ,
8787 " --project-ref" , " your-project-id" ,
@@ -99,7 +99,7 @@ pnpm build
9999
100100| 参数 | 环境变量 | 说明 | 必需 |
101101| ------| ----------| ------| ------|
102- | ` --api-url ` | ` SUPABASE_API_URL ` | Supabase 项目 API URL (如: https://xxx.supabase.co) | ✅ |
102+ | ` --api-url ` | ` SUPABASE_API_URL ` | Supabase 项目 API URL | ✅ |
103103| ` --service-role-key ` | ` SUPABASE_SERVICE_ROLE_KEY ` | Supabase 服务角色密钥 | ✅ |
104104| ` --anon-key ` | ` SUPABASE_ANON_KEY ` | Supabase 匿名密钥 | ❌ |
105105| ` --dashboard-username ` | ` SUPABASE_DASHBOARD_USERNAME ` | Supabase Dashboard 用户名(用于 Edge Functions) | ❌ |
@@ -110,13 +110,13 @@ pnpm build
110110
111111### 4. 获取配置信息
112112
113- #### 从 Supabase Dashboard 获取
113+ #### 从 PolarDB Supabase 实例详情页获取
114114
115- 1 . ** API URL** : 在 Dashboard 的项目设置 → General → Configuration → API URL
116- 2 . ** Service Role Key** : 在 Dashboard 的项目设置 → API → Project API keys → service_role 密钥
117- 3 . ** Anon Key** : 在 Dashboard 的项目设置 → API → Project API keys → anon public 密钥
118- 5 . ** Dashboard 用户名** : 在 Dashboard 的项目设置 → Database → Connection info → Username
119- 6 . ** Dashboard 密码** : 在 Dashboard 的项目设置 → Database → Connection info → Password
115+ 1 . ** API URL** : 详情页 → 拓扑图 → 公网地址
116+ 2 . ** Service Role Key** : 详情页 → 配置 → secret.jwt.serviceKey
117+ 3 . ** Anon Key** : 详情页 → 配置 → secret.jwt.anonKey
118+ 5 . ** Dashboard 用户名** : 详情页 → 配置 → secret.dashboard.username
119+ 6 . ** Dashboard 密码** : 详情页 → 配置 → secret.dashboard.password
120120
121121
122122
@@ -157,318 +157,3 @@ pnpm build
1571573. 验证权限设置
158158```
159159
160- ## 📝 使用示例
161-
162- ### 1. 数据库操作工具
163-
164- #### ` list_tables ` - 列出数据库表
165-
166- ``` typescript
167- // 列出 public schema 中的所有表
168- const result = await client .callTool ({
169- name: ' polardb-supabase_list_tables' ,
170- arguments: {
171- schema: ' public' // 可选,默认为 'public'
172- }
173- });
174-
175- // 返回值示例
176- {
177- " tables" : [
178- {
179- " name" : " users" ,
180- " schema" : " public" ,
181- " type" : " table"
182- },
183- {
184- " name" : " posts" ,
185- " schema" : " public" ,
186- " type" : " table"
187- }
188- ]
189- }
190-
191- // 列出其他 schema 的表
192- const result = await client .callTool ({
193- name: ' polardb-supabase_list_tables' ,
194- arguments: {
195- schema: ' auth' // 列出 auth schema 的表
196- }
197- });
198- ```
199-
200- #### ` execute_sql ` - 执行 SQL 查询
201-
202- ``` typescript
203- // 执行只读查询
204- const result = await client .callTool ({
205- name: ' polardb-supabase_execute_sql' ,
206- arguments: {
207- query: ' SELECT * FROM users WHERE active = true LIMIT 10' ,
208- read_only: true // 可选,默认为 true
209- }
210- });
211-
212- // 返回值示例
213- {
214- " data" : [
215- {
216- " id" : 1 ,
217- 218- " active" : true ,
219- " created_at" : " 2024-01-01T00:00:00Z"
220- }
221- ],
222- " count" : 1
223- }
224-
225- // 执行写入操作(需要关闭只读模式)
226- const result = await client .callTool ({
227- name: ' polardb-supabase_execute_sql' ,
228- arguments: {
229- query: ' INSERT INTO users (email, name) VALUES ($1, $2)' ,
230- read_only: false ,
231- params: [
' [email protected] ' ,
' New User' ]
232- }
233- });
234-
235- // 复杂查询示例
236- const result = await client .callTool ({
237- name: ' polardb-supabase_execute_sql' ,
238- arguments: {
239- query: `
240- SELECT
241- u.name,
242- COUNT(p.id) as post_count,
243- AVG(p.rating) as avg_rating
244- FROM users u
245- LEFT JOIN posts p ON u.id = p.user_id
246- WHERE u.created_at > $1
247- GROUP BY u.id, u.name
248- HAVING COUNT(p.id) > 0
249- ORDER BY avg_rating DESC
250- ` ,
251- params: [' 2024-01-01' ],
252- read_only: true
253- }
254- });
255- ```
256-
257- ### 2. 项目信息工具
258-
259- #### ` get_anon_key ` - 获取匿名密钥
260-
261- ``` typescript
262- // 获取项目的匿名密钥
263- const result = await client .callTool ({
264- name: ' polardb-supabase_get_anon_key' ,
265- arguments: {}
266- });
267-
268- // 返回值示例
269- {
270- " anon_key" : " eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6ImRlZmF1bHQiLCJyb2xlIjoiYW5vbiIsImlhdCI6MTczNDc0OTY0NSwiZXhwIjoyMDUwMzI1NjQ1fQ.example"
271- }
272- ```
273-
274- #### ` get_project_url ` - 获取项目 URL
275-
276- ``` typescript
277- // 获取项目 URL
278- const result = await client .callTool ({
279- name: ' polardb-supabase_get_project_url' ,
280- arguments: {}
281- });
282-
283- // 返回值示例
284- {
285- " project_url" : " http://8.145.192.124:8080"
286- }
287- ```
288-
289- ### 3. 最佳实践工具
290-
291- #### ` get_best_practices ` - 获取开发最佳实践
292-
293- ``` typescript
294- // 获取所有 Supabase 最佳实践
295- const result = await client .callTool ({
296- name: ' polardb-supabase_get_best_practices' ,
297- arguments: {}
298- });
299-
300- // 返回值示例
301- {
302- " content" : " # Supabase Development Best Practices\n\n > Total practices: 8\n\n ## Bootstrap Next.js app with Supabase Auth\n\n **Create a Next.js app with Supabase authentication using TypeScript**\n\n ## Writing Supabase Edge Functions\n\n **Guidelines for developing Supabase Edge Functions**\n\n ..." ,
303- " count" : 8 ,
304- " usage" : " Copy the content above and paste it into .cursor/rules or .qoder/rules"
305- }
306- ```
307-
308- ### 4. 存储管理工具
309-
310- #### ` list_storage_buckets ` - 列出存储桶
311-
312- ``` typescript
313- // 列出所有存储桶
314- const result = await client .callTool ({
315- name: ' polardb-supabase_list_storage_buckets' ,
316- arguments: {}
317- });
318-
319- // 返回值示例
320- {
321- " buckets" : [
322- {
323- " id" : " avatars" ,
324- " name" : " avatars" ,
325- " owner" : " 00000000-0000-0000-0000-000000000000" ,
326- " created_at" : " 2024-01-01T00:00:00Z" ,
327- " updated_at" : " 2024-01-01T00:00:00Z" ,
328- " public" : false
329- },
330- {
331- " id" : " public" ,
332- " name" : " public" ,
333- " owner" : " 00000000-0000-0000-0000-000000000000" ,
334- " created_at" : " 2024-01-01T00:00:00Z" ,
335- " updated_at" : " 2024-01-01T00:00:00Z" ,
336- " public" : true
337- }
338- ]
339- }
340- ```
341-
342- ### 5. Edge Functions 管理工具
343-
344- #### ` list_edge_functions ` - 列出 Edge Functions
345-
346- ``` typescript
347- // 列出所有 Edge Functions
348- const result = await client .callTool ({
349- name: ' polardb-supabase_list_edge_functions' ,
350- arguments: {}
351- });
352-
353- // 返回值示例
354- {
355- " functions" : [
356- {
357- " id" : " rapid-action" ,
358- " name" : " rapid-action" ,
359- " slug" : " rapid-action" ,
360- " version" : " 1.0.0" ,
361- " status" : " ACTIVE" ,
362- " created_at" : " 2024-01-01T00:00:00Z" ,
363- " updated_at" : " 2024-01-01T00:00:00Z"
364- },
365- {
366- " id" : " hello-world" ,
367- " name" : " hello-world" ,
368- " slug" : " hello-world" ,
369- " version" : " 1.0.0" ,
370- " status" : " ACTIVE" ,
371- " created_at" : " 2024-01-01T00:00:00Z" ,
372- " updated_at" : " 2024-01-01T00:00:00Z"
373- }
374- ]
375- }
376- ```
377-
378- #### ` get_edge_function ` - 获取 Edge Function 详情
379-
380- ``` typescript
381- // 获取特定 Edge Function 的详细信息
382- const result = await client .callTool ({
383- name: ' polardb-supabase_get_edge_function' ,
384- arguments: {
385- function_name: ' rapid-action'
386- }
387- });
388-
389- // 返回值示例
390- {
391- " function" : {
392- " id" : " rapid-action" ,
393- " name" : " rapid-action" ,
394- " slug" : " rapid-action" ,
395- " version" : " 1.0.0" ,
396- " status" : " ACTIVE" ,
397- " created_at" : " 2024-01-01T00:00:00Z" ,
398- " updated_at" : " 2024-01-01T00:00:00Z" ,
399- " import_map" : {
400- " imports" : {
401- " @supabase/supabase-js" : " https://esm.sh/@supabase/supabase-js@2"
402- }
403- },
404- " verify_jwt" : true
405- }
406- }
407- ```
408-
409- #### ` deploy_edge_function ` - 部署 Edge Function
410-
411- ``` typescript
412- // 部署 Edge Function
413- const result = await client .callTool ({
414- name: ' polardb-supabase_deploy_edge_function' ,
415- arguments: {
416- function_name: ' hello-world' ,
417- code: `
418- import { serve } from "https://deno.land/[email protected] /http/server.ts" 419-
420- serve(async (req) => {
421- const { name } = await req.json()
422- const data = {
423- message: \` Hello \$ {name}!\` ,
424- }
425-
426- return new Response(
427- JSON.stringify(data),
428- { headers: { "Content-Type": "application/json" } },
429- )
430- })
431- ` ,
432- import_map: {
433- imports: {
434- " @supabase/supabase-js" : " https://esm.sh/@supabase/supabase-js@2"
435- }
436- },
437- verify_jwt: true
438- }
439- });
440-
441- // 返回值示例
442- {
443- " success" : true ,
444- " message" : " Function 'hello-world' deployed successfully" ,
445- " function" : {
446- " id" : " hello-world" ,
447- " name" : " hello-world" ,
448- " slug" : " hello-world" ,
449- " version" : " 1.0.1" ,
450- " status" : " ACTIVE" ,
451- " created_at" : " 2024-01-01T00:00:00Z" ,
452- " updated_at" : " 2024-01-02T00:00:00Z"
453- }
454- }
455-
456- // 简单部署(使用默认配置)
457- const result = await client .callTool ({
458- name: ' polardb-supabase_deploy_edge_function' ,
459- arguments: {
460- function_name: ' simple-function' ,
461- code: `
462- import { serve } from "https://deno.land/[email protected] /http/server.ts" 463-
464- serve(async (req) => {
465- return new Response(
466- JSON.stringify({ message: "Hello from Edge Function!" }),
467- { headers: { "Content-Type": "application/json" } }
468- )
469- })
470- `
471- }
472- });
473- ```
474-
0 commit comments