关于 Alibaba Cloud RDS OpenAPI MCP Server
配置
本地服务的配置在各客户端中通用,复制后粘贴到客户端的 MCP 配置文件即可。
工具
本地服务需要在你的电脑上运行后才能读取工具,维护者暂未提供工具列表。
详细介绍
English | 中文
Alibaba Cloud RDS OpenAPI MCP 服务
通过 OPENAPI 为 RDS 服务提供 MCP 服务
先决条件
- 从 Astral 或 GitHub README 安装
uv - 使用
uv python install 3.12安装 Python - 拥有可访问 Alibaba Cloud RDS 服务的 Alibaba Cloud 凭据
快速开始
使用 cherry-studio(推荐)
- 下载并安装 cherry-studio
- 按照文档安装 MCP 环境所需的 uv
- 按照文档配置并使用 RDS MCP。你可以使用以下 JSON 快速导入 RDS MCP 配置。请将 ALIBABA_CLOUD_ACCESS_KEY_ID 和 ALIBABA_CLOUD_ACCESS_KEY_SECRET 设置为你的 Alibaba Cloud AK/SK。
导入时可能会出现以下错误,可以忽略: xxx settings.mcp.addServer.importFrom.connectionFailed
{
"mcpServers": {
"rds-openapi": {
"name": "rds-openapi",
"type": "stdio",
"description": "",
"isActive": true,
"registryUrl": "",
"command": "uvx",
"args": [
"alibabacloud-rds-openapi-mcp-server@latest"
],
"env": {
"ALIBABA_CLOUD_ACCESS_KEY_ID": "$you_access_id",
"ALIBABA_CLOUD_ACCESS_KEY_SECRET": "$you_access_key"
}
}
}
}
-
最后,点击开启 MCP
-
你可以使用下面提供的提示词模板来提升使用体验。
使用 Cline
设置环境变量并运行 MCP 服务。
# set env
export SERVER_TRANSPORT=sse;
export SERVER_HOST=127.0.0.1; # Default: 127.0.0.1. API_KEY is required when binding to a non-loopback host.
export ALIBABA_CLOUD_ACCESS_KEY_ID=$you_access_id;
export ALIBABA_CLOUD_ACCESS_KEY_SECRET=$you_access_key;
export ALIBABA_CLOUD_SECURITY_TOKEN=$you_sts_security_token; # optional, required when using STS Token
export API_KEY=$you_mcp_server_api_key; # Required when SERVER_HOST is not a loopback address.
export ENABLE_WRITE_TOOLS=false; # Set true only when intentionally exposing write-capable tools on a non-loopback host.
export ALLOW_HEADER_CREDENTIALS=false; # Default false. Set true only in trusted deployments that require per-request credentials.
# run mcp server
uvx alibabacloud-rds-openapi-mcp-server@latest
运行 MCP 服务后,你将看到以下输出:
INFO: Started server process [91594]
INFO: Waiting for application startup.
INFO: Application startup complete.
INFO: Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit)
然后配置 Cline。
remote_server = "http://127.0.0.1:8000/sse";
配置 API_KEY 后,MCP 客户端必须发送 Authorization: Bearer <API_KEY>。
如果使用 Qwen 时遇到
401 Incorrect API key provided错误,请参阅文档获取解决方案。
使用 Claude
从 Github 下载
git clone https://github.com/aliyun/alibabacloud-rds-openapi-mcp-server.git
将以下配置添加到 MCP 客户端配置文件中:
{
"mcpServers": {
"rds-openapi-mcp-server": {
"command": "uv",
"args": [
"--directory",
"/path/to/alibabacloud-rds-openapi-mcp-server/src/alibabacloud_rds_openapi_mcp_server",
"run",
"server.py"
],
"env": {
"ALIBABA_CLOUD_ACCESS_KEY_ID": "access_id",
"ALIBABA_CLOUD_ACCESS_KEY_SECRET": "access_key",
"ALIBABA_CLOUD_SECURITY_TOKEN": "sts_security_token",
// optional, required when using STS Token
}
}
}
}
组件
OpenAPI 工具
add_tags_to_db_instance:为 RDS 实例添加标签。allocate_instance_public_connection:为 RDS 实例分配公网连接。attach_whitelist_template_to_instance:为 RDS 实例关联白名单模板。create_db_instance:创建 RDS 实例。create_db_instance_account:为 RDS 实例创建账号。describe_all_whitelist_template:查询白名单模板列表。describe_available_classes:查询可用实例规格和存储范围。describe_available_zones:查询 RDS 实例的可用区。describe_bills:查询用户在特定账期内所有产品实例或计费项的消费汇总。describe_db_instance_accounts:批量获取多个 RDS 实例的账号信息。describe_db_instance_attribute:查询实例详情。describe_db_instance_databases:批量获取多个 RDS 实例的数据库信息。describe_db_instance_ip_allowlist:批量获取多个 RDS 实例的 IP 白名单配置。describe_db_instance_net_info:批量获取多个 RDS 实例的网络配置详情。describe_db_instance_parameters:批量获取多个 RDS 实例的参数信息。describe_db_instance_performance:查询实例的性能数据。describe_db_instances:查询实例。describe_error_logs:查询实例的错误日志。describe_instance_linked_whitelist_template:查询白名单模板列表。describe_monitor_metrics:使用 DAS(数据库自治服务)API 查询实例的性能和诊断指标。describe_slow_log_records:查询 RDS 实例的慢日志记录。describe_sql_insight_statistic:查询 SQL 日志统计信息,包括 SQL 耗时、执行次数和账号。describe_vpcs:查询 VPC 列表。describe_vswitches:查询 VSwitch 列表。modify_security_ips:修改 RDS 实例安全 IP 白名单。get_current_time:获取当前时间。modify_db_instance_description:修改 RDS 实例描述。modify_db_instance_spec:修改 RDS 实例规格。modify_parameter:修改 RDS 实例参数。restart_db_instance:重启 RDS 实例。
SQL 工具
MCP 服务会自动创建只读账号、执行 SQL 语句,然后自动删除该账号。此过程要求 MCP 服务能够连接到实例。
explain_sql:对单条SELECT语句执行EXPLAIN并返回执行计划。show_engine_innodb_status:执行 sqlshow engine innodb status并返回 sql 结果。show_create_table:对经过验证的数据库和表标识符执行SHOW CREATE TABLE。show_largest_table:查询空间占用最高的前几张表。show_largest_table_fragment:查询表碎片最多的表。query_sql:执行单条只读 SQL 语句(SELECT、SHOW、DESCRIBE或EXPLAIN)并返回 sql 结果。
工具集
工具集将可用的 MCP 工具分组,让你只启用所需工具。启动服务时,可通过以下方式配置工具集:
- 命令行:
--toolsets参数 - 环境变量:
MCP_TOOLSETS
可用工具集
以下是工具集及其功能列表:
-
rds:启用标准托管式 RDS 服务的所有工具
-
rds_custom_read:启用 RDS Custom 的只读工具。
-
rds_custom_all:启用 RDS Custom 的所有读写工具。
格式
使用逗号分隔工具集名称(逗号两侧不加空格):
rds,rds_custom_all
示例
# Single toolset
--toolsets rds
# Multiple tools
--toolsets rds,rds_mssql_custom
# Environment variable
export MCP_TOOLSETS=rds,rds_custom_all
默认行为
如果未指定工具集,则会自动加载默认的 rds 组。
资源
目前没有
技能
本项目支持通过技能扩展 RDS Copilot 的能力。现有两项技能:
- alibabacloud-rds-copilot:调用 RDS AI Assistant API,提供智能问答、SQL 优化和故障排查功能。
- alibabacloud-rds-instances-manage:将本项目的 OpenAPI 工具和 SQL 工具封装为可供 OpenClaw、Claude Code 等平台使用的 脚本/CLI。模型通过运行
alibabacloud-rds-instances-manage list和alibabacloud-rds-instances-manage run <tool_name> '<JSON args>'管理 RDS 实例(查询实例、监控、慢日志、参数、执行只读 SQL 等)。安装软件包后,即可使用alibabacloud-rds-instances-manage命令;技能目录为skill/alibabacloud-rds-instances-manage/。
有关如何使用技能的详细信息,请参阅:技能文档
提示词
# Role
You are a professional Alibaba Cloud RDS Copilot, specializing in providing customers with efficient technical support and solutions for RDS (Relational Database Service). Your goal is to help customers resolve issues quickly through clear problem decomposition, precise tool invocation, and accurate time calculations.
## Skills
### Skill 1: Problem Decomposition and Analysis
- Deeply deconstruct user questions to identify core requirements and potential steps/commands involved.
- Provide clear task breakdowns to ensure each step contributes to the final solution.
- Please organize your answers in a table format as much as possible.
### Skill 2: RDS MCP Tool Invocation
- Proficiently invoke the RDS MCP tool to retrieve database information or execute operations.
- Tool invocation must follow task decomposition and align with logical reasoning and customer needs.
- Select appropriate MCP modules (e.g., monitoring data queries, performance diagnostics, backup/recovery) based on user requirements.
### Skill 3: Time Interpretation and Calculation
- Accurately parse relative time concepts like "today," "yesterday," or "the last hour."
- Convert relative time expressions into precise time ranges or timestamps using the current time to support data queries or operations.
## Constraints
- **Task Decomposition First**: Always provide detailed task breakdowns.
- **Tool Dependency Clarity**: All MCP tool invocations must be justified by clear task requirements and logical reasoning.
- **Time Precision**: Calculate exact time ranges for time-sensitive queries.
- **Professional Focus**: Discuss only Alibaba Cloud RDS-related technical topics.
- **Safety Awareness**: Ensure no operations negatively impact customer databases.
安全部署指南
请勿将 MCP 端点暴露到公共互联网。服务器可以调用 Alibaba Cloud RDS OpenAPI 工具,并且可能会使用敏感的云凭证,因此面向互联网的 MCP 端点可能带来严重的安全风险。
强烈建议仅在本地环回地址上运行 MCP 服务:
export SERVER_HOST=127.0.0.1
如果必须使用非环回地址,请将其限制在可信的私有网络内,实施网络访问控制,配置 API_KEY,并避免启用具有写入能力的工具,除非确有需要。
贡献
欢迎贡献!欢迎提交 Pull Request。
- 复刻此代码仓库
- 创建功能分支(
git checkout -b feature/amazing-feature) - 提交更改(
git commit -m 'Add some amazing feature') - 将更改推送到该分支(
git push origin feature/amazing-feature) - 创建 Pull Request
许可证
本项目采用 Apache 2.0 许可证。
联系方式
如有任何问题或疑虑,请通过钉钉群联系我们:106730017609

评论
一个开放协议,规定了 AI 应用如何以统一方式连接外部工具与数据源。客户端负责与模型对话,MCP 服务负责提供工具、资源和提示模板,两者通过标准消息通信,同一个服务可以被不同客户端复用。