English | 中文
[//]: # (
)
---
## Usage Methods
DMS MCP Server currently supports two usage modes.
### Mode One: Multi-instance Mode
- Supports adding instances to DMS, allowing access to multiple database instances.
- Suitable for scenarios where managing and accessing multiple database instances is required.
#### Scenario Example:
You are a company DBA who needs to manage and access various types of database instances (e.g., MySQL, Oracle, PostgreSQL) in production, test, and development environments. With DMS MCP Server, you can achieve unified access and centralized management of these heterogeneous databases.
**Typical Question Examples:**
- Which of my instances are in the production environment?
- Get a list of all databases named `test`.
- Retrieve details of the `test_db` database from the `myHost:myPort` instance.
- What tables are in the `test_db` database?
- Use a tool to query data from the `test_db` database and answer: "What is today's user traffic?"
### Mode Two: Single Database Mode
- Directly specify the target database by configuring the `CONNECTION_STRING` parameter in the server (format: `dbName@host:port`).
- Suitable for scenarios that focus on accessing a single database.
#### Scenario Example 1:
You are a developer who frequently accesses a fixed database (e.g., `mydb@192.168.1.100:3306`) for development and testing. Set the `CONNECTION_STRING` parameter in the DMS MCP Server configuration as follows:
```ini
CONNECTION_STRING = mydb@192.168.1.100:3306
```
Afterward, every time the service starts, the DMS MCP Server will directly access this specified database without needing to switch instances.
**Typical Question Examples:**
- What tables do I have?
- Show the field structure of the `test_table` table.
- Retrieve the first 20 rows from the `test_table` table.
- Use a tool to answer: "What is today's user traffic?"
#### Scenario Example 2:
You are a data analyst at an e-commerce company, needing to frequently query and analyze business data such as orders, users, and products. The company's core business database is located at ecommerce@10.20.30.40:3306.
Configure the following parameters in DMS MCP Server:
```ini
CONNECTION_STRING = ecommerce@10.20.30.40:3306
```
Simply ask questions in natural language, and DMS MCP will parse the question into SQL and return the results.
**Typical Question Examples:**
- What is the total number of orders today?
- How are the order counts ranked by province?
- What is the number of new users each day over the past 7 days?
- Which product category has the highest sales revenue?
---
## Tool List
| Tool Name | Description | Applicable Mode |
|--------------------|---------------------------------------------------------------------------------------------------------------------------|-------------------------------|
| addInstance | Adds an instance to DMS. Only Aliyun instances are supported. | Multi-instance Mode |
| listInstances | Search for instances from DMS. | Multi-instance Mode |
| getInstance | Retrieves detailed information about an instance based on host and port. | Multi-instance Mode |
| searchDatabase | Searches databases based on schemaName. | Multi-instance Mode |
| getDatabase | Retrieves detailed information about a specific database. | Multi-instance Mode |
| listTables | Lists tables under a specified database. | Multi-instance Mode & Single Database Mode |
| getTableDetailInfo | Retrieves detailed information about a specific table. | Multi-instance Mode & Single Database Mode |
| executeScript | Executes an SQL script and returns the result. | Multi-instance Mode & Single Database Mode |
| createDataChangeOrder | Creates a data change order in DMS. | Multi-instance Mode & Single Database Mode |
| getOrderInfo | Retrieves order information from DMS. | Multi-instance Mode & Single Database Mode |
| submitOrderApproval | Submits the order for approval in DMS. | Multi-instance Mode & Single Database Mode |
| approveOrder | Approves or rejects an order in DMS. | Multi-instance Mode & Single Database Mode |
| generateSql | Converts natural language questions into SQL queries. | Multi-instance Mode |
| askDatabase | Natural language querying of a database (NL2SQL + execute SQL). | Single Database Mode |
| fixSql | Analyzes and fixes SQL errors. | Multi-instance Mode & Single Database Mode |
| answerSqlSyntax | Answers SQL syntax-related questions. | Multi-instance Mode & Single Database Mode |
| optimizeSql | Analyzes and optimizes SQL performance. | Multi-instance Mode & Single Database Mode |
For a full list of tools, please refer to: Tool List
[//]: # (
)
## Security
### Network Binding
This MCP Server **only binds to `127.0.0.1` (localhost)**. It does not support remote network access. All connections must originate from the local machine. This design ensures that even if the server is accidentally started, it will not be exposed to the network.
### SQL Execution Disclaimer
> **IMPORTANT: This tool is designed to provide full SQL execution capabilities, including SELECT, INSERT, UPDATE, DELETE, and DDL statements.**
By using this MCP Server, you acknowledge and accept the following:
1. **You are solely responsible** for ensuring that the AK/SK (AccessKey) used has appropriate, minimal permissions configured in Alibaba Cloud RAM.
2. **It is strongly recommended** to enable [DMS Safe Hosting Mode](https://help.aliyun.com/zh/dms/user-guide/overview-of-instance-management) for your database instances, which provides built-in SQL review, risk identification, and approval workflows.
3. **The maintainers of this project are not responsible** for any data loss, corruption, or security incidents resulting from SQL execution through this tool.
4. **Best practices**:
- Use read-only AK/SK for query-only scenarios
- Enable DMS fine-grained permission control
- Enable SQL audit logging for compliance
- Regularly review and rotate access credentials
### Security Design
- **No command injection risk**: The codebase does not use `subprocess`, `os.system`, `eval()`, or `exec()`. All operations are performed through the Alibaba Cloud SDK.
- **No SSRF risk**: All network requests are sent to a fixed Alibaba Cloud endpoint (`dms-enterprise.cn-hangzhou.aliyuncs.com`) via the SDK. No user-controlled URLs are fetched.
- **Input validation**: Search interfaces validate input length and reject potentially dangerous SQL patterns to prevent injection through non-SQL-execution interfaces.
---
## License
This project is licensed under the Apache 2.0 License.
---
## Agent Skills (Independent of MCP)
In addition to the MCP Server, this project also hosts **AI Agent skills** for DMS Enterprise. These skills enable any AI agent (Codex, ChatGPT, Cursor, etc.) to manage DMS resources directly via OpenAPI — no MCP protocol required.
### Quick Start (Skills)
1. Read the skill definition:
[`skills/database/dms/alicloud-database-dms-enterprise/SKILL.md`](skills/database/dms/alicloud-database-dms-enterprise/SKILL.md)
2. Discover available APIs:
```bash
python3 skills/database/dms/alicloud-database-dms-enterprise/scripts/list_openapi_meta_apis.py
```
3. Configure AccessKey:
```bash
export ALICLOUD_ACCESS_KEY_ID="your-ak"
export ALICLOUD_ACCESS_KEY_SECRET="your-sk"
export ALICLOUD_REGION_ID="cn-hangzhou"
```
### Skill Capabilities
| Category | Operations |
|---|---|
| Instance Management | Register, list, update, delete database instances |
| SQL Execution & Audit | Execute scripts, NL2SQL, SQL review & optimization |
| Permission Management | Create permission orders, grant/revoke user permissions |
| Data Security | Sensitive column identification, data masking, audit logs |
| Task Orchestration | Create, execute, monitor task flows (DAG) |
| Metadata Knowledge | Get/edit table business knowledge |
### Prompt Examples
See [`skills/examples/prompts/`](skills/examples/prompts/) for DMS scenario-based prompt templates:
- Instance management & resource query
- SQL execution & audit
- Permission & security management
- Task orchestration & data changes
- API discovery & metadata
### Skill Index
| Category | Skill | Description | Path |
| --- | --- | --- | --- |
| database/dms | alicloud-database-dms-enterprise | Manage Alibaba Cloud Data Management Service (DMS Enterprise) via OpenAPI. Use for database instance management, SQL audit, data security, task orchestration, sensitive data protection, permission management, and database operation workflows. | `skills/database/dms/alicloud-database-dms-enterprise` |
For agent-specific guidelines, see [`AGENTS.md`](AGENTS.md).