Skip to main content
Glama
aliyun

Alibaba Cloud MCP Server

Official
by aliyun

DescribeVSwitches

Retrieve detailed information about VSwitches within Alibaba Cloud VPCs, including ID, name, zone, and region, to facilitate network planning and configuration.

Instructions

查询可组网的信息,内网按vswitch进行组网。

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
DryRunNo是否只预检此次请求。取值: - **true**:发送检查请求,不会创建资源(接口功能)。检查项包括是否填写了必需参数、请求格式、业务限制。如果检查不通过,则返回对应错误。如果检查通过,则返回错误码`DryRunOperation`。 - **false**(默认值):发送正常请求,通过检查后返回HTTP 2xx状态码并直接进行操作。 请注意,提供参数要严格按照参数的类型和参数示例的提示,如果提到参数为String,且为一个 JSON 数组字符串,应在数组内使用单引号包裹对应的参数以避免转义问题,并在最外侧用双引号包裹以确保其是字符串,否则可能会导致参数解析错误。参数类型: boolean,参数示例:true
EnableIpv6No是否查询指定地域下开启IPv6网段的交换机,取值: - **true**:查询指定地域下开启IPv6网段的交换机。 - **false**:不查询指定地域下开启IPv6网段的交换机。 如果不传入该参数,系统默认查询指定地域下的所有交换机。 请注意,提供参数要严格按照参数的类型和参数示例的提示,如果提到参数为String,且为一个 JSON 数组字符串,应在数组内使用单引号包裹对应的参数以避免转义问题,并在最外侧用双引号包裹以确保其是字符串,否则可能会导致参数解析错误。参数类型: boolean,参数示例:false
IsDefaultNo是否查询指定地域下的默认交换机,取值: - **true**:查询指定地域下的默认交换机。 - **false**:不查询指定地域下的默认交换机。 如果不传入该参数,系统默认查询指定地域下的所有交换机。 请注意,提供参数要严格按照参数的类型和参数示例的提示,如果提到参数为String,且为一个 JSON 数组字符串,应在数组内使用单引号包裹对应的参数以避免转义问题,并在最外侧用双引号包裹以确保其是字符串,否则可能会导致参数解析错误。参数类型: boolean,参数示例:true
PageNumberNo 列表的页码,默认值为**1**。 请注意,提供参数要严格按照参数的类型和参数示例的提示,如果提到参数为String,且为一个 JSON 数组字符串,应在数组内使用单引号包裹对应的参数以避免转义问题,并在最外侧用双引号包裹以确保其是字符串,否则可能会导致参数解析错误。参数类型: integer,参数示例:1
PageSizeNo 分页查询时每页的行数,最大值为**50**。默认值为**10**。 请注意,提供参数要严格按照参数的类型和参数示例的提示,如果提到参数为String,且为一个 JSON 数组字符串,应在数组内使用单引号包裹对应的参数以避免转义问题,并在最外侧用双引号包裹以确保其是字符串,否则可能会导致参数解析错误。参数类型: integer,参数示例:10
RegionIdNo交换机所属地域的ID。您可以通过调用[DescribeRegions](~~36063~~)接口获取地域ID。 > **RegionId**和**VpcId**参数至少输入一个。 请注意,提供参数要严格按照参数的类型和参数示例的提示,如果提到参数为String,且为一个 JSON 数组字符串,应在数组内使用单引号包裹对应的参数以避免转义问题,并在最外侧用双引号包裹以确保其是字符串,否则可能会导致参数解析错误。参数类型: string,参数示例:cn-hangzhou
ResourceGroupIdNo交换机所属的资源组ID。 请注意,提供参数要严格按照参数的类型和参数示例的提示,如果提到参数为String,且为一个 JSON 数组字符串,应在数组内使用单引号包裹对应的参数以避免转义问题,并在最外侧用双引号包裹以确保其是字符串,否则可能会导致参数解析错误。参数类型: string,参数示例:rg-bp67acfmxazb4ph****
RouteTableIdNo路由表的ID。 请注意,提供参数要严格按照参数的类型和参数示例的提示,如果提到参数为String,且为一个 JSON 数组字符串,应在数组内使用单引号包裹对应的参数以避免转义问题,并在最外侧用双引号包裹以确保其是字符串,否则可能会导致参数解析错误。参数类型: string,参数示例:vtb-bp145q7glnuzdvzu2****
TagNo资源的标签。 请注意,提供参数要严格按照参数的类型和参数示例的提示,如果提到参数为String,且为一个 JSON 数组字符串,应在数组内使用单引号包裹对应的参数以避免转义问题,并在最外侧用双引号包裹以确保其是字符串,否则可能会导致参数解析错误。参数类型: array,参数示例:
VSwitchIdNo要查询的交换机的ID。 请注意,提供参数要严格按照参数的类型和参数示例的提示,如果提到参数为String,且为一个 JSON 数组字符串,应在数组内使用单引号包裹对应的参数以避免转义问题,并在最外侧用双引号包裹以确保其是字符串,否则可能会导致参数解析错误。参数类型: string,参数示例:vsw-23dscddcffvf3****
VSwitchNameNo交换机的名称。 名称长度为1~128个字符,不能以`http://`或`https://`开头。 请注意,提供参数要严格按照参数的类型和参数示例的提示,如果提到参数为String,且为一个 JSON 数组字符串,应在数组内使用单引号包裹对应的参数以避免转义问题,并在最外侧用双引号包裹以确保其是字符串,否则可能会导致参数解析错误。参数类型: string,参数示例:vSwitch
VSwitchOwnerIdNo资源归属的阿里云账号ID。 请注意,提供参数要严格按照参数的类型和参数示例的提示,如果提到参数为String,且为一个 JSON 数组字符串,应在数组内使用单引号包裹对应的参数以避免转义问题,并在最外侧用双引号包裹以确保其是字符串,否则可能会导致参数解析错误。参数类型: integer,参数示例:2546073170691****
VpcIdNo要查询的交换机所属VPC的ID。 > **RegionId**和**VpcId**参数至少输入一个。 请注意,提供参数要严格按照参数的类型和参数示例的提示,如果提到参数为String,且为一个 JSON 数组字符串,应在数组内使用单引号包裹对应的参数以避免转义问题,并在最外侧用双引号包裹以确保其是字符串,否则可能会导致参数解析错误。参数类型: string,参数示例:vpc-25cdvfeq58pl****
ZoneIdNo交换机所属可用区的ID。您可以通过调用[DescribeZones](~~36064~~)接口获取可用区ID。 请注意,提供参数要严格按照参数的类型和参数示例的提示,如果提到参数为String,且为一个 JSON 数组字符串,应在数组内使用单引号包裹对应的参数以避免转义问题,并在最外侧用双引号包裹以确保其是字符串,否则可能会导致参数解析错误。参数类型: string,参数示例:cn-hangzhou-d

Implementation Reference

  • Configuration entry listing 'DescribeVSwitches' as one of the APIs/tools to register for the VPC service.
    'Vpc': [
        'DescribeVpcs',
        'DescribeVSwitches'
    ],
  • Iterates over the config to dynamically register tools like DescribeVSwitches by calling _create_and_decorate_tool for each service API pair.
    def create_api_tools(mcp: FastMCP, config:dict):
        for service_code, apis in config.items():
            for api_name in apis:
                _create_and_decorate_tool(mcp, service_code, api_name)
  • Core handler logic executed by the dynamic tool for DescribeVSwitches: fetches API metadata, constructs request, calls Alibaba Cloud OpenAPI client, and returns response.
    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 DescribeVSwitches tool based on Alibaba Cloud API metadata.
    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
  • Helper that creates and registers the dynamic tool handler for specific APIs like DescribeVSwitches, naming it 'VPC_DESCRIBEVSWITCHES'.
    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
Behavior1/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden of behavioral disclosure. The description fails to disclose any behavioral traits—it doesn't indicate that this is a read-only query operation, whether it requires authentication, any rate limits, pagination behavior (implied by PageNumber/PageSize parameters but not stated), or what the output looks like. For a tool with 14 parameters and no annotations, this is a significant gap.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness2/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, vague sentence that doesn't front-load key information. It's under-specified rather than concise—it wastes space by not clearly stating the tool's purpose or usage. While short, it fails to communicate effectively, so it scores low for structure and clarity.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness1/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the complexity (14 parameters, no annotations, no output schema), the description is completely inadequate. It doesn't explain what the tool returns, how to interpret results, or any behavioral context. The schema covers parameters well, but the description fails to provide the necessary overview, usage context, or output expectations, leaving significant gaps for an AI agent.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The input schema has 100% description coverage, with detailed parameter documentation in Chinese. The description adds no parameter semantics beyond what the schema provides—it doesn't explain any parameters, their interactions (e.g., RegionId vs. VpcId), or usage examples. Given the high schema coverage, the baseline score of 3 is appropriate, as the schema does the heavy lifting.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose2/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description '查询可组网的信息,内网按vswitch进行组网' translates to 'Query information that can be networked, internal network networking by vswitch.' This is vague and tautological—it essentially restates the tool name 'DescribeVSwitches' in Chinese without specifying what the tool actually does. It doesn't clearly state that this tool lists or describes virtual switches (VSwitches) in a cloud network, nor does it differentiate from siblings like DescribeVpcs or DescribeSecurityGroups.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines1/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention any prerequisites, context for usage, or comparisons to sibling tools like DescribeVpcs or DescribeSecurityGroups. There is no explicit or implied usage guidance beyond the vague statement about networking.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Related Tools

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

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