360 Secure SkillHub
360 安全技能中心

huawei-cloud-rds-supabase

该技能通过 MCP 服务器管理华为云 RDS Supabase 数据面,支持部署 init.sql 迁移、只读查询、查看表结构与索引、RLS 策略与安全建议、认证用户管理及存储配置;强调事务回滚、写前确认、最小权限与查询后验证。

分类:开发
huaweicloudskill
huaweicloudskill
热度 2.91
最近更新 2026-12-02 18:44:31

安装

发给 Agent
帮我安装这个技能:npx secure-skills-cli add huaweicloudskill/huawei-cloud-rds-supabase
兼容性
通用兼容
联网要求
需要联网
数据出网
必须出网
Metadata
name
huawei-cloud-rds-supabase
description
华为云 RDS Supabase 数据面管理技能:经 mcp_huaweicloud_rds_supabase MCP 服务器操作运行在 RDS PostgreSQL 之上的全托管 Supabase 平台。当用户需要部署 init.sql 后端迁移(建表、GRANT、RLS、函数)、查询数据库结构与数据、管理登录用户、配置存储、核查 RLS 与安全建议(advisors)、排查连接与执行计划、或注册本 MCP 服务器时使用。触发词:init.sql 迁移、执行 SQL、只读查询、行级安全、安全建议、登录用户管理、存储配置、SQL 排查、MCP 服务器注册。English triggers: run init.sql migration, execute_sql deployment, read_only query, manage auth users, rls advisors security check, storage config, troubleshoot slow queries, install supabase mcp server.
license
MIT
tags
["huawei-cloud","rds","supabase","postgresql","mcp"]

Huawei Cloud RDS Supabase Data-Plane Operations

Overview

Huawei Cloud RDS Supabase is a fully-managed Supabase stack running on Huawei Cloud RDS for PostgreSQL. It delivers backend-as-a-service: the Kong gateway is the single entry point, PostgREST publishes database tables as REST APIs, GoTrue handles authentication, and Storage and Realtime are ready to use, so the application needs no backend service of its own.

In a full-stack web flow, this skill covers two stages. Instance onboarding: the RDS Supabase instance is created or selected by the flow; once it is ready, the gateway URL, anon key, and service-role key become available, and the MCP server is registered with them (full command and configuration in references/mcp-installation-guide.md — load it when the server is not yet registered or a connection fails). Backend development: the application's backend is defined as an init.sql migration script (DDL, GRANTS, and other initialization SQL) and deployed through execute_sql as database-layer definitions — table structures, grants, row-level security policies, functions — which the frontend consumes directly over the REST API.

The platform provides no management console for data-plane operations. The mcp_huaweicloud_rds_supabase MCP server is the management entry point, exposing schema inspection, SQL execution, auth user management, storage configuration, and security advisors as MCP tools for the AI assistant. Core design:

  • execute_sql executes each script as one transaction batch with automatic rollback; read_only=true restricts a call to read-only statements
  • SQL executes through the PostgREST RPC; user management goes through the GoTrue admin API (GoTrue handles password hashing and email confirmation — never write auth.users directly)
  • Safety controls: tools classified READ/WRITE; server-level read-only mode, confirmation rules, audit logging, automatic redaction of secret-like output values

The full chain: instance creation/selection → MCP server registration → AI assistant → MCP tools → service layer → PostgREST RPC / GoTrue admin API. No tool connects to the database directly; every request travels through the Kong gateway.

Typical use cases:

  1. Onboard an instance: after creation or selection, register the MCP server with the gateway URL and API keys (references/mcp-installation-guide.md) → verify with get_project_url and list_tables.
  2. Inspect current state: list_tables → list_table_columns → get_rls_status.
  3. Deploy backend definitions: generate init.sql (tables, grants, RLS policies, functions) → execute with execute_sql → verify by query; produce the companion cleanup.sql whenever init.sql is finalized.
  4. Security check: get_advisors + get_rls_status on externally exposed tables, then remediate and recheck.
  5. Data troubleshooting and user management: execute_sql with read_only=true for layer-by-layer queries; list/get/create/update/delete_auth_user for login users.

Routing boundary:

Task Owner
Instance provisioning, renewal, flavor changes, backup policy Cloud console — out of scope for this skill
MCP server registration (after instance creation/selection) references/mcp-installation-guide.md (installation sources in preference order, registration template, full guide)
public.migrations table Platform-internal object: do not read, write, or depend on it

Safety and Authority Boundaries

  • Read-only first. Investigation and query scenarios always call execute_sql with read_only=true; write statements are rejected at the database level. When only read access is needed, set HUAWEICLOUD_MCP_READ_ONLY=true to block every WRITE tool at the server level (Prerequisites, Notes).
  • Write confirmation. Destructive statements (DROP, TRUNCATE, ALTER) are confirmed per statement by a human; DROP ... CASCADE is forbidden. Before an irreversible user write operation, confirm the exact user_id or email with the user (Workflow step 2, Parameter Confirmation).
  • RLS coverage and least privilege. Every externally exposed table enables row-level security and defines at least one policy; only necessary privileges are granted to necessary roles (Workflow step 2).
  • Transactions and verification. A script executes as one batch in a single transaction and rolls back entirely on failure; whether a change took effect is judged only by the queried state, never by execution records (Workflow steps 3 and 5).
  • Platform-internal objects. public.migrations is not read, written, or depended upon (Overview routing boundary).
  • Auth users. Managed exclusively through the GoTrue admin API with the service-role key; GoTrue owns password hashing and email confirmation — never write auth.users directly (Core Commands).
  • Audit and redaction. Every tool call is audit-logged; secret-like values in output are redacted automatically (Notes).
  • EXPLAIN ANALYZE executes the statement. explain_query with analyze=true really executes the SQL — DML in the plan modifies data. Treat it as a write operation: per-statement human confirmation, exactly like execute_sql (Workflow step 2). Prefer analyze=false when investigating; the server read-only mode does not intercept this READ-class tool.

Prerequisites

  1. An RDS Supabase instance is created or selected, and three configuration items are available from the provisioning flow: HUAWEICLOUD_MCP_RDS_SUPABASE_URL (gateway URL, composed as http(s)://<rds_supabase_eip>:<rds_supabase_port> from the instance's EIP and port), HUAWEICLOUD_MCP_RDS_SUPABASE_ANON_KEY, and HUAWEICLOUD_MCP_RDS_SUPABASE_SERVICE_ROLE_KEY (required for SQL execution and user management). Register the MCP server with them — installation sources in preference order and registration template in references/mcp-installation-guide.md.
  2. When only read access is needed, set HUAWEICLOUD_MCP_READ_ONLY=true.

Workflow

Instance onboarding (MCP server registration)

  • Once, after the instance is created or selected: obtain the three configuration items above → write the registration template from references/mcp-installation-guide.md into the client's MCP configuration and reload → confirm that get_project_url returns the gateway URL and list_tables returns results. Onboarding is complete; proceed to the development workflows.

General flow

  • Query the current state first (list_tables, list_table_columns, get_rls_status), execute writes only afterwards, and re-query after every write to confirm the result.

Deploy backend definitions (init.sql, five steps)

execute_sql executes arbitrary SQL; deploying init.sql (DDL and other migration scripts) as backend definitions is its primary use.

init.sql → precheck → review → deploy → expose → verify
  • Step 1, precheck (current state): list_tables / list_indexes / list_table_columns — do the target tables and indexes already exist, and does the structure conflict? get_rls_status / list_rls_policies — RLS state and policies of existing tables. For existing objects, use repeatable forms (IF NOT EXISTS, CREATE OR REPLACE for functions and views) or rework the script as incremental changes.

  • Step 2, review — four mandatory checks before execution:

    1. Idempotency: the script can run multiple times — CREATE TABLE IF NOT EXISTS, CREATE OR REPLACE for functions and views, DROP POLICY IF EXISTS before CREATE POLICY, INSERT ... ON CONFLICT DO NOTHING.
    2. Destructive statements: DROP, TRUNCATE, ALTER require per-statement human confirmation; DROP ... CASCADE is forbidden.
    3. RLS coverage: every externally exposed table enables row-level security and defines at least one policy — enabled without a policy, queries return no rows; without RLS enabled, data is visible to every role with table privileges (get_advisors reports it).
    4. Least privilege: grant only necessary privileges to necessary roles (e.g. GRANT SELECT ON t TO anon); avoid over-granting.
  • Step 3, deploy (one single transaction batch): execute_sql (read_only=false, the default) executes the whole script as one batch — any statement failing inside the transaction rolls back the entire batch, so no partially applied state can remain. Split long scripts into multiple batches ordered by dependency (tables → indexes → policies → grants), each committed independently. Statements that cannot run inside a transaction (CREATE DATABASE, ALTER SYSTEM) fail the batch. In production, configure a confirmation rule for execute_sql (see the installation guide).

  • Step 4, expose (grants):

    GRANT SELECT ON public.<table> TO anon;    -- add INSERT/UPDATE as needed
    NOTIFY pgrst, 'reload schema';              -- PostgREST picks up the change immediately, no restart
    

    PostgREST exposes only granted tables: after the GRANT, GET /rest/v1/<table> (anon key) returns results; ungranted tables are not exposed. Row-level access is governed by the RLS policies.

  • Step 5, verify by query (the queried state is authoritative): list_tables / list_table_columns / list_constraints — the structure took effect; get_rls_status / list_rls_policies — the policies took effect; get_advisors (type=security) — no new issues; optionally GET /rest/v1/<table> returns 200. Do not treat execution records as proof of deployment success.

Cleanup script discipline: whenever init.sql is finalized, produce the companion cleanup script in the same pass (e.g. cleanup.sql, references/init-sql-guide.md section 7) — a reverse-order teardown (revoke grants and policies first, triggers and functions next, tables last) with IF EXISTS throughout, archived in pairs with init.sql. It serves later removal scenarios (application decommission, environment recycling), runs only on explicit user request, and never executes automatically with a deployment.

SQL troubleshooting

  • Call execute_sql with read_only=true for read-only investigation; the database layer rejects write statements. Investigate layer by layer, and execute a write only after the finding is confirmed.

Security check

  • get_advisors (security/performance) → remediate each issue per its remediation field → recheck with get_rls_status / list_rls_policies.

User management

  • list_auth_users → get/create/update/delete_auth_user (GoTrue admin API; GoTrue handles password hashing and email confirmation).

Core Commands

All operations run on the mcp_huaweicloud_rds_supabase MCP tool surface. SQL-class tools use the PostgREST RPC channel (the only SQL channel); auth user tools use the GoTrue admin API; nothing connects to the database directly.

Group Tools Notes
SQL execution execute_sql Executes arbitrary SQL; an init.sql batch runs as one single transaction and rolls back entirely on failure; cleanup.sql runs through the same channel on request. Parameters: sql, read_only (default false)
Schema list_tables, list_table_columns, list_indexes, list_constraints, list_foreign_keys, list_triggers, list_database_functions, get_function_definition, get_trigger_definition Tables, columns, indexes, constraints, foreign keys, triggers, function and trigger definitions
Security get_rls_status, list_rls_policies, get_advisors RLS status, policy details, security and performance advisors
Runtime get_database_connections, get_database_stats, explain_query Active connections, database and bgwriter statistics snapshots, execution plans. explain_query with analyze=true executes the statement for real — treat DML as a write (Safety and Authority Boundaries)
Extensions list_extensions, list_available_extensions Installed / installable extensions
Auth users list/get/create/update/delete_auth_user CRUD on login users (GoTrue admin API, service-role key)
Platform / storage / realtime get_storage_config, update_storage_config (WRITE), list_storage_buckets, list_storage_objects, list_realtime_publications, rebuild_hooks (WRITE), get_project_url, list_cron_jobs, get_cron_job_history, list_vector_indexes, get_index_stats, get_vector_index_stats Storage bucket and object catalogs, realtime publications, storage configuration, platform information, cron jobs, index statistics

Parameter Confirmation

Item Confirmation rule
execute_sql.sql (migration script) Must pass the four review checks (Workflow step 2); use idempotent forms; must not contain statements that cannot run inside a transaction
execute_sql.read_only Must be true for investigation; false (default) only when deploying backend definitions
GRANT objects and roles Least privilege; external tables and internal tables handled separately
User write operations (user_id / email) Irreversible — confirm the exact identifier with the user before execution
explain_query.analyze true executes the statement for real (DML modifies data) — treat as a write operation with per-statement confirmation; false (default) is read-only

Output Format

Dual output for every operation: the machine-readable JSON result from the tool plus a Markdown summary for the user. For deploying backend definitions, use the deployment report:

[Before deployment]
Target objects: <tables / functions / policies / grant list>
Precheck result: <existing objects and conflicts, or none>
Risk confirmation: <destructive statements / RLS coverage / grant scope>

[After deployment]
Execution result: <result rows for row-returning statements; a {success, rows_affected} envelope for DDL and non-RETURNING DML> (on failure: the error envelope and a full batch rollback)
Exposure: <GRANT details + /rest/v1/<table>>
Verification: <structure / RLS / advisors results / HTTP 200>

Investigation and routine writes use a brief format: target objects, operation executed, read/write level, and the post-execution query confirmation. Track multi-step work with ○ Pending, ⏳ In progress, and ✅ Completed. Never include key material in reports — redaction of secret-like values (shown as ***) is enforced in the tool layer and must not be bypassed.

Verification

Follow references/verification-method.md (load when validating a deployment): the per-step checklist for the five-step deployment, read-only mode verification (WRITE tools blocked under HUAWEICLOUD_MCP_READ_ONLY=true), and transaction rollback verification (a batch containing a deliberately failing statement leaves no partially applied state, confirmed by query afterwards). Check references/acceptance-criteria.md (load when accepting the skill or a delivery) before proposing a change.

Best Practices

  • Load references/init-sql-guide.md before writing or reviewing any init.sql — idempotent patterns, the RLS and GRANT checklists, and the cleanup script requirements.
  • Query first, write second, verify after; treat queried state as the only source of truth.
  • Split long scripts into multiple batches in dependency order — the Kong gateway times out at about 60 s.
  • Recheck with get_advisors after remediating; the remediation action itself is not the confirmation.
  • Set HUAWEICLOUD_MCP_AUDIT_FILE to persist the per-call JSONL audit log (always emitted to stderr otherwise).
  • In production, configure a confirmation rule for execute_sql via HUAWEICLOUD_MCP_GUARDRAILS_CONFIG (see the installation guide).

References

  • references/mcp-installation-guide.md — load when the MCP server is not yet registered or a connection fails (installation sources in preference order, client registration template, environment variables).
  • references/iam-policies.md — load when configuring credentials, deciding which key an operation needs, or handling a key-related error.
  • references/init-sql-guide.md — load before writing or reviewing init.sql.
  • references/related-tools.md — load when choosing tools or when a tool errors (tool groups, access channels, unified error format).
  • references/verification-method.md — load when validating a deployment.
  • references/acceptance-criteria.md — load when accepting the skill or a delivery.

Notes

  • Two independent layers of read-only enforcement: the execute_sql parameter read_only limits a single call to read-only statements (the gate also rejects data-modifying WITH and EXPLAIN ANALYZE), while HUAWEICLOUD_MCP_READ_ONLY=true blocks all WRITE tools at the server level.
  • RLS identity predicates: prefer auth.uid() (the platform helper is deployed on current instances); on instances without it, use (select current_setting('request.jwt.claims', true)::jsonb ->> 'sub')::uuid. Never reference request.jwt.claims bare — PostgreSQL parses it as a table reference and the statement fails with SQLSTATE 42P01.
  • Advisor security codes: 0013 RLS not enabled, 0007 policy exists but RLS disabled, 0008 RLS enabled without a policy.
  • public.migrations is a platform-internal object: do not read, write, or depend on it.
  • The Kong gateway times out at about 60 s; split long scripts into multiple batches.
  • Tool errors use the unified envelope {"error": {code, message, hint}} — act on the hint:
Code Meaning
MCP_CONFIG_ERROR service-role key not configured — the SQL and auth channels are unavailable
MCP_READ_ONLY server read-only mode blocked a WRITE tool
MCP_GUARDRAIL_BLOCKED a guardrail rule or protected list blocked the call
MCP_UNSUPPORTED_OPERATION the requested operation is not supported through its channel (for example, updating a role through update_auth_user)
SQLSTATE (e.g. 42P01, 22012) SQL execution error — message is SQL Error (<code>): <detail>; a failed batch rolls back entirely
  • Every tool call emits a JSONL audit event to stderr; set HUAWEICLOUD_MCP_AUDIT_FILE to persist it.
  • Output redaction (always on) masks credential-shaped values — Huawei Cloud AK patterns, 40-character tokens, PEM keys, Bearer — and sensitive keys in structured output; JWT-shaped values are not covered, so never echo keys or JWTs into reports.
  • Auth users are managed only through the GoTrue admin API — writing auth.users directly is forbidden.