ApsaraDB Agent

Updated at:
Copy as MD

ApsaraDB Agent is an intelligent assistant integrated into the ApsaraDB console that helps you efficiently manage and use Alibaba Cloud database products.

Core capabilities

ApsaraDB Agent provides the following capabilities to help you manage and use databases more efficiently.

Knowledge Q&A for database products

You can ask the agent questions about the features, pricing, and best practices of Alibaba Cloud database products at any time. The agent provides accurate and timely answers based on official documentation and the knowledge base.

image

Instance diagnosis and analysis

When a database instance experiences performance issues or anomalies, you can use the agent to perform an intelligent diagnosis. It analyzes relevant metrics and logs to help you quickly identify the root cause.

Note

This feature is currently available only for cloud-native database PolarDB and ApsaraDB for Tair (Redis-compatible). Support for other database products will be added.

image.png

Usage notes

Welcome to ApsaraDB Agent! Before you use the service, read and understand the following terms:

  1. Content accuracy and service reliability: The content is generated by an AI model, and Alibaba Cloud does not guarantee its accuracy, completeness, security, reliability, or availability. This content does not represent the position or views of Alibaba Cloud. Alibaba Cloud assumes no liability for any results arising from your use of this service. Exercise caution and do not rely excessively on the generated content.

  2. User responsibility: Ensure that any content you publish, upload, or transmit through this service complies with applicable laws and regulations, does not infringe on any third-party rights, and does not spread false information.

  3. Data collection and authorization: To provide this service, ApsaraDB Agent collects and processes necessary information from your database instances. This includes basic information, system table information, monitoring metrics, events, and key error information from logs. By using this service, you acknowledge and agree to these terms.

Access points

You can interact with ApsaraDB Agent through the following entry points:

General entry point

Click the image icon on the left or right sidebar of the ApsaraDB console to open the ApsaraDB Agent dialog box.

Instance diagnosis entry point

In specific management and O&M scenarios, such as on resource list and instance detail pages, the system provides quick-access entry points to activate the agent. These entry points allow you to diagnose issues or perform operations based on the current context. This feature is currently supported only for cloud-native database PolarDB and ApsaraDB for Tair (Redis-compatible). For more information, see PolarDB AI Assistant and Tair AI Assistant. Support for other products is gradually being rolled out.

  1. Go to the Resource Management page on the ApsaraDB console. Find the instance that you want to diagnose and analyze, and click the AI-powered inspection button.

  2. In the dialog box that appears on the right, select an Inspection item and a Time range, and then click Start inspection.

    image

MCP Server open-source project

ApsaraDB Agent MCP Server is an open-source database tool service built on the Model Context Protocol (MCP). The project is hosted on GitHub. With MCP Server, AI programming assistants such as Cursor, Claude Desktop, and Qoder can directly manage and operate ApsaraDB databases. This enables a complete workflow in which AI automatically creates databases, creates tables, executes SQL statements for verification, and calls ApsaraDB Agent for performance diagnostics in an IDE.

Repository: https://github.com/aliyun/alibabacloud-yaochi-db-mcp-server.

Supported databases

MCP Server supports the following database engines:

Database engine

Supported operations

ApsaraDB RDS for MySQL

Create instances, execute SQL statements, and use temporary accounts

PolarDB for MySQL

Create clusters, execute SQL statements, and use temporary accounts

ApsaraDB for MongoDB

Create replica sets and execute MongoDB commands

ApsaraDB for Tair (Redis-compatible)

Create instances and execute Redis commands

In addition, MCP Server has built-in ApsaraDB Agent capabilities that support knowledge Q&A, intelligent diagnostics, and best practice recommendations for all ApsaraDB database engines.

Get started

  1. Clone the project and install it.

    git clone https://github.com/aliyun/alibabacloud-yaochi-db-mcp-server.git
    cd alibabacloud-yaochi-db-mcp-server
    python3 -m venv .venv
    source .venv/bin/activate
    pip install .
  2. Verify the installation. Run the following command. If the program enters stdio wait mode with no output, the installation is successful. Press Ctrl+C to exit.

    yaochi-db-mcp-server
  3. Add the following configuration to the MCP configuration file of your AI assistant.

    {
      "mcpServers": {
        "yaochi-db": {
          "command": "<project_path>/alibabacloud-yaochi-db-mcp-server/.venv/bin/yaochi-db-mcp-server",
          "env": {
            "ALIBABA_CLOUD_ACCESS_KEY_ID": "<your_access_key_id>",
            "ALIBABA_CLOUD_ACCESS_KEY_SECRET": "<your_access_key_secret>",
            "ALIBABA_CLOUD_REGION_ID": "cn-hangzhou",
            "YAOCHI_ENABLE_WRITE_SQL": "true",
            "YAOCHI_ENABLE_DDL_SQL": "true"
          }
        }
      }
    }

The following table describes the key environment variables.

Environment variable

Default value

Description

ALIBABA_CLOUD_ACCESS_KEY_ID

None

Required. The AccessKey ID of your Alibaba Cloud account.

ALIBABA_CLOUD_ACCESS_KEY_SECRET

None

Required. The AccessKey secret of your Alibaba Cloud account.

ALIBABA_CLOUD_REGION_ID

cn-hangzhou

The default region ID.

YAOCHI_ENABLE_WRITE_SQL

true

Specifies whether to allow DML operations such as INSERT, UPDATE, and DELETE.

YAOCHI_ENABLE_DDL_SQL

false

Specifies whether to allow DDL operations such as CREATE and ALTER.

Security mechanisms

  • Temporary accounts: When SQL statements are executed, temporary database accounts are automatically created and destroyed immediately after execution. No persistent credentials are retained.

  • SQL security checks: Dangerous operations such as DROP and TRUNCATE are automatically blocked. Comments and multi-statement execution are prohibited.

  • Restrictive whitelist: When public access is enabled, only the current IP address (/32) is allowed. Existing security rules are not affected.

  • Permission control: DML and DDL operation permissions are precisely controlled through environment variables.

MCP Server is open-sourced under the Apache License 2.0. You are welcome to visit GitHub to submit issues or pull requests.