All Products
Search
Document Center

AnalyticDB:Integrate the AI assistant using a Skill plugin for AnalyticDB for MySQL

Last Updated:Jul 09, 2026

The Claude Code skill for Alibaba Cloud AnalyticDB for MySQL enables cluster management, performance monitoring, slow query diagnosis, and SQL execution directly within Claude conversations.

Features

  • Cluster management: Query cluster lists, view cluster properties, check storage space, and review account and network information.

  • Performance monitoring: Query metrics such as CPU, memory, queries per second (QPS), response time (RT), connections, and disk usage.

  • Slow query diagnosis: Detect bad SQL, analyze SQL patterns, and identify the root causes of slow queries through a guided diagnostic process.

  • Running SQL analysis: View currently running SQL statements to identify operations with high resource consumption.

  • Table-level analysis: View table statistics and optimization suggestions, and detect issues such as excessive primary keys, oversized unpartitioned tables, partitioned table problems, and data skew.

  • SQL execution: Connect directly to a database to run diagnostic SQL statements. Requires database connection configuration.

  • Guided diagnostic scenarios: Built-in diagnostic flows for common scenarios, including slow query investigation, cluster health checks, SQL health checks, and configuration reviews.

  • Zero installation: Use the uv run command for inline script dependencies. No extra pip install is needed.

Prerequisites

  • Python 3.10 or later.

  • uv (recommended) or pip.

  • An Alibaba Cloud AccessKey with permissions for AnalyticDB for MySQL.

Getting started

Step 1: Clone the repository

git clone https://github.com/aliyun/alibabacloud-adb-mysql-mcp-server
cd alibabacloud-adb-mysql-mcp-server/skill

Step 2: Install uv

curl -LsSf https://astral.sh/uv/install.sh | sh

Step 3: Configure environment variables

For macOS or Linux:

export ALIBABA_CLOUD_ACCESS_KEY_ID="Your_AccessKey_ID"
export ALIBABA_CLOUD_ACCESS_KEY_SECRET="Your_AccessKey_secret"
# Optional: Set the Security Token Service (STS) token when using temporary credentials.
# export ALIBABA_CLOUD_SECURITY_TOKEN="Your_STS_token"
# Optional: Connect directly to a database to run SQL (for execute_sql).
# export ADB_MYSQL_HOST="your_database_host"
# export ADB_MYSQL_PORT="3306"
# export ADB_MYSQL_USER="your_database_username"
# export ADB_MYSQL_PASSWORD="your_database_password"
# export ADB_MYSQL_DATABASE="your_default_database_name"

To configure permanently (recommended):

Add the preceding commands to your shell configuration file, such as ~/.bashrc or ~/.zshrc.

Step 4: Deploy to Claude Code

Choose one of the following methods to deploy.

  • Copy the skill directory to the Claude Code skills directory.

    # macOS / Linux
    mkdir -p ~/.claude/skills/
    cp -r alibabacloud-adb-mysql-copilot ~/.claude/skills/
  • Create a symbolic link. This is recommended for development environments.

    mkdir -p ~/.claude/skills/
    ln -s "$(pwd)/alibabacloud-adb-mysql-copilot" ~/.claude/skills/alibabacloud-adb-mysql-copilot

Step 5: Verify the installation

Start Claude Code and call the skill:

claude
/alibabacloud-adb-mysql-copilot I have several instances in Zhangjiakou

Usage examples

After installing the skill, enter the prompts shown below into your Claude Code conversation. Claude automatically calls the appropriate diagnostic function and returns the results.

Find an instance

Find the list of instances in a specific region.

You: /alibabacloud-adb-mysql-copilot Which AnalyticDB for MySQL instances are in the Hangzhou region?
Claude: [Calls the AnalyticDB for MySQL Copilot and returns the result]

Diagnose slow queries for an instance

Run a slow query diagnosis for a specific instance over a specified time period.

You: /alibabacloud-adb-mysql-copilot For the instance amv-xxx in Zhangjiakou, run a slow query diagnosis for the last 2 hours.
Claude: [Calls the instance slow query diagnosis logic and returns bad SQL and optimization suggestions]

Diagnose instance storage space

Run a full storage space health check on a specific instance. Seven diagnostic tasks run in parallel: oversized unpartitioned tables, partition design, primary key design, table data skew, replicated table design, idle indexes, and hot/cold tables. Results are summarized in a health check report.

You: /alibabacloud-adb-mysql-copilot For the Zhangjiakou cluster, run a storage space diagnosis on instance amv-xxx.
Claude: [Calls the instance storage space diagnosis logic, runs multiple diagnostic tasks in parallel, and returns a summarized instance health check report]

Diagnose table data skew

Detect fact tables with data skew in an instance. Data skew can cause unbalanced resource usage and long-tail queries.

You: /alibabacloud-adb-mysql-copilot Does instance amv-xxx have any table data skew? Check the data skew status of its fact tables.
Claude: [Calls the table data skew diagnosis logic and returns the fact tables with data skew and their skew status]

Diagnose partition design

Detect tables with poorly designed partition fields. Partitions that are too large or too small can affect build and query performance.

You: /alibabacloud-adb-mysql-copilot Run a partition design diagnosis for amv-xxx to see if there are any tables with poor partition designs.
Claude: [Calls the partition design diagnosis logic and returns the tables with poor partition designs and their physical capacity]

Diagnose oversized unpartitioned tables

Detect unpartitioned tables with large data volumes. These tables can trigger full table builds and cause disk and performance issues.

You: /alibabacloud-adb-mysql-copilot Check if there are any oversized unpartitioned tables in amv-xxx.
Claude: [Calls the oversized unpartitioned table diagnosis logic and returns the names, physical capacity, and row counts of abnormal tables]

Diagnose replicated table design

Detect replicated tables with too many rows. Replicated tables use broadcast writes, so excessive rows can increase write pressure.

You: /alibabacloud-adb-mysql-copilot Run a replicated table design diagnosis for amv-xxx. Are there any poorly designed replicated tables?
Claude: [Calls the replicated table design diagnosis logic and returns poorly designed replicated tables with their capacity and row counts]

Get idle index optimization suggestions

View suggestions for idle or redundant indexes in an instance that can be deleted or optimized.

You: /alibabacloud-adb-mysql-copilot Are there any idle index optimization suggestions for amv-xxx? I want to save storage and reduce write operations.
Claude: [Calls the idle index optimization suggestion logic and returns optimizable indexes, suggestions, and expected benefits]

Get hot and cold table optimization suggestions

View optimization suggestions for tables suitable for tiered storage (hot-to-cold) to reduce costs.

You: /alibabacloud-adb-mysql-copilot For amv-xxx, provide hot and cold table optimization suggestions. Which tables can be moved to cold storage?
Claude: [Calls the hot and cold table optimization suggestion logic and returns tables that can be moved to cold storage, along with suggestions and expected benefits]

Run SQL on a specific instance

To run SQL on a specific instance, configure the following environment variables: ADB_MYSQL_HOST/ADB_MYSQL_PORT/ADB_MYSQL_USER/ADB_MYSQL_PASSWORD/ADB_MYSQL_DATABASE.

You: /alibabacloud-adb-mysql-copilot For amv-xxx, what is the current progress of the hot-to-cold table conversion?
Claude: [Queries the system table for the hot-to-cold table conversion progress]

You: /alibabacloud-adb-mysql-copilot For amv-xxx, what are the values of common configuration items?
Claude: [Queries the system table for the values of common configuration items]

FAQ

Missing dependencies

If you encounter an ImportError, manually install the dependencies:

pip install alibabacloud-adb20211201 alibabacloud-tea-openapi alibabacloud-tea-util pymysql

Credential error

Make sure the ALIBABA_CLOUD_ACCESS_KEY_ID and ALIBABA_CLOUD_ACCESS_KEY_SECRET environment variables are set correctly:

echo $ALIBABA_CLOUD_ACCESS_KEY_ID   # Should not be empty
echo $ALIBABA_CLOUD_ACCESS_KEY_SECRET  # Should not be empty

Claude Code does not recognize the skill

  1. Confirm that the skill is copied to ~/.claude/skills/alibabacloud-adb-mysql-copilot/.

  2. Confirm that the SKILL.md file exists in the skill's root directory.

  3. Restart Claude Code.