relational-database-mcp-cloudbase

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

When to use this skill

何时使用该Skill

Use this skill when an agent needs to operate on CloudBase Relational Database via MCP tools, for example:
  • Inspecting or querying data in tables
  • Modifying data or schema (INSERT/UPDATE/DELETE/DDL)
  • Reading or changing table security rules
Do NOT use this skill for:
  • Building Web or Node.js applications that talk to CloudBase Relational Database (use the Web/Node Relational Database skills)
  • Auth flows or user identity (use the Auth skills)
当Agent需要通过MCP工具操作CloudBase关系型数据库时,使用该Skill,例如:
  • 检查或查询表中的数据
  • 修改数据或模式(INSERT/UPDATE/DELETE/DDL)
  • 读取或修改表的安全规则
请勿将该Skill用于:
  • 构建与CloudBase关系型数据库交互的Web或Node.js应用(请使用Web/Node关系型数据库相关Skill)
  • 认证流程或用户身份管理(请使用认证相关Skill)

How to use this skill (for a coding agent)

如何使用该Skill(针对编码Agent)

  1. Recognize MCP context
    • If you can call tools like
      executeReadOnlySQL
      ,
      executeWriteSQL
      ,
      readSecurityRule
      ,
      writeSecurityRule
      , you are in MCP context.
    • In this context, never initialize SDKs for CloudBase Relational Database; use MCP tools instead.
  2. Pick the right tool for the job
    • Reads →
      executeReadOnlySQL
    • Writes/DDL →
      executeWriteSQL
    • Inspect rules →
      readSecurityRule
    • Change rules →
      writeSecurityRule
  3. Always be explicit about safety
    • Before destructive operations (DELETE, DROP, etc.), summarize what you are about to run and why.
    • Prefer running read-only SELECTs first to verify assumptions.

  1. 识别MCP上下文
    • 如果您可以调用
      executeReadOnlySQL
      、
      executeWriteSQL
      、
      readSecurityRule
      、
      writeSecurityRule
      等工具,说明您处于MCP上下文环境中。
    • 在该上下文环境中,绝对不要初始化CloudBase关系型数据库的SDK;请改用MCP工具。
  2. 为任务选择合适的工具
    • 读取操作 →
      executeReadOnlySQL
    • 写入/DDL操作 →
      executeWriteSQL
    • 检查规则 →
      readSecurityRule
    • 修改规则 →
      writeSecurityRule
  3. 始终明确安全性
    • 在执行破坏性操作(DELETE、DROP等)之前,总结您即将执行的操作内容及原因。
    • 优先运行只读SELECT语句来验证假设。

Available MCP tools (CloudBase Relational Database)

可用的MCP工具(CloudBase关系型数据库)

These tools are the only supported way to interact with CloudBase Relational Database via MCP:
这些工具是唯一支持通过MCP与CloudBase关系型数据库交互的方式:

1.
executeReadOnlySQL

1.
executeReadOnlySQL

  • Purpose: Run
    SELECT
    queries (read-only).
  • Use for:
    • Listing rows, aggregations, joins.
    • Inspecting data before changing it.
Example call (conceptual):
sql
SELECT id, email FROM users WHERE active = true ORDER BY created_at DESC LIMIT 50;
Call this through the MCP tool instead of embedding SQL in code.
  • 用途: 运行
    SELECT
    查询(只读)。
  • 适用场景:
    • 列出行数据、聚合、连接查询。
    • 在修改数据前检查数据。
示例调用(概念性):
sql
SELECT id, email FROM users WHERE active = true ORDER BY created_at DESC LIMIT 50;
请通过MCP工具调用该查询,而非将SQL嵌入代码中。

2.
executeWriteSQL

2.
executeWriteSQL

  • Purpose: Run write or DDL statements:
    • INSERT
      ,
      UPDATE
      ,
      DELETE
    • CREATE TABLE
      ,
      ALTER TABLE
      ,
      DROP TABLE
  • Use for:
    • Data migrations
    • Fixing or seeding data
    • Schema changes
Important: When creating a new table, you must include the
_openid
column for per-user access control:
sql
_openid VARCHAR(64) DEFAULT '' NOT NULL
💡 Note about
_openid
: When a user is logged in, the
_openid
field is automatically populated by the server with the current user's identity. You do NOT need to manually set this field in INSERT operations - the server will fill it automatically based on the authenticated user's session.
Before calling this tool, confirm:
  • The target tables and conditions are correct.
  • You have run a corresponding
    SELECT
    via
    executeReadOnlySQL
    when appropriate.
  • 用途: 运行写入或DDL语句:
    • INSERT
      、
      UPDATE
      、
      DELETE
    • CREATE TABLE
      、
      ALTER TABLE
      、
      DROP TABLE
  • 适用场景:
    • 数据迁移
    • 修复或填充数据
    • 模式变更
重要提示: 创建新表时,您必须包含
_openid
列以实现按用户访问控制:
sql
_openid VARCHAR(64) DEFAULT '' NOT NULL
💡 关于
_openid
的说明
:当用户登录后,服务器会自动将当前用户的身份信息填充到
_openid
字段
。您无需在INSERT操作中手动设置该字段——服务器会根据已认证用户的会话自动填充。
调用该工具前,请确认:
  • 目标表和条件是正确的。
  • 适当时,已通过
    executeReadOnlySQL
    运行对应的SELECT查询。

3.
readSecurityRule

3.
readSecurityRule

  • Purpose: Read security rules for a given table.
  • Use for:
    • Understanding who can read/write a table.
    • Auditing permissions on sensitive tables.
Security rule types typically include:
  • READONLY
    – anyone can read, no one can write
  • PRIVATE
    – only authenticated users can read/write
  • ADMINWRITE
    – anyone can read, only admins can write
  • ADMINONLY
    – only admins can read/write
  • CUSTOM
    – custom security logic
  • 用途: 读取指定表的安全规则。
  • 适用场景:
    • 了解谁可以读写该表。
    • 审计敏感表的权限。
安全规则类型通常包括:
  • READONLY
    – 任何人可读取,无人可写入
  • PRIVATE
    – 仅已认证用户可读写
  • ADMINWRITE
    – 任何人可读取,仅管理员可写入
  • ADMINONLY
    – 仅管理员可读写
  • CUSTOM
    – 自定义安全逻辑

4.
writeSecurityRule

4.
writeSecurityRule

  • Purpose: Set or update security rules for a table.
  • Use for:
    • Hardening access to sensitive data
    • Opening up read access while restricting writes
    • Applying custom rules when needed
When using this tool:
  • Clearly explain the intent (who should read/write what).
  • Prefer standard rule types (
    READONLY
    ,
    PRIVATE
    , etc.) before
    CUSTOM
    .

  • 用途: 设置或更新表的安全规则。
  • 适用场景:
    • 强化敏感数据的访问权限
    • 开放读取权限同时限制写入权限
    • 必要时应用自定义规则
使用该工具时:
  • 明确说明意图(谁应该读写什么数据)。
  • 优先使用标准规则类型(
    READONLY
    、
    PRIVATE
    等),而非
    CUSTOM
    。

Scenario 1: Safely inspect data in a table

场景1:安全检查表中的数据

  1. Use
    executeReadOnlySQL
    with a limited
    SELECT
    :
    • Include a
      LIMIT
      clause.
    • Filter by relevant conditions.
  2. Review the result set and confirm it matches expectations.
This pattern prevents accidental full-table scans and gives you context before any write operations.

  1. 使用
    executeReadOnlySQL
    执行带限制的
    SELECT
    查询:
    • 包含
      LIMIT
      子句。
    • 按相关条件过滤。
  2. 查看结果集并确认其符合预期。
该模式可防止意外的全表扫描,并在执行任何写入操作前为您提供上下文信息。

Scenario 2: Apply a schema change

场景2:应用模式变更

  1. Use
    executeReadOnlySQL
    to inspect the current schema or data (if needed).
  2. Plan the
    CREATE TABLE
    /
    ALTER TABLE
    statement.
  3. Run it once via
    executeWriteSQL
    .
  4. Optionally, validate by running
    SELECT
    again.
Always describe:
  • What schema change you are making.
  • Why it is safe in the current context.

  1. 使用
    executeReadOnlySQL
    检查当前模式或数据(如有需要)。
  2. 规划
    CREATE TABLE
    /
    ALTER TABLE
    语句。
  3. 通过
    executeWriteSQL
    运行一次该语句。
  4. 可选:再次运行SELECT查询以验证结果。
始终说明:
  • 您正在进行的模式变更内容。
  • 该变更在当前上下文中为何是安全的。

Scenario 3: Tighten security rules on a sensitive table

场景3:收紧敏感表的安全规则

  1. Call
    readSecurityRule
    for the table to see current settings.
  2. Decide on the target rule (e.g., from
    READONLY
    →
    PRIVATE
    ).
  3. Explain the change and why it matches the user’s requirements.
  4. Call
    writeSecurityRule
    with the new rule.
  5. Optionally, re-read the rule to confirm the update.

  1. 调用
    readSecurityRule
    查看该表的当前设置。
  2. 确定目标规则(例如从
    READONLY
    改为
    PRIVATE
    )。
  3. 说明变更内容及为何符合用户需求。
  4. 调用
    writeSecurityRule
    设置新规则。
  5. 可选:重新读取规则以确认更新成功。

Key principle: MCP tools vs SDKs

核心原则:MCP工具 vs SDK

  • MCP tools are for agent operations and database management:
    • Run ad-hoc SQL.
    • Inspect and change security rules.
    • Do not depend on application auth state.
  • SDKs are for application code:
    • Frontend Web apps → Web Relational Database skill.
    • Backend Node apps → Node Relational Database quickstart.
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.
  • MCP工具适用于Agent操作和数据库管理:
    • 运行临时SQL查询。
    • 检查和修改安全规则。
    • 不依赖应用的认证状态。
  • SDK适用于应用代码:
    • 前端Web应用 → Web关系型数据库Skill。
    • 后端Node应用 → Node关系型数据库快速入门。
当作为MCP Agent工作时,请始终优先使用这些MCP工具操作CloudBase关系型数据库,避免在同一流程中混合使用SDK初始化。