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_sqlexecutes each script as one transaction batch with automatic rollback;read_only=truerestricts 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.usersdirectly) - 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:
- 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_urlandlist_tables. - Inspect current state:
list_tables→list_table_columns→get_rls_status. - 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. - Security check:
get_advisors+get_rls_statuson externally exposed tables, then remediate and recheck. - Data troubleshooting and user management:
execute_sqlwithread_only=truefor layer-by-layer queries;list/get/create/update/delete_auth_userfor 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_sqlwithread_only=true; write statements are rejected at the database level. When only read access is needed, setHUAWEICLOUD_MCP_READ_ONLY=trueto 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 ... CASCADEis forbidden. Before an irreversible user write operation, confirm the exactuser_idoremailwith 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.migrationsis 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.usersdirectly (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_querywithanalyze=truereally executes the SQL — DML in the plan modifies data. Treat it as a write operation: per-statement human confirmation, exactly likeexecute_sql(Workflow step 2). Preferanalyze=falsewhen investigating; the server read-only mode does not intercept this READ-class tool.
Prerequisites
- 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 ashttp(s)://<rds_supabase_eip>:<rds_supabase_port>from the instance's EIP and port),HUAWEICLOUD_MCP_RDS_SUPABASE_ANON_KEY, andHUAWEICLOUD_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. - 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_urlreturns the gateway URL andlist_tablesreturns 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 REPLACEfor functions and views) or rework the script as incremental changes. -
Step 2, review — four mandatory checks before execution:
- Idempotency: the script can run multiple times —
CREATE TABLE IF NOT EXISTS,CREATE OR REPLACEfor functions and views,DROP POLICY IF EXISTSbeforeCREATE POLICY,INSERT ... ON CONFLICT DO NOTHING. - Destructive statements:
DROP,TRUNCATE,ALTERrequire per-statement human confirmation;DROP ... CASCADEis forbidden. - 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_advisorsreports it). - Least privilege: grant only necessary privileges to necessary roles (e.g.
GRANT SELECT ON t TO anon); avoid over-granting.
- Idempotency: the script can run multiple times —
-
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 forexecute_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 restartPostgREST 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; optionallyGET /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_sqlwithread_only=truefor 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 withget_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_advisorsafter remediating; the remediation action itself is not the confirmation. - Set
HUAWEICLOUD_MCP_AUDIT_FILEto persist the per-call JSONL audit log (always emitted to stderr otherwise). - In production, configure a confirmation rule for
execute_sqlviaHUAWEICLOUD_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_sqlparameterread_onlylimits a single call to read-only statements (the gate also rejects data-modifying WITH and EXPLAIN ANALYZE), whileHUAWEICLOUD_MCP_READ_ONLY=trueblocks 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 referencerequest.jwt.claimsbare — PostgreSQL parses it as a table reference and the statement fails with SQLSTATE 42P01. - Advisor security codes:
0013RLS not enabled,0007policy exists but RLS disabled,0008RLS enabled without a policy. public.migrationsis 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_FILEto 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.usersdirectly is forbidden.
