describe_vswitches
Query and list available vSwitches in Alibaba Cloud VPCs to manage network segmentation and connectivity.
Instructions
查询交换机列表
Args:
region: 区域ID,如cn-beijing
vpc_id: VPC ID(可选)
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| region | No | cn-beijing | |
| vpc_id | No |
Implementation Reference
- complete_fastmcp_server.py:185-207 (handler)The primary handler and registration for the 'describe_vswitches' tool. It is a wrapper that searches for and invokes a vswitch-related function from common_api_tools.tools, passing RegionId and optional VpcId.@app.tool() def describe_vswitches(region: str = "cn-beijing", vpc_id: Optional[str] = None) -> str: """查询交换机列表 Args: region: 区域ID,如cn-beijing vpc_id: VPC ID(可选) """ try: sys.path.insert(0, os.path.join(os.path.dirname(__file__), 'alibaba_cloud_ops_mcp_server')) from tools import common_api_tools for tool_func in common_api_tools.tools: if hasattr(tool_func, '__name__') and 'vswitch' in tool_func.__name__.lower(): kwargs = {'RegionId': region} if vpc_id: kwargs['VpcId'] = vpc_id result = tool_func(**kwargs) return str(result) return f"交换机查询功能可用,查询region: {region}" except Exception as e: return f"交换机查询失败: {str(e)}"
- alibaba_cloud_ops_mcp_server/config.py:18-21 (registration)Configuration defining the 'DescribeVSwitches' API for the VPC service, used to dynamically generate the underlying API tool implementation.'Vpc': [ 'DescribeVpcs', 'DescribeVSwitches' ],
- Invocation of create_api_tools which uses the config to generate and register dynamic tool functions, including one for DescribeVSwitches.api_tools.create_api_tools(mcp, config)
- Dynamic tool generator that creates FastMCP tools for each API in config, such as VPC_DESCRIBEVSWITCHES, which provides the core API call logic via _tools_api_call.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)