Labsco
aliyun logo

AnalyticDB for MySQL

31

from aliyun

An interface for AI agents to interact with AnalyticDB for MySQL databases, allowing them to retrieve metadata and execute SQL operations.

🔥🔥🔥🔥✓ VerifiedAccount requiredNeeds API keys

AnalyticDB for MySQL MCP Server

English | 中文

AnalyticDB for MySQL MCP Server is a universal interface between AI Agents and AnalyticDB MySQL. It provides two categories of capabilities:

  • OpenAPI Tools (openapi group): Manage clusters, whitelists, accounts, networking, monitoring, diagnostics, and audit logs via Alibaba Cloud OpenAPI.
  • SQL Tools & Resources (sql group): Connect directly to ADB MySQL clusters to execute SQL, view execution plans, and browse database metadata.

Read-only tools are annotated with ToolAnnotations(readOnlyHint=True) per the MCP protocol, allowing clients to distinguish them from mutating operations.

三、Environment Variables

VariableRequiredDescription
ALIBABA_CLOUD_ACCESS_KEY_IDYes (OpenAPI tools)Alibaba Cloud AccessKey ID
ALIBABA_CLOUD_ACCESS_KEY_SECRETYes (OpenAPI tools)Alibaba Cloud AccessKey Secret
ALIBABA_CLOUD_SECURITY_TOKENNoSTS temporary security token
ADB_MYSQL_HOSTNoDatabase host (direct-connection mode)
ADB_MYSQL_PORTNoDatabase port, default 3306 (direct-connection mode)
ADB_MYSQL_USERNoDatabase username (direct-connection mode)
ADB_MYSQL_PASSWORDNoDatabase password (direct-connection mode)
ADB_MYSQL_DATABASENoDefault database name (direct-connection mode)
ADB_MYSQL_CONNECT_TIMEOUTNoDatabase connection timeout in seconds, default 2
ADB_API_CONNECT_TIMEOUTNoOpenAPI connection timeout in milliseconds, default 10000 (10s)
ADB_API_READ_TIMEOUTNoOpenAPI read timeout in milliseconds, default 300000 (5min)
SERVER_TRANSPORTNoTransport protocol: stdio (default), sse, streamable_http
SERVER_PORTNoSSE/HTTP server port, default 8000

四、Tool List

4.1 Cluster Management (group: openapi)

ToolDescription
describe_db_clustersList ADB MySQL clusters in a region
describe_db_cluster_attributeGet detailed cluster attributes
describe_cluster_access_whitelistGet cluster IP whitelist
modify_cluster_access_whitelistModify cluster IP whitelist
describe_accountsList database accounts in a cluster
describe_cluster_net_infoGet cluster network connection info
get_current_timeGet current server time

4.2 Diagnostics & Monitoring (group: openapi)

ToolDescription
describe_db_cluster_performanceQuery cluster performance metrics (CPU, memory, QPS, etc.)
describe_db_cluster_health_statusQuery cluster health status
describe_diagnosis_recordsQuery SQL diagnosis summary records
describe_diagnosis_sql_infoGet SQL execution details (plan, runtime info)
describe_bad_sql_detectionDetect bad SQL impacting cluster stability
describe_sql_patternsQuery SQL pattern list
describe_table_statisticsQuery table-level statistics

4.3 Administration & Audit (group: openapi)

ToolDescription
create_accountCreate a database account
modify_db_cluster_descriptionModify cluster description
describe_db_cluster_space_summaryGet cluster storage space summary
describe_audit_log_recordsQuery SQL audit log records

4.4 Advanced Diagnostics (group: openapi)

ToolDescription
describe_executor_detectionCompute node diagnostics
describe_worker_detectionStorage node diagnostics
describe_controller_detectionAccess node diagnostics
describe_available_advicesGet optimization advices
kill_processKill a running query process
describe_db_resource_groupGet resource group configuration
describe_excessive_primary_keysDetect tables with excessive primary keys
describe_oversize_non_partition_table_infosDetect oversized non-partition tables
describe_table_partition_diagnoseDiagnose table partitioning issues
describe_inclined_tablesDetect data-skewed tables

4.5 SQL Tools (group: sql)

ToolDescription
execute_sqlExecute SQL on an ADB MySQL cluster
get_query_planGet EXPLAIN execution plan
get_execution_planGet EXPLAIN ANALYZE actual execution plan

4.6 MCP Resources (group: sql)

Resource URIDescription
adbmysql:///databasesList all databases
adbmysql:///{database}/tablesList all tables in a database
adbmysql:///{database}/{table}/ddlGet table DDL
adbmysql:///config/{key}/valueGet a config key value

五、Local Development

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

Run tests:

uv run python -m pytest test/ -v

Debug with MCP Inspector:

npx @modelcontextprotocol/inspector \
  -e ALIBABA_CLOUD_ACCESS_KEY_ID=your_ak \
  -e ALIBABA_CLOUD_ACCESS_KEY_SECRET=your_sk \
  uv --directory /path/to/alibabacloud-adb-mysql-mcp-server run adb-mysql-mcp-server

六、SKILL

In addition to the MCP server above, this project also provides an independent SKILL under the skill/ directory. The Skill can be deployed directly to Claude Code without relying on this MCP server (it calls ADB MySQL OpenAPI through call_adb_api.py in the SKILL directory).

The Skill covers cluster information queries, performance monitoring, slow query diagnosis, SQL Pattern analysis, and SQL execution, with built-in guided diagnostic workflows for common scenarios.

For setup and usage details, see skill/skill_readme.md.

Note: The evolution of this Skill will be aligned with our next-generation Agent in the future. Stay tuned.