Skip to main content
Glama
aliyun

AlibabaCloud MCP Server

Official
by aliyun

DescribeAccountAttributes

Retrieve ECS resource quotas and account attributes in a specified Alibaba Cloud region, including security groups, vCPU limits, network types, and real-name authentication status, to manage resource allocation effectively.

Instructions

查询您在一个阿里云地域下能创建的ECS资源配额。包括您能创建的安全组数量、弹性网卡数量、按量付费vCPU核数、抢占式实例vCPU核数、按量付费云盘总容量配额、专用宿主机数量、网络类型以及账号是否已完成实名认证。

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
AttributeNameNo查询某类资源在指定地域下的使用配额,N的取值范围为1~8。取值范围: - instance-network-type:可选择的网络类型。 - max-security-groups:安全组数量。 - max-elastic-network-interfaces:弹性网卡的数量。 - max-postpaid-instance-vcpu-count:按量付费实例的vCPU核数上限。 - max-spot-instance-vcpu-count:抢占式实例vCPU核数上限。 - used-postpaid-instance-vcpu-count:已使用按量付费实例的vCPU核数。 - used-spot-instance-vcpu-count:已使用抢占式实例vCPU核数。 - max-postpaid-yundisk-capacity:用作数据盘的按量付费云盘的总容量上限。(该参数值已弃用) - used-postpaid-yundisk-capacity:已使用的用作数据盘的按量付费云盘容量。(该参数值已弃用) - max-dedicated-hosts:专用宿主机数量。 - supported-postpaid-instance-types:按量付费I/O优化实例规格。 - max-axt-command-count:云助手命令的数量。 - max-axt-invocation-daily:每天可以执行的云助手命令次数。 - real-name-authentication:账号是否完成了实名认证。 > 您只有完成了实名认证才可以在中国内地地域中创建ECS实例。 - max-cloud-assistant-activation-count:可创建的云助手托管实例激活码数量上限。 默认值为空。 请注意,提供参数要严格按照参数的类型和参数示例的提示,如果提到参数为String,且为一个 JSON 数组字符串,应在数组内使用单引号包裹对应的参数以避免转义问题,并在最外侧用双引号包裹以确保其是字符串,否则可能会导致参数解析错误。参数类型: array,参数示例:max-security-groups
RegionIdYes地域ID。您可以调用[DescribeRegions](~~25609~~)查看最新的阿里云地域列表。 请注意,提供参数要严格按照参数的类型和参数示例的提示,如果提到参数为String,且为一个 JSON 数组字符串,应在数组内使用单引号包裹对应的参数以避免转义问题,并在最外侧用双引号包裹以确保其是字符串,否则可能会导致参数解析错误。参数类型: string,参数示例:cn-hangzhou
ZoneIdNo可用区ID。 请注意,提供参数要严格按照参数的类型和参数示例的提示,如果提到参数为String,且为一个 JSON 数组字符串,应在数组内使用单引号包裹对应的参数以避免转义问题,并在最外侧用双引号包裹以确保其是字符串,否则可能会导致参数解析错误。参数类型: string,参数示例:cn-hangzhou-b

Implementation Reference

  • Generic handler function that executes the Alibaba Cloud API call for 'DescribeAccountAttributes' and similar dynamically generated tools. It fetches API metadata, prepares the request, and calls the OpenAPI client.
    def _tools_api_call(service: str, api: str, parameters: dict, ctx: Context):
        service = service.lower()
        api_meta, _ = ApiMetaClient.get_api_meta(service, api)
        version = ApiMetaClient.get_service_version(service)
        method = 'POST' if api_meta.get('methods', [])[0] == 'post' else 'GET'
        path = api_meta.get('path', '/')
        style = ApiMetaClient.get_service_style(service)
        
        # Handling special parameter formats
        processed_parameters = parameters.copy()
        processed_parameters = {k: v for k, v in processed_parameters.items() if v is not None}
        if service == 'ecs':
            for param_name, param_value in parameters.items():
                if param_name in ECS_LIST_PARAMETERS and isinstance(param_value, list):
                    processed_parameters[param_name] = json.dumps(param_value)
        
        req = open_api_models.OpenApiRequest(
            query=OpenApiUtilClient.query(processed_parameters)
        )
        params = open_api_models.Params(
            action=api,
            version=version,
            protocol='HTTPS',
            pathname=path,
            method=method,
            auth_type='AK',
            style=style,
            req_body_type='formData',
            body_type='json'
        )
        logger.info(f'Call API Request: Service: {service} API: {api} Method: {method} Parameters: {processed_parameters}')
        client = create_client(service, processed_parameters.get('RegionId', 'cn-hangzhou'))
        runtime = util_models.RuntimeOptions()
        resp = client.call_api(params, req, runtime)
        logger.info(f'Call API Response: {resp}')
        return resp
  • Dynamically generates the input schema for the 'DescribeAccountAttributes' tool based on API metadata from Alibaba Cloud.
    def _create_function_schemas(service, api, api_meta):
        schemas = {}
        schemas[api] = {}
        parameters = api_meta.get('parameters', [])
    
        required_params = []
        optional_params = []
    
        for parameter in parameters:
            name = parameter.get('name')
            # TODO 目前忽略了带'.'的参数
            if '.' in name:
                continue
            schema = parameter.get('schema', '')
            required = schema.get('required', False)
    
            if required:
                required_params.append(parameter)
            else:
                optional_params.append(parameter)
    
        def process_parameter(parameter):
            name = parameter.get('name')
            schema = parameter.get('schema', '')
            description = schema.get('description', '')
            example = schema.get('example', '')
            type_ = schema.get('type', '')
            description = f'{description} 参数类型: {type_},参数示例:{example}'
            required = schema.get('required', False)
    
            if service.lower() == 'ecs' and name in ECS_LIST_PARAMETERS and type_ == 'string':
                python_type = list
            else:
                python_type = type_map.get(type_, str)
    
            field_info = (
                python_type,
                field(
                    default=None,
                    metadata={'description': description, 'required': required}
                )
            )
            return name, field_info
    
        for parameter in required_params:
            name, field_info = process_parameter(parameter)
            schemas[api][name] = field_info
    
        for parameter in optional_params:
            name, field_info = process_parameter(parameter)
            schemas[api][name] = field_info
    
        if 'RegionId' not in schemas[api]:
            schemas[api]['RegionId'] = (
                str,
                field(
                    default='cn-hangzhou',
                    metadata={'description': '地域ID', 'required': False}
                )
            )
        return schemas
  • Configuration listing 'DescribeAccountAttributes' as an available ECS tool, which triggers its dynamic registration.
    config = {
        'ecs': [
            'DescribeInstances',
            'DescribeRegions',
            'DescribeZones',
            'DescribeAccountAttributes',
            'DescribeAvailableResource',
            'DescribeImages',
            'DescribeSecurityGroups',
            'DeleteInstances'
        ],
        'Vpc': [
            'DescribeVpcs',
            'DescribeVSwitches'
        ],
        'rds': [
            'DescribeDBInstances'
        ]
    }
  • Dynamically creates and registers the tool named 'ECS_DescribeAccountAttributes' using FastMCP tool decorator.
    def _create_and_decorate_tool(mcp: FastMCP, service: str, api: str):
        """Create a tool function for an AlibabaCloud openapi."""
        api_meta, _ = ApiMetaClient.get_api_meta(service, api)
        fields = _create_function_schemas(service, api, api_meta).get(api, {})
        description = api_meta.get('summary', '')
        dynamic_lambda = _create_tool_function_with_signature(service, api, fields, description)
        function_name = f'{service.upper()}_{api}'
        decorated_function = mcp.tool(name=function_name)(dynamic_lambda)
    
        return decorated_function
  • Invokes the creation and registration of all tools listed in config, including 'DescribeAccountAttributes' for ECS.
    api_tools.create_api_tools(mcp, config)

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-core-mcp-server'

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