Skip to main content
Glama
rainhan99

Cloud Manage MCP Server

by rainhan99

get_aws_instance_monitoring

Retrieve AWS EC2 instance monitoring metrics for specified time periods to analyze performance and track resource utilization.

Instructions

获取AWS EC2实例的监控数据

Args:
    instance_id (str): EC2实例ID
    hours (int): 获取过去多少小时的数据
    
Returns:
    Dict: 监控数据

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
instance_idYes
hoursNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • main.py:354-367 (handler)
    MCP tool registration and handler for 'get_aws_instance_monitoring'. This thin wrapper delegates the actual logic to the aws_provider instance.
    @mcp.tool()
    def get_aws_instance_monitoring(instance_id: str, hours: int = 1) -> Dict:
        """
        获取AWS EC2实例的监控数据
        
        Args:
            instance_id (str): EC2实例ID
            hours (int): 获取过去多少小时的数据
            
        Returns:
            Dict: 监控数据
        """
        return aws_provider.get_instance_monitoring_data(instance_id, hours)
  • Core implementation in AWSProvider class that fetches CloudWatch metrics (CPU, Network, Disk) for the given instance over the specified hours using boto3.
    def get_instance_monitoring_data(self, instance_id: str, hours: int = 1) -> Dict:
        """
        获取实例的监控数据
        
        Args:
            instance_id (str): EC2实例ID
            hours (int): 获取过去多少小时的数据
            
        Returns:
            Dict: 监控数据或错误信息
        """
        if not self.available:
            return {
                'error': f'AWS服务不可用: {getattr(self, "error", "未知错误")}',
                'provider': 'aws'
            }
        
        try:
            end_time = datetime.utcnow()
            start_time = end_time - timedelta(hours=hours)
            
            metrics = ['CPUUtilization', 'NetworkIn', 'NetworkOut', 'DiskReadOps', 'DiskWriteOps']
            monitoring_data = {}
            
            for metric in metrics:
                try:
                    response = self.cloudwatch.get_metric_statistics(
                        Namespace='AWS/EC2',
                        MetricName=metric,
                        Dimensions=[
                            {
                                'Name': 'InstanceId',
                                'Value': instance_id
                            }
                        ],
                        StartTime=start_time,
                        EndTime=end_time,
                        Period=300,  # 5分钟
                        Statistics=['Average', 'Maximum']
                    )
                    
                    monitoring_data[metric] = {
                        'datapoints': len(response['Datapoints']),
                        'data': response['Datapoints']
                    }
                except Exception as e:
                    monitoring_data[metric] = {
                        'error': str(e),
                        'datapoints': 0
                    }
            
            return {
                'provider': 'aws',
                'instance_id': instance_id,
                'time_range': f'{hours}小时',
                'metrics': monitoring_data
            }
            
        except ClientError as e:
            return {
                'error': f'AWS API调用失败: {str(e)}',
                'provider': 'aws'
            }
        except Exception as e:
            return {
                'error': f'获取监控数据时发生错误: {str(e)}',
                'provider': 'aws'
            }
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 retrieves monitoring data, implying a read-only operation, but doesn't specify details like authentication requirements, rate limits, data format, or whether it's a real-time or historical query. For a tool with no annotations, 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.

Conciseness4/5

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

The description is concise and well-structured: a clear purpose statement followed by Args and Returns sections. It uses minimal sentences that directly address key elements. However, it could be more front-loaded with critical details (e.g., distinguishing from siblings), and the Returns section is vague ('Dict: 监控数据'), slightly reducing efficiency.

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 moderate complexity (2 parameters, no annotations, but has an output schema), the description is partially complete. It covers the basic purpose and parameters but misses behavioral context (e.g., auth, limits) and usage guidelines. The output schema exists, so the description doesn't need to detail return values, but overall, it leaves gaps for effective agent use.

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 description adds minimal semantics beyond the input schema: it names the parameters (instance_id, hours) and their types (str, int), but the schema already provides titles and types with 0% description coverage. It doesn't explain what 'hours' means (e.g., past hours from now) or provide examples. With schema coverage low, the description partially compensates but lacks depth, aligning with the baseline.

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 tool's purpose: '获取AWS EC2实例的监控数据' (Get AWS EC2 instance monitoring data). It specifies the verb (获取/get) and resource (AWS EC2 instance monitoring data), which is clear. However, it doesn't explicitly distinguish this tool from its sibling 'get_aws_instance_info' or other monitoring tools like 'get_alibaba_instance_monitoring', which would be needed for a score of 5.

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 sibling tools like 'get_aws_instance_info' (for general info) or 'get_aws_instance_storage_info' (for storage-specific data), nor does it specify prerequisites or exclusions (e.g., only for AWS EC2 instances). This lack of context makes it harder for an agent to choose correctly among similar tools.

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