Activation Contract
Use this first when
- The agent must inspect SQL data, execute SQL statements, provision or destroy MySQL, initialize table structure, or manage table security rules through MCP tools.
Read before writing code if
- The task includes
querySqlDatabase, manageSqlDatabase, readSecurityRule, or writeSecurityRule.
Then also read
- Web application integration ->
../relational-database-web/SKILL.md
- Raw HTTP database access ->
../http-api/SKILL.md
Do NOT use for
- Frontend or backend application code that should use SDKs instead of MCP operations.
Common mistakes / gotchas
- Initializing SDKs in an MCP management flow.
- Running write SQL or DDL before checking whether MySQL is provisioned and ready.
- Treating document database tasks as MySQL management tasks.
- Skipping
_openid and security-rule review after creating new SQL tables.
- Destroying MySQL without explicit confirmation or without checking whether the environment still needs the instance.
When to use this skill
Use this skill when an agent needs to operate on CloudBase Relational Database via MCP tools, for example:
- Inspecting or querying SQL data
- Provisioning MySQL for an environment
- Destroying MySQL for an environment
- Polling MySQL provisioning status
- Modifying data or schema (INSERT/UPDATE/DELETE/DDL)
- Initializing tables and indexes after MySQL is ready
- Reading or changing table security rules
Do NOT use this skill for:
- Building Web or Node.js applications that talk to CloudBase Relational Database directly through SDKs
- Auth flows or user identity management
How to use this skill (for a coding agent)
Recognize MCP context
- If you can call tools like
querySqlDatabase, manageSqlDatabase, readSecurityRule, writeSecurityRule, you are in MCP context.
- In this context, never initialize SDKs for CloudBase Relational Database; use MCP tools instead.
Pick the right tool for the job
- Read-only SQL and provisioning status checks ->
querySqlDatabase
- MySQL provisioning, MySQL destruction, write SQL, DDL, schema initialization ->
manageSqlDatabase
- Inspect rules ->
readSecurityRule
- Change rules ->
writeSecurityRule
Always be explicit about safety
- Before destructive operations (DELETE, DROP, etc.), summarize what you are about to run and why.
- Prefer
querySqlDatabase(action="getInstanceInfo") or a read-only SQL check before writes.
- Provisioning or destroying MySQL requires explicit confirmation because both actions have environment-level impact.
Available MCP tools (CloudBase Relational Database)
These tools are the supported way to interact with CloudBase Relational Database via MCP:
1. querySqlDatabase
- Purpose: Query SQL data and provisioning state.
- Use for:
- Running
SELECT and other read-only SQL queries with action="runQuery"
- Checking whether MySQL already exists with
action="getInstanceInfo"
- Inspecting asynchronous provisioning progress with
action="describeCreateResult" or action="describeTaskStatus"
Example flow:
{
"action": "runQuery",
"sql": "SELECT id, email FROM users ORDER BY created_at DESC LIMIT 50"
}
2. manageSqlDatabase
- Purpose: Manage SQL lifecycle and execute mutating SQL.
- Use for:
- Provisioning MySQL with
action="provisionMySQL"
- Destroying MySQL with
action="destroyMySQL"
- Executing
INSERT, UPDATE, DELETE, CREATE TABLE, ALTER TABLE, DROP TABLE with action="runStatement"
- Initializing tables and indexes with
action="initializeSchema"
Important: When creating a new table, you must include the _openid column for per-user access control:
_openid VARCHAR(64) DEFAULT '' NOT NULL
Note: when a user is logged in, _openid is automatically populated by the server from the authenticated session. Do not manually fill it in normal inserts.
Before calling this tool, confirm:
- The current environment has a ready MySQL instance, or you have just provisioned one.
- The target tables and conditions are correct.
- You have run a corresponding read-only query when appropriate.
When destroying MySQL, confirm:
- The current environment really should lose the SQL instance.
- You have explicit confirmation for the destructive action.
- You are prepared to query
describeTaskStatus afterward to inspect the destroy result.
3. readSecurityRule
- Purpose: Read security rules for a given SQL table.
- Use for:
- Understanding who can read/write a table
- Auditing permissions on sensitive tables
4. writeSecurityRule
- Purpose: Set or update security rules for a given SQL table.
- Use for:
- Hardening access to sensitive data
- Opening up read access while restricting writes
- Applying custom rules when needed
Recommended lifecycle flow
Scenario 1: MySQL is not provisioned yet
- Call
querySqlDatabase(action="getInstanceInfo").
- If no instance exists, call
manageSqlDatabase(action="provisionMySQL", confirm=true).
- Poll provisioning status with:
querySqlDatabase(action="describeCreateResult")
querySqlDatabase(action="describeTaskStatus")
- Only continue when the returned lifecycle status is
READY.
- For MySQL provisioning, prefer
describeCreateResult; reserve describeTaskStatus for destroy flows whose task response carries TaskName.
Scenario 2: Safely inspect data in a table
- Use
querySqlDatabase(action="runQuery") with a limited SELECT.
- Include
LIMIT and relevant filters.
- Review the result set and confirm it matches expectations before any write operation.
Scenario 3: Apply schema initialization after provisioning
- Confirm MySQL is ready.
- Prepare ordered DDL statements.
- Run them through
manageSqlDatabase(action="initializeSchema").
- After creating tables, verify security rules with
readSecurityRule or writeSecurityRule.
Scenario 4: Execute a targeted write or DDL change
- Use
querySqlDatabase(action="runQuery") to inspect current data or schema if needed.
- Run the mutation once with
manageSqlDatabase(action="runStatement").
- Validate with another read-only query or by checking security rules.
Scenario 5: Destroy MySQL when the environment no longer needs it
- Use
querySqlDatabase(action="getInstanceInfo") to confirm the current environment still has a SQL instance.
- Call
manageSqlDatabase(action="destroyMySQL", confirm=true).
- Query
querySqlDatabase(action="describeTaskStatus") until the destroy task completes or fails.
- If the task succeeds, optionally call
querySqlDatabase(action="getInstanceInfo") to confirm the instance no longer exists.
- If the task fails, treat the returned error as the terminal result and let the caller decide whether to retry.
Key principle: MCP tools vs SDKs
When working as an MCP agent, always prefer these MCP tools for CloudBase Relational Database, and avoid mixing them with SDK initialization in the same flow.
1---2name: relational-database-mcp-cloudbase3description: This is the required documentation for agents operating on the CloudBase Relational Database through MCP. It defines the canonical SQL management flow with `querySqlDatabase`, `manageSqlDatabase`, `readSecurityRule`, and `writeSecurityRule`, including MySQL provisioning, destroy flow, async status checks, safe query execution, schema initialization, and security rule updates.4---5
6## Activation Contract
7
8### Use this first when
9
10- The agent must inspect SQL data, execute SQL statements, provision or destroy MySQL, initialize table structure, or manage table security rules through MCP tools.
11
12### Read before writing code if
13
14- The task includes `querySqlDatabase`, `manageSqlDatabase`, `readSecurityRule`, or `writeSecurityRule`.
15
16### Then also read
17
18- Web application integration -> `../relational-database-web/SKILL.md`
19- Raw HTTP database access -> `../http-api/SKILL.md`
20
21### Do NOT use for
22
23- Frontend or backend application code that should use SDKs instead of MCP operations.
24
25### Common mistakes / gotchas
26
27- Initializing SDKs in an MCP management flow.
28- Running write SQL or DDL before checking whether MySQL is provisioned and ready.
29- Treating document database tasks as MySQL management tasks.
30- Skipping `_openid` and security-rule review after creating new SQL tables.
31- Destroying MySQL without explicit confirmation or without checking whether the environment still needs the instance.
32
33## When to use this skill
34
35Use this skill when an **agent** needs to operate on **CloudBase Relational Database via MCP tools**, for example:
36
37- Inspecting or querying SQL data
38- Provisioning MySQL for an environment
39- Destroying MySQL for an environment
40- Polling MySQL provisioning status
41- Modifying data or schema (INSERT/UPDATE/DELETE/DDL)
42- Initializing tables and indexes after MySQL is ready
43- Reading or changing table security rules
44
45Do **NOT** use this skill for:
46
47- Building Web or Node.js applications that talk to CloudBase Relational Database directly through SDKs
48- Auth flows or user identity management
49
50## How to use this skill (for a coding agent)
51
521. **Recognize MCP context**
53 - If you can call tools like `querySqlDatabase`, `manageSqlDatabase`, `readSecurityRule`, `writeSecurityRule`, you are in MCP context.
54 - In this context, **never initialize SDKs for CloudBase Relational Database**; use MCP tools instead.
55
562. **Pick the right tool for the job**
57 - Read-only SQL and provisioning status checks -> `querySqlDatabase`
58 - MySQL provisioning, MySQL destruction, write SQL, DDL, schema initialization -> `manageSqlDatabase`
59 - Inspect rules -> `readSecurityRule`
60 - Change rules -> `writeSecurityRule`
61
623. **Always be explicit about safety**
63 - Before destructive operations (DELETE, DROP, etc.), summarize what you are about to run and why.
64 - Prefer `querySqlDatabase(action="getInstanceInfo")` or a read-only SQL check before writes.
65 - Provisioning or destroying MySQL requires explicit confirmation because both actions have environment-level impact.
66
67---
68
69## Available MCP tools (CloudBase Relational Database)
70
71These tools are the supported way to interact with CloudBase Relational Database via MCP:
72
73### 1. `querySqlDatabase`
74
75- **Purpose:** Query SQL data and provisioning state.
76- **Use for:**
77 - Running `SELECT` and other read-only SQL queries with `action="runQuery"`
78 - Checking whether MySQL already exists with `action="getInstanceInfo"`
79 - Inspecting asynchronous provisioning progress with `action="describeCreateResult"` or `action="describeTaskStatus"`
80
81**Example flow:**
82
83```json
84{
85 "action": "runQuery",
86 "sql": "SELECT id, email FROM users ORDER BY created_at DESC LIMIT 50"
87}
88```
89
90### 2. `manageSqlDatabase`
91
92- **Purpose:** Manage SQL lifecycle and execute mutating SQL.
93- **Use for:**
94 - Provisioning MySQL with `action="provisionMySQL"`
95 - Destroying MySQL with `action="destroyMySQL"`
96 - Executing `INSERT`, `UPDATE`, `DELETE`, `CREATE TABLE`, `ALTER TABLE`, `DROP TABLE` with `action="runStatement"`
97 - Initializing tables and indexes with `action="initializeSchema"`
98
99**Important:** When creating a new table, you **must** include the `_openid` column for per-user access control:
100
101```sql
102_openid VARCHAR(64) DEFAULT '' NOT NULL
103```
104
105Note: when a user is logged in, `_openid` is automatically populated by the server from the authenticated session. Do not manually fill it in normal inserts.
106
107Before calling this tool, **confirm**:
108
109- The current environment has a ready MySQL instance, or you have just provisioned one.
110- The target tables and conditions are correct.
111- You have run a corresponding read-only query when appropriate.
112
113When destroying MySQL, confirm:
114
115- The current environment really should lose the SQL instance.
116- You have explicit confirmation for the destructive action.
117- You are prepared to query `describeTaskStatus` afterward to inspect the destroy result.
118
119### 3. `readSecurityRule`
120
121- **Purpose:** Read security rules for a given SQL table.
122- **Use for:**
123 - Understanding who can read/write a table
124 - Auditing permissions on sensitive tables
125
126### 4. `writeSecurityRule`
127
128- **Purpose:** Set or update security rules for a given SQL table.
129- **Use for:**
130 - Hardening access to sensitive data
131 - Opening up read access while restricting writes
132 - Applying custom rules when needed
133
134---
135
136## Recommended lifecycle flow
137
138### Scenario 1: MySQL is not provisioned yet
139
1401. Call `querySqlDatabase(action="getInstanceInfo")`.
1412. If no instance exists, call `manageSqlDatabase(action="provisionMySQL", confirm=true)`.
1423. Poll provisioning status with:
143 - `querySqlDatabase(action="describeCreateResult")`
144 - `querySqlDatabase(action="describeTaskStatus")`
1454. Only continue when the returned lifecycle status is `READY`.
1465. For MySQL provisioning, prefer `describeCreateResult`; reserve `describeTaskStatus` for destroy flows whose task response carries `TaskName`.
147
148### Scenario 2: Safely inspect data in a table
149
1501. Use `querySqlDatabase(action="runQuery")` with a limited `SELECT`.
1512. Include `LIMIT` and relevant filters.
1523. Review the result set and confirm it matches expectations before any write operation.
153
154### Scenario 3: Apply schema initialization after provisioning
155
1561. Confirm MySQL is ready.
1572. Prepare ordered DDL statements.
1583. Run them through `manageSqlDatabase(action="initializeSchema")`.
1594. After creating tables, verify security rules with `readSecurityRule` or `writeSecurityRule`.
160
161### Scenario 4: Execute a targeted write or DDL change
162
1631. Use `querySqlDatabase(action="runQuery")` to inspect current data or schema if needed.
1642. Run the mutation once with `manageSqlDatabase(action="runStatement")`.
1653. Validate with another read-only query or by checking security rules.
166
167### Scenario 5: Destroy MySQL when the environment no longer needs it
168
1691. Use `querySqlDatabase(action="getInstanceInfo")` to confirm the current environment still has a SQL instance.
1702. Call `manageSqlDatabase(action="destroyMySQL", confirm=true)`.
1713. Query `querySqlDatabase(action="describeTaskStatus")` until the destroy task completes or fails.
1724. If the task succeeds, optionally call `querySqlDatabase(action="getInstanceInfo")` to confirm the instance no longer exists.
1735. If the task fails, treat the returned error as the terminal result and let the caller decide whether to retry.
174
175---
176
177## Key principle: MCP tools vs SDKs
178
179- **MCP tools** are for **agent operations** and **database management**:
180 - Provision MySQL.
181 - Destroy MySQL.
182 - Poll lifecycle state.
183 - Run ad-hoc SQL.
184 - Inspect and change security rules.
185 - Do not depend on application auth state.
186
187- **SDKs** are for **application code**:
188 - Frontend Web apps -> Web Relational Database skill.
189 - Backend Node apps -> Node Relational Database quickstart.
190
191When working as an MCP agent, **always prefer these MCP tools** for CloudBase Relational Database, and avoid mixing them with SDK initialization in the same flow.