Skip to main content
Glama
rainhan99

Cloud Manage MCP Server

by rainhan99

list_aws_instances

Retrieve and display all AWS EC2 instances to monitor cloud infrastructure and manage resources effectively.

Instructions

列出所有AWS EC2实例

Returns:
    Dict: AWS实例列表

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • Core handler function in AWSProvider class that lists all EC2 instances using boto3's describe_instances API, formats them, and returns a dictionary with instance summaries.
    def list_instances(self) -> Dict:
        """
        列出所有EC2实例
        
        Returns:
            Dict: 实例列表或错误信息
        """
        if not self.available:
            return {
                'error': f'AWS服务不可用: {getattr(self, "error", "未知错误")}',
                'provider': 'aws'
            }
        
        try:
            response = self.ec2.describe_instances()
            
            instances = []
            for reservation in response['Reservations']:
                for instance in reservation['Instances']:
                    instance_info = self._format_instance_summary(instance)
                    instances.append(instance_info)
            
            return {
                'provider': 'aws',
                'region': self.region,
                'total_instances': len(instances),
                'instances': instances
            }
            
        except ClientError as e:
            return {
                'error': f'AWS API调用失败: {str(e)}',
                'provider': 'aws'
            }
        except Exception as e:
            return {
                'error': f'列出EC2实例时发生错误: {str(e)}',
                'provider': 'aws'
            }
  • main.py:368-377 (registration)
    Registers the MCP tool 'list_aws_instances' with @mcp.tool() decorator. This wrapper function delegates to the aws_provider.list_instances() method.
    @mcp.tool()
    def list_aws_instances() -> Dict:
        """
        列出所有AWS EC2实例
        
        Returns:
            Dict: AWS实例列表
        """
        return aws_provider.list_instances()
  • Helper method used by list_instances to format each instance into a summary dictionary, extracting key fields like ID, name, state, IPs, etc.
    def _format_instance_summary(self, instance: Dict) -> Dict:
        """格式化实例摘要信息"""
        # 获取名称标签
        name = '未命名'
        for tag in instance.get('Tags', []):
            if tag['Key'] == 'Name':
                name = tag['Value']
                break
        
        return {
            'instance_id': instance.get('InstanceId'),
            'name': name,
            'instance_type': instance.get('InstanceType'),
            'state': instance.get('State', {}).get('Name'),
            'public_ip': instance.get('PublicIpAddress'),
            'private_ip': instance.get('PrivateIpAddress'),
            'availability_zone': instance.get('Placement', {}).get('AvailabilityZone'),
            'launch_time': instance.get('LaunchTime').isoformat() if instance.get('LaunchTime') else None
        }
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It mentions returning a dictionary of AWS instances but doesn't cover critical aspects like whether this is a read-only operation, potential rate limits, authentication needs, or error handling. This is a significant gap for a tool that likely interacts with cloud resources.

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

Conciseness3/5

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

The description is brief with two sentences, but it's not optimally structured. The first sentence states the purpose, and the second redundantly notes the return type (which is already covered by the output schema). It could be more front-loaded with key behavioral insights.

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 simplicity (0 parameters, output schema exists) and lack of annotations, the description is minimally adequate. However, it misses opportunities to explain scope (e.g., all regions vs. current region), filtering options, or how it differs from sibling tools, leaving gaps in contextual understanding.

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, so no parameter documentation is needed. The description doesn't add parameter details, which is appropriate here, but it could have mentioned any implicit assumptions (e.g., region or credential context). Baseline is 4 for zero parameters.

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

Purpose4/5

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

The description clearly states the verb ('列出' meaning 'list') and resource ('AWS EC2实例'), making the purpose unambiguous. However, it doesn't differentiate from sibling tools like 'list_alibaba_instances' or 'list_digitalocean_droplets' beyond specifying AWS EC2, which is somewhat helpful but not explicit about scope distinctions.

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?

No guidance is provided on when to use this tool versus alternatives like 'get_aws_instance_info' or 'get_instance_by_provider'. The description lacks context about use cases, prerequisites, or exclusions, leaving the agent without direction on tool selection.

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