Skip to content

Commit 3ba8c26

Browse files
authored
Merge pull request #7 from fdwills/feature/restart_db_instance
add restart instance tool
2 parents aa14304 + fd02ae4 commit 3ba8c26

File tree

3 files changed

+54
-1
lines changed

3 files changed

+54
-1
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,11 +102,12 @@ Add the following configuration to the MCP client configuration file:
102102
* `describe_slow_log_records`: Query slow log records for an RDS instance.
103103
* `describe_vpcs`: Query VPC list.
104104
* `describe_vswitches`: Query VSwitch list.
105-
* `modify_security_ips`: Modify security ips
105+
* `modify_security_ips`: Modify RDS instance security IP whitelist.
106106
* `get_current_time`: Get the current time.
107107
* `modify_db_instance_description`: Modify RDS instance descriptions.
108108
* `modify_db_instance_spec`: Modify RDS instance specifications.
109109
* `modify_parameter`: Modify RDS instance parameters.
110+
* `restart_db_instance`: Restart an RDS instance.
110111

111112
### Resources
112113
None at this time

README_CN.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ git clone https://github.com/aliyun/alibabacloud-rds-openapi-mcp-server.git
104104
* `modify_db_instance_description`: 修改RDS实例描述
105105
* `modify_db_instance_spec`: 修改RDS实例规格
106106
* `modify_parameter`: 修改RDS实例参数
107+
* `restart_db_instance`: 重启RDS实例
107108

108109
### 资源
109110
当前暂无资源

src/alibabacloud_rds_openapi_mcp_server/server.py

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1299,6 +1299,57 @@ async def modify_security_ips(
12991299
raise OpenAPIError(f"modify rds instance security ips failed: {str(e)}")
13001300

13011301

1302+
@mcp.tool()
1303+
async def restart_db_instance(
1304+
region_id: str,
1305+
dbinstance_id: str,
1306+
effective_time: str = "Immediate",
1307+
switch_time: str = None,
1308+
client_token: str = None
1309+
) -> Dict[str, Any]:
1310+
"""Restart an RDS instance.
1311+
1312+
Args:
1313+
region_id (str): The region ID of the RDS instance.
1314+
dbinstance_id (str): The ID of the RDS instance.
1315+
effective_time (str, optional): When to restart the instance. Options:
1316+
- Immediate: Restart immediately
1317+
- MaintainTime: Restart during maintenance window
1318+
- ScheduleTime: Restart at specified time
1319+
Default: Immediate
1320+
switch_time (str, optional): The scheduled restart time in format: yyyy-MM-ddTHH:mm:ssZ (UTC time).
1321+
Required when effective_time is ScheduleTime.
1322+
client_token (str, optional): Idempotency token, max 64 ASCII characters.
1323+
1324+
Returns:
1325+
Dict[str, Any]: Response containing the request ID.
1326+
"""
1327+
try:
1328+
# Initialize client
1329+
client = get_rds_client(region_id)
1330+
1331+
# Create request
1332+
request = rds_20140815_models.RestartDBInstanceRequest(
1333+
dbinstance_id=dbinstance_id
1334+
)
1335+
1336+
# Add optional parameters
1337+
if effective_time:
1338+
request.effective_time = effective_time
1339+
if switch_time:
1340+
request.switch_time = switch_time
1341+
if client_token:
1342+
request.client_token = client_token
1343+
1344+
# Make the API request
1345+
response = client.restart_dbinstance(request)
1346+
return response.body.to_map()
1347+
1348+
except Exception as e:
1349+
logger.error(f"Error occurred while restarting instance: {str(e)}")
1350+
raise OpenAPIError(f"Failed to restart RDS instance: {str(e)}")
1351+
1352+
13021353
def main():
13031354
mcp.run(transport=os.getenv('SERVER_TRANSPORT', 'stdio'))
13041355

0 commit comments

Comments
 (0)