Skip to main content
Glama
rainhan99

Cloud Manage MCP Server

by rainhan99

list_alibaba_instances

Retrieve and display all Alibaba Cloud ECS instances for inventory management and monitoring through the Cloud Manage MCP Server.

Instructions

列出所有阿里云ECS实例

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • Core handler logic for listing all Alibaba ECS instances using the Alibaba Cloud ECS SDK. Queries instances via describe_instances API, formats summaries, and returns structured list.
    def list_instances(self) -> Dict:
        """
        列出所有ECS实例
        
        Returns:
            Dict: 实例列表或错误信息
        """
        if not self.available:
            return {
                'error': f'阿里云服务不可用: {getattr(self, "error", "未知错误")}',
                'provider': 'alibaba'
            }
        
        try:
            request = ecs_models.DescribeInstancesRequest(
                region_id=self.region_id,
                page_size=100
            )
            
            response = self.client.describe_instances(request)
            
            instance_list = []
            if response.body.instances and response.body.instances.instance:
                for instance in response.body.instances.instance:
                    instance_info = self._format_instance_summary(instance)
                    instance_list.append(instance_info)
            
            return {
                'provider': 'alibaba',
                'region_id': self.region_id,
                'total_instances': len(instance_list),
                'instances': instance_list
            }
            
        except Exception as e:
            return {
                'error': f'列出ECS实例时发生错误: {str(e)}',
                'provider': 'alibaba'
            }
  • main.py:613-619 (registration)
    MCP tool registration for 'list_alibaba_instances'. Thin wrapper that delegates to alibaba_provider.list_instances().
    @mcp.tool()
    def list_alibaba_instances() -> Dict:
        """
        列出所有阿里云ECS实例
        """
        return alibaba_provider.list_instances()
  • Helper function to format individual instance summary data for inclusion in the list_instances response.
    def _format_instance_summary(self, instance) -> Dict:
        """格式化实例摘要信息"""
        # 获取主要公网IP
        primary_public_ip = None
        if hasattr(instance, 'eip_address') and instance.eip_address.ip_address:
            primary_public_ip = instance.eip_address.ip_address
        elif hasattr(instance, 'public_ip_address') and instance.public_ip_address:
            if instance.public_ip_address.ip_address:
                primary_public_ip = instance.public_ip_address.ip_address[0]
        
        # 获取主要私网IP
        primary_private_ip = None
        if hasattr(instance, 'vpc_attributes') and instance.vpc_attributes.private_ip_address:
            if instance.vpc_attributes.private_ip_address.ip_address:
                primary_private_ip = instance.vpc_attributes.private_ip_address.ip_address[0]
        elif hasattr(instance, 'inner_ip_address') and instance.inner_ip_address:
            if instance.inner_ip_address.ip_address:
                primary_private_ip = instance.inner_ip_address.ip_address[0]
        
        return {
            'instance_id': instance.instance_id,
            'name': instance.instance_name,
            'status': instance.status,
            'instance_type': instance.instance_type,
            'region_id': instance.region_id,
            'zone_id': instance.zone_id,
            'cpu': instance.cpu,
            'memory': instance.memory,
            'public_ip': primary_public_ip,
            'private_ip': primary_private_ip,
            'creation_time': instance.creation_time,
            'os_name': getattr(instance, 'osname', ''),
            'instance_charge_type': instance.instance_charge_type
        }
Behavior2/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. It states the tool lists instances but doesn't describe any behavioral traits such as whether it's read-only, safe to use, requires authentication, has rate limits, or what the output format entails. For a tool with zero annotation coverage, this is a significant gap in transparency.

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

Conciseness5/5

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

The description is a single, clear sentence in Chinese ('列出所有阿里云ECS实例') that directly states the tool's purpose without any unnecessary words. It is front-loaded and efficiently conveys the core action, making it highly concise and well-structured for its simplicity.

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

Completeness3/5

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

Given the tool's low complexity (0 parameters, output schema exists), the description is minimally adequate. It states what the tool does but lacks details on behavioral aspects, usage context, or output interpretation. With an output schema present, the description doesn't need to explain return values, but it should provide more guidance on when and how to use the tool effectively, especially compared to siblings.

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

Parameters4/5

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

The input schema has 0 parameters with 100% coverage, meaning there are no parameters to document. The description doesn't need to add parameter semantics, so it meets the baseline expectation. No additional information is required or provided, which is appropriate given the schema's completeness.

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

Purpose3/5

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

The description '列出所有阿里云ECS实例' clearly states the action (list) and resource (Alibaba Cloud ECS instances) in Chinese, making the purpose understandable. However, it doesn't distinguish this tool from sibling tools like 'list_aws_instances' or 'list_digitalocean_droplets' beyond specifying the provider, which is a basic differentiation but not fully explicit about unique scope or functionality compared to similar listing tools.

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

Usage Guidelines2/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 'get_alibaba_instance_info' for detailed information or 'get_instance_by_provider' for cross-provider queries. This lack of usage context leaves the agent without explicit direction.

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

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/rainhan99/cloud_manage_mcp_server'

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