|
| 1 | +# Alibaba Cloud RDS OpenAPI MCP Server |
| 2 | + |
| 3 | +🚀 Provides MCP server support for Alibaba Cloud RDS through OpenAPI. This project exposes Alibaba Cloud RDS, VPC, and billing APIs through the [MCP](https://github.com/CherryHQ/mcp) framework, packaging common database management tasks into easy-to-use tools. |
| 4 | + |
| 5 | + |
| 6 | + |
| 7 | +> ⚠️ **Note**: This documentation is based on Windows platform. |
| 8 | +
|
| 9 | +## 📋 Table of Contents |
| 10 | +- [✨ Features](#-features) |
| 11 | +- [📋 Prerequisites](#-prerequisites) |
| 12 | +- [🔧 Installation](#-installation) |
| 13 | +- [⚙️ Configuration](#️-configuration) |
| 14 | +- [🚀 Quick Start](#-quick-start) |
| 15 | +- [🛠️ Available Tools](#️-available-tools) |
| 16 | +- [💡 Usage Scenarios](#-usage-scenarios) |
| 17 | +- [🔌 Integration](#-integration) |
| 18 | +- [🤝 Contributing](#-contributing) |
| 19 | +- [📄 License](#-license) |
| 20 | +- [💬 Support](#-support) |
| 21 | + |
| 22 | +## ✨ Features |
| 23 | + |
| 24 | +- 🏗️ **Comprehensive RDS Management**: Create, configure, and manage RDS instances |
| 25 | +- 🔒 **Security & Compliance**: IP allowlist management and security auditing |
| 26 | +- 📊 **Performance Monitoring**: Query performance metrics and logs |
| 27 | +- 💰 **Cost Optimization**: Billing analysis and resource optimization |
| 28 | +- 🌐 **Multi-Environment Support**: Development, testing, and production environments |
| 29 | +- 🔗 **VPC Integration**: Complete VPC and switch management capabilities |
| 30 | + |
| 31 | +## 📋 Prerequisites |
| 32 | + |
| 33 | +- 🐍 Python 3.12 or higher |
| 34 | +- ☁️ Alibaba Cloud account with appropriate permissions |
| 35 | +- 🔑 Access Key ID and Access Key Secret (or STS Token) |
| 36 | + |
| 37 | +## 🔧 Installation |
| 38 | + |
| 39 | +### Method 1: Quick Start with uv (Recommended) |
| 40 | + |
| 41 | +1. **Install uv** |
| 42 | + ```powershell |
| 43 | + powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex" |
| 44 | + ``` |
| 45 | + |
| 46 | +2. **Run the server** |
| 47 | + ```bash |
| 48 | + uvx alibabacloud-rds-openapi-mcp-server@latest |
| 49 | + ``` |
| 50 | + |
| 51 | +### Method 2: Install from Source |
| 52 | + |
| 53 | +1. **Install Python 3.12+** |
| 54 | + |
| 55 | + Download from [Python official website](https://www.python.org/downloads/) |
| 56 | + |
| 57 | +2. **Clone the repository** |
| 58 | + ```bash |
| 59 | + git clone https://github.com/aliyun/alibabacloud-rds-openapi-mcp-server.git |
| 60 | + cd alibabacloud-rds-openapi-mcp-server |
| 61 | + ``` |
| 62 | + |
| 63 | +3. **Install dependencies** |
| 64 | + ```bash |
| 65 | + pip install -i https://mirrors.aliyun.com/pypi/simple/ alibabacloud_bssopenapi20171214 |
| 66 | + pip install -i https://mirrors.aliyun.com/pypi/simple/ alibabacloud_rds20140815 |
| 67 | + pip install -i https://mirrors.aliyun.com/pypi/simple/ alibabacloud_vpc20160428 |
| 68 | + pip install -i https://mirrors.aliyun.com/pypi/simple/ mcp |
| 69 | + ``` |
| 70 | + |
| 71 | +4. **Run the server** |
| 72 | + ```bash |
| 73 | + python src/alibabacloud_rds_openapi_mcp_server/server.py |
| 74 | + ``` |
| 75 | + |
| 76 | +## ⚙️ Configuration |
| 77 | + |
| 78 | +### Environment Variable Setup |
| 79 | + |
| 80 | +Before starting the MCP server, you need to set the necessary environment variables: |
| 81 | + |
| 82 | +#### PowerShell Configuration |
| 83 | +```powershell |
| 84 | +# Set server transport mode |
| 85 | +$env:SERVER_TRANSPORT="sse" |
| 86 | +
|
| 87 | +# Set Alibaba Cloud credentials |
| 88 | +$env:ALIBABA_CLOUD_ACCESS_KEY_ID="<Your AccessKey ID>" |
| 89 | +$env:ALIBABA_CLOUD_ACCESS_KEY_SECRET="<Your AccessKey Secret>" |
| 90 | +
|
| 91 | +# Optional: Set STS Token when using temporary credentials |
| 92 | +$env:ALIBABA_CLOUD_SECURITY_TOKEN="<Your STS Security Token>" |
| 93 | +``` |
| 94 | + |
| 95 | +#### Command Prompt (CMD) Configuration |
| 96 | +```cmd |
| 97 | +REM Set server transport mode |
| 98 | +set SERVER_TRANSPORT=sse |
| 99 | +
|
| 100 | +REM Set Alibaba Cloud credentials |
| 101 | +set ALIBABA_CLOUD_ACCESS_KEY_ID=<Your AccessKey ID> |
| 102 | +set ALIBABA_CLOUD_ACCESS_KEY_SECRET=<Your AccessKey Secret> |
| 103 | +
|
| 104 | +REM Optional: Set STS Token when using temporary credentials |
| 105 | +set ALIBABA_CLOUD_SECURITY_TOKEN=<Your STS Security Token> |
| 106 | +``` |
| 107 | + |
| 108 | +> ⚠️ **Important**: Please replace `<placeholders>` with your actual credential information. These environment variables are only valid for the current terminal session. |
| 109 | +
|
| 110 | +## 🚀 Quick Start |
| 111 | + |
| 112 | +### Server Startup Verification |
| 113 | + |
| 114 | +After successful startup, you will see output similar to the following: |
| 115 | +``` |
| 116 | +INFO: Started server process [Process ID] |
| 117 | +INFO: Waiting for application startup. |
| 118 | +INFO: Application startup complete. |
| 119 | +INFO: Uvicorn running on http://0.0.0.0:8000 (Press CTRL+C to quit) |
| 120 | +``` |
| 121 | + |
| 122 | +### Test Installation |
| 123 | + |
| 124 | +After configuration is complete, you can test the effectiveness of MCP tools using a simple prompt: |
| 125 | +``` |
| 126 | +Please list all available tools in a list format, showing titles and corresponding brief descriptions. |
| 127 | +``` |
| 128 | + |
| 129 | +## 🛠️ Available Tools |
| 130 | + |
| 131 | +### 🏗️ RDS Instance Management |
| 132 | +- `create_db_instance`: Create RDS instance |
| 133 | +- `describe_db_instances`: Query instances |
| 134 | +- `describe_db_instance_attribute`: Query detailed instance information |
| 135 | +- `modify_db_instance_description`: Modify RDS instance description |
| 136 | +- `modify_db_instance_spec`: Modify RDS instance specifications |
| 137 | +- `restart_db_instance`: Restart RDS instance |
| 138 | + |
| 139 | +### 🔒 Security & Access Control |
| 140 | +- `modify_security_ips`: Modify IP allowlist |
| 141 | +- `describe_db_instance_ip_allowlist`: Batch query IP allowlist configuration |
| 142 | +- `attach_whitelist_template_to_instance`: Bind allowlist template to instance |
| 143 | +- `describe_all_whitelist_template`: Query allowlist template list |
| 144 | +- `describe_instance_linked_whitelist_template`: Query allowlist templates bound to instances |
| 145 | + |
| 146 | +### 👥 Database & User Management |
| 147 | +- `create_db_instance_account`: Create RDS instance account |
| 148 | +- `describe_db_instance_accounts`: Batch query account information |
| 149 | +- `describe_db_instance_databases`: Batch query database information |
| 150 | + |
| 151 | +### 🌐 Network & Connection |
| 152 | +- `allocate_instance_public_connection`: Allocate public connection for RDS instance |
| 153 | +- `describe_db_instance_net_info`: Batch query network configuration details |
| 154 | +- `describe_vpcs`: Query VPC list |
| 155 | +- `describe_vswitches`: Query VSwitch list |
| 156 | + |
| 157 | +### 📊 Monitoring & Performance |
| 158 | +- `describe_db_instance_performance`: Query instance performance data |
| 159 | +- `describe_error_logs`: Query instance error logs |
| 160 | +- `describe_slow_log_records`: Query slow log records of RDS instance |
| 161 | +- `describe_db_instance_parameters`: Batch query parameter information |
| 162 | +- `modify_parameter`: Modify RDS instance parameters |
| 163 | + |
| 164 | +### 📦 Resource Management |
| 165 | +- `describe_available_classes`: Query available instance specifications and storage ranges |
| 166 | +- `describe_available_zones`: Query available zones for RDS instances |
| 167 | +- `add_tags_to_db_instance`: Add tags to RDS instance |
| 168 | + |
| 169 | +### 💰 Billing & Cost Management |
| 170 | +- `describe_bills`: Query user's consumption summary for all product instances or billing items within a specific billing cycle |
| 171 | + |
| 172 | +### 🔧 Utility Tools |
| 173 | +- `get_current_time`: Get current time |
| 174 | + |
| 175 | +## 💡 Usage Scenarios |
| 176 | + |
| 177 | +### Scenario 1: Resource Provisioning & Environment Initialization 🏗️ |
| 178 | + |
| 179 | +**Create a production RDS MySQL instance in Hangzhou region:** |
| 180 | +``` |
| 181 | +Create a production RDS MySQL instance in cn-hangzhou region with configuration, version, allowlist and other settings identical to instance rm-bp1696hd82oc438fl, and tag it with: production environment audit, release before month-end |
| 182 | +``` |
| 183 | + |
| 184 | +**Create read-only user account:** |
| 185 | +``` |
| 186 | +On instance rm-bp1696hd82oc438fl in cn-hangzhou region, create a read-only account readonly_user with password: Strong!Pa$$word and grant it read-only access to the report_db database. |
| 187 | +``` |
| 188 | + |
| 189 | +### Scenario 2: Security & Compliance Automation Audit 🔒 |
| 190 | + |
| 191 | +**Add bastion host IP to security group:** |
| 192 | +``` |
| 193 | +Immediately add the new bastion host IP 100.101.102.103 to the 'ops_allowlist' security group of all RDS MySQL instances in cn-hangzhou region. |
| 194 | +``` |
| 195 | + |
| 196 | +**Security compliance audit:** |
| 197 | +``` |
| 198 | +Audit all RDS SQL Server instances and find all instances in cn-hangzhou whose allowlist does not include IP 123.123.123.123 |
| 199 | +``` |
| 200 | + |
| 201 | +### Scenario 3: Cost Optimization 💰 |
| 202 | + |
| 203 | +**Performance-based cost optimization:** |
| 204 | +``` |
| 205 | +Analyze all RDS MySQL instances tagged as "test environment" in cn-hangzhou region over the past 3 days, identify those with average CPU utilization below 5%, and recommend more economical instance specifications. |
| 206 | +``` |
| 207 | + |
| 208 | +### Scenario 4: Common Operations & Maintenance 🔧 |
| 209 | + |
| 210 | +**Instance troubleshooting:** |
| 211 | +``` |
| 212 | +Instance rm-bp1696hd82oc438f in cn-hangzhou region is currently unreachable, please immediately attempt to restart this instance. |
| 213 | +``` |
| 214 | + |
| 215 | +## 🔌 Integration |
| 216 | + |
| 217 | +### Cherry Studio Integration (Recommended) 🍒 |
| 218 | + |
| 219 | +Cherry Studio is a cross-platform AI client that integrates multiple large language models, supporting AI conversations, drawing, and other features designed to enhance creative efficiency. |
| 220 | + |
| 221 | +Add the following configuration to your MCP client configuration file: |
| 222 | + |
| 223 | +```json |
| 224 | +{ |
| 225 | + "mcpServers": { |
| 226 | + "rds-openapi-mcp-server": { |
| 227 | + "command": "uvx", |
| 228 | + "args": [ |
| 229 | + "alibabacloud-rds-openapi-mcp-server@latest" |
| 230 | + ], |
| 231 | + "env": { |
| 232 | + "ALIBABA_CLOUD_ACCESS_KEY_ID": "your_access_id", |
| 233 | + "ALIBABA_CLOUD_ACCESS_KEY_SECRET": "your_access_key", |
| 234 | + "ALIBABA_CLOUD_SECURITY_TOKEN": "your_sts_token" |
| 235 | + } |
| 236 | + } |
| 237 | + } |
| 238 | +} |
| 239 | +``` |
| 240 | + |
| 241 | +<div align="left"> |
| 242 | + <img src="./import_mcp_cherry_en.png" alt="Cherry Studio Configuration Example" width="900" /> |
| 243 | +</div> |
| 244 | +*Configuring RDS MCP Server in Cherry Studio* |
| 245 | + |
| 246 | +<div align="left"> |
| 247 | + <img src="./cherry_studio_list_tools_en.png" alt="Available MCP Tools in Cherry Studio" width="900" /> |
| 248 | +</div> |
| 249 | +*Displaying all available tools in Cherry Studio* |
| 250 | + |
| 251 | +> 📝 **Note**: `ALIBABA_CLOUD_SECURITY_TOKEN` should only be filled when using STS Token. If using AccessKey method, please leave this value empty. |
| 252 | +
|
| 253 | +### Claude Desktop Integration 🤖 |
| 254 | + |
| 255 | +Add to your MCP client configuration: |
| 256 | + |
| 257 | +```json |
| 258 | +{ |
| 259 | + "mcpServers": { |
| 260 | + "rds-openapi-mcp-server": { |
| 261 | + "command": "uv", |
| 262 | + "args": [ |
| 263 | + "--directory", |
| 264 | + "d:/path/to/alibabacloud-rds-openapi-mcp-server/src/alibabacloud_rds_openapi_mcp_server", |
| 265 | + "run", |
| 266 | + "server.py" |
| 267 | + ], |
| 268 | + "env": { |
| 269 | + "ALIBABA_CLOUD_ACCESS_KEY_ID": "your_access_id", |
| 270 | + "ALIBABA_CLOUD_ACCESS_KEY_SECRET": "your_access_key", |
| 271 | + "ALIBABA_CLOUD_SECURITY_TOKEN": "your_sts_token" |
| 272 | + } |
| 273 | + } |
| 274 | + } |
| 275 | +} |
| 276 | +``` |
| 277 | + |
| 278 | +## 🤝 Contributing |
| 279 | + |
| 280 | +We welcome your contributions! Please follow these steps: |
| 281 | + |
| 282 | +1. 🍴 Fork this repository |
| 283 | +2. 🌟 Create a feature branch (`git checkout -b feature/amazing-feature`) |
| 284 | +3. 💾 Commit your changes (`git commit -m 'Add new feature'`) |
| 285 | +4. 📤 Push to the branch (`git push origin feature/amazing-feature`) |
| 286 | +5. 🔄 Create a Pull Request |
| 287 | + |
| 288 | +## 📄 License |
| 289 | + |
| 290 | +This project is licensed under the Apache 2.0 License |
| 291 | + |
| 292 | +## 💬 Support |
| 293 | + |
| 294 | +For questions, feedback, or support, please contact us through: |
| 295 | + |
| 296 | +- 💬 **DingTalk Group**: 106730017609 |
| 297 | +- 🐛 **GitHub Issues**: [Create Issue](https://github.com/aliyun/alibabacloud-rds-openapi-mcp-server/issues) |
| 298 | + |
| 299 | +### FAQ ❓ |
| 300 | + |
| 301 | +<details> |
| 302 | +<summary>How to obtain Alibaba Cloud AccessKey?</summary> |
| 303 | + |
| 304 | +1. Log in to Alibaba Cloud Console |
| 305 | +2. Click on the avatar in the upper right corner and select "AccessKey Management" |
| 306 | +3. Create a new AccessKey pair |
| 307 | +4. Keep your AccessKey Secret secure |
| 308 | + |
| 309 | +</details> |
| 310 | + |
| 311 | +<details> |
| 312 | +<summary>Which RDS database engines are supported?</summary> |
| 313 | + |
| 314 | +Currently supported: |
| 315 | +- MySQL |
| 316 | +- SQL Server |
| 317 | +- PostgreSQL |
| 318 | +- MariaDB |
| 319 | + |
| 320 | +</details> |
0 commit comments