Skip to content

Commit 5ff2084

Browse files
authored
Merge pull request #6 from fdwills/feature/modify_security_ips
add new tool modify_security_ips
2 parents e188fdf + f7d0c17 commit 5ff2084

File tree

3 files changed

+66
-0
lines changed

3 files changed

+66
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ 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
105106
* `get_current_time`: Get the current time.
106107
* `modify_db_instance_description`: Modify RDS instance descriptions.
107108
* `modify_db_instance_spec`: Modify RDS instance specifications.

README_CN.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ git clone https://github.com/aliyun/alibabacloud-rds-openapi-mcp-server.git
9898
* `describe_instance_linked_whitelist_template`: 查询绑定到实例的白名单模板列表
9999
* `describe_slow_log_records`: 查询RDS实例的慢日志记录
100100
* `describe_vpcs`: 查询VPC列表
101+
* `modify_security_ips`: 修改白名单
101102
* `describe_vswitches`: 查询VSwitch列表
102103
* `get_current_time`: 获取当前时间
103104
* `modify_db_instance_description`: 修改RDS实例描述

src/alibabacloud_rds_openapi_mcp_server/server.py

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1235,6 +1235,70 @@ async def get_current_time() -> Dict[str, Any]:
12351235
raise Exception(f"Failed to get the current time: {str(e)}")
12361236

12371237

1238+
@mcp.tool()
1239+
async def modify_security_ips(
1240+
region_id: str,
1241+
dbinstance_id: str,
1242+
security_ips: str,
1243+
whitelist_network_type: str = "MIX",
1244+
security_ip_type: str = None,
1245+
dbinstance_ip_array_name: str = None,
1246+
dbinstance_ip_array_attribute: str = None,
1247+
client_token: str = None
1248+
) -> Dict[str, Any]:
1249+
"""modify security ips。
1250+
1251+
Args:
1252+
region_id (str): RDS instance region id.
1253+
dbinstance_id (str): RDS instance id.
1254+
security_ips (str): security ips list, separated by commas.
1255+
whitelist_network_type (str, optional): whitelist network type.
1256+
- MIX: mixed network type
1257+
- Classic: classic network
1258+
- VPC: vpc
1259+
default value: MIX
1260+
security_ip_type (str, optional): security ip type.
1261+
- normal: normal security ip
1262+
- hidden: hidden security ip
1263+
dbinstance_ip_array_name (str, optional): security ip array name.
1264+
dbinstance_ip_array_attribute (str, optional): security ip array attribute.
1265+
- hidden: hidden security ip
1266+
- normal: normal security ip
1267+
client_token (str, optional): idempotency token, max 64 ascii characters.
1268+
1269+
Returns:
1270+
Dict[str, Any]: response contains request id.
1271+
"""
1272+
try:
1273+
# initialize client
1274+
client = get_rds_client(region_id)
1275+
1276+
# create request
1277+
request = rds_20140815_models.ModifySecurityIpsRequest(
1278+
dbinstance_id=dbinstance_id,
1279+
security_ips=security_ips,
1280+
whitelist_network_type=whitelist_network_type
1281+
)
1282+
1283+
# add optional parameters
1284+
if security_ip_type:
1285+
request.security_ip_type = security_ip_type
1286+
if dbinstance_ip_array_name:
1287+
request.dbinstance_ip_array_name = dbinstance_ip_array_name
1288+
if dbinstance_ip_array_attribute:
1289+
request.dbinstance_ip_array_attribute = dbinstance_ip_array_attribute
1290+
if client_token:
1291+
request.client_token = client_token
1292+
1293+
# send api request
1294+
response = client.modify_security_ips(request)
1295+
return response.body.to_map()
1296+
1297+
except Exception as e:
1298+
logger.error(f"modify security ips error: {str(e)}")
1299+
raise OpenAPIError(f"modify rds instance security ips failed: {str(e)}")
1300+
1301+
12381302
def main():
12391303
mcp.run(transport=os.getenv('SERVER_TRANSPORT', 'stdio'))
12401304

0 commit comments

Comments
 (0)