Skip to main content
Glama
aliyun

Alibaba Cloud RDS OpenAPI MCP Server

Official
by aliyun

attach_whitelist_template_to_instance

Apply a security whitelist template to an Alibaba Cloud RDS database instance to manage network access permissions.

Instructions

allocate db instance public connection.
Args:
    region_id: The region ID of the RDS instance.
    db_instance_id: The ID of the RDS instance.
    template_id: Whitelist Template ID. Can be obtained via DescribeAllWhitelistTemplate.
Returns:
    dict[str, Any]: The response.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
region_idYes
db_instance_idYes
template_idYes

Implementation Reference

  • The core handler function implementing the attach_whitelist_template_to_instance MCP tool. It calls the Alibaba Cloud RDS AttachWhitelistTemplateToInstance API to attach a specified whitelist template to a DB instance.
    async def attach_whitelist_template_to_instance(
            region_id: str,
            db_instance_id: str,
            template_id: int
    ):
        """
        allocate db instance public connection.
        Args:
            region_id: The region ID of the RDS instance.
            db_instance_id: The ID of the RDS instance.
            template_id: Whitelist Template ID. Can be obtained via DescribeAllWhitelistTemplate.
        Returns:
            dict[str, Any]: The response.
        """
        try:
            client = get_rds_client(region_id)
            request = rds_20140815_models.AttachWhitelistTemplateToInstanceRequest(
                region_id=region_id,
                ins_name=db_instance_id,
                template_id=template_id
            )
            response = await client.attach_whitelist_template_to_instance_async(request)
            return response.body.to_map()
        except Exception as e:
            raise e
  • Helper tool to describe all whitelist templates, used to obtain template_id for attachment.
    async def describe_all_whitelist_template(
            region_id: str,
            template_name: str = None
    ) -> List[Dict[str, Any]]:
        """
        describe all whitelist template.
        Args:
            region_id: The region ID of the RDS instance.
            template_name: The ID of the RDS instance.
        Returns:
            List[Dict[str, Any]]: The response contains all whitelist template information.
        """
        try:
            client = get_rds_client(region_id)
            next_pages = True
            all_whitelists = []
            page_num = 1
            while next_pages:
                request = rds_20140815_models.DescribeAllWhitelistTemplateRequest(
                    template_name=template_name,
                    fuzzy_search=False if template_name is None else True,
                    max_records_per_page=100,
                    page_numbers=page_num
                )
                response = await client.describe_all_whitelist_template_async(request)
                next_pages = response.body.data.has_next
                page_num += 1
                all_whitelists.extend(response.body.data.templates)
            return [item.to_map() for item in all_whitelists]
        except Exception as e:
            raise e
  • Helper tool to describe the whitelist template currently linked to an instance.
    async def describe_instance_linked_whitelist_template(
            region_id: str,
            db_instance_id: str
    ):
        """
        describe instance linked whitelist template.
        Args:
            region_id: The region ID of the RDS instance.
            db_instance_id: The ID of the RDS instance.
        Returns:
            dict[str, Any]: The response.
        """
        try:
            client = get_rds_client(region_id)
            request = rds_20140815_models.DescribeInstanceLinkedWhitelistTemplateRequest(
                region_id=region_id,
                ins_name=db_instance_id
            )
            response = await client.describe_instance_linked_whitelist_template_async(request)
            return response.body.to_map()
        except Exception as e:
            raise e

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/aliyun/alibabacloud-rds-openapi-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server