Skip to main content
Glama
rainhan99

Cloud Manage MCP Server

by rainhan99

get_aws_instance_storage_info

Retrieve storage details for AWS EC2 instances, including disk type, IOPS, and throughput metrics, to monitor and manage cloud resources effectively.

Instructions

获取AWS EC2实例的存储详细信息

Args:
    instance_id (str): EC2实例ID
    
Returns:
    Dict: 存储信息,包括磁盘类型、IOPS、吞吐量等

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
instance_idYes

Implementation Reference

  • Core handler implementing AWS EC2 instance storage info retrieval using boto3 to fetch block devices and EBS volume details including type, size, IOPS, throughput.
    def get_instance_storage_info(self, instance_id: str) -> Dict:
        """
        获取实例的存储详细信息
        
        Args:
            instance_id (str): EC2实例ID
            
        Returns:
            Dict: 存储信息或错误信息
        """
        if not self.available:
            return {
                'error': f'AWS服务不可用: {getattr(self, "error", "未知错误")}',
                'provider': 'aws'
            }
        
        try:
            # 获取实例信息
            instance_response = self.ec2.describe_instances(InstanceIds=[instance_id])
            if not instance_response['Reservations']:
                return {
                    'error': f'未找到ID为 {instance_id} 的EC2实例',
                    'provider': 'aws'
                }
            
            instance = instance_response['Reservations'][0]['Instances'][0]
            
            # 获取卷信息
            storage_info = []
            
            for block_device in instance.get('BlockDeviceMappings', []):
                volume_id = block_device.get('Ebs', {}).get('VolumeId')
                if volume_id:
                    volume_response = self.ec2.describe_volumes(VolumeIds=[volume_id])
                    if volume_response['Volumes']:
                        volume = volume_response['Volumes'][0]
                        
                        # 获取IOPS和吞吐量信息
                        iops = volume.get('Iops', 'N/A')
                        throughput = volume.get('Throughput', 'N/A')
                        
                        storage_info.append({
                            'device_name': block_device.get('DeviceName'),
                            'volume_id': volume_id,
                            'volume_type': volume.get('VolumeType'),
                            'size': volume.get('Size'),
                            'iops': iops,
                            'throughput': throughput,
                            'encrypted': volume.get('Encrypted', False),
                            'state': volume.get('State'),
                            'created_time': volume.get('CreateTime').isoformat() if volume.get('CreateTime') else None
                        })
            
            return {
                'provider': 'aws',
                'instance_id': instance_id,
                'storage_devices': storage_info,
                'total_devices': len(storage_info)
            }
            
        except ClientError as e:
            return {
                'error': f'AWS API调用失败: {str(e)}',
                'provider': 'aws'
            }
        except Exception as e:
            return {
                'error': f'获取存储信息时发生错误: {str(e)}',
                'provider': 'aws'
            }
  • main.py:341-352 (registration)
    MCP tool registration for 'get_aws_instance_storage_info' which delegates to the AWSProvider instance method.
    @mcp.tool()
    def get_aws_instance_storage_info(instance_id: str) -> Dict:
        """
        获取AWS EC2实例的存储详细信息
        
        Args:
            instance_id (str): EC2实例ID
            
        Returns:
            Dict: 存储信息,包括磁盘类型、IOPS、吞吐量等
        """
        return aws_provider.get_instance_storage_info(instance_id)
  • Global instantiation of AWSProvider class instance used by the tool wrappers.
    aws_provider = AWSProvider() 

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