Skip to main content
Glama
RadiumGu

Alibaba Cloud Operations MCP Server

by RadiumGu

get_cpu_usage_data

Retrieve CPU usage metrics for Alibaba Cloud ECS instances to monitor performance and identify resource utilization patterns.

Instructions

获取ECS实例CPU使用率数据

Args:
    region: 区域ID,如cn-beijing
    instance_ids: ECS实例ID列表

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
regionNocn-beijing
instance_idsNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • Main MCP tool handler and registration for get_cpu_usage_data. Dynamically selects and calls CMS_GetCpuUsageData from cms_tools based on name matching.
    def get_cpu_usage_data(region: str = "cn-beijing", instance_ids: List[str] = None) -> str:
        """获取ECS实例CPU使用率数据
        
        Args:
            region: 区域ID,如cn-beijing
            instance_ids: ECS实例ID列表
        """
        try:
            sys.path.insert(0, os.path.join(os.path.dirname(__file__), 'alibaba_cloud_ops_mcp_server'))
            from tools import cms_tools
            
            if not instance_ids:
                instance_ids = ["示例实例ID"]
            
            for tool_func in cms_tools.tools:
                if hasattr(tool_func, '__name__') and 'cpu' in tool_func.__name__.lower() and 'usage' in tool_func.__name__.lower():
                    result = tool_func(RegionId=region, InstanceIds=instance_ids)
                    return str(result)
            
            return f"CPU使用率监控功能可用,region: {region}, 实例: {instance_ids}"
        except Exception as e:
            return f"CPU监控查询失败: {str(e)}"
  • Helper function CMS_GetCpuUsageData that wraps the core metric query for CPU usage, invoked by the main handler.
    def CMS_GetCpuUsageData(
        InstanceIds: List[str] = Field(description='AlibabaCloud ECS instance ID List'),
        RegionId: str = Field(description='AlibabaCloud region ID', default='cn-hangzhou')
    ):
        """获取ECS实例的CPU使用率数据"""
        return _get_cms_metric_data(RegionId, InstanceIds, 'cpu_total')
  • Core helper implementing the Alibaba Cloud CMS API call to fetch metric data (cpu_total for CPU usage).
    def _get_cms_metric_data(region_id: str, instance_ids: List[str], metric_name: str):
        client = create_client(region_id)
        dimesion = []
        for instance_id in instance_ids:
            dimesion.append({
                'instanceId': instance_id
            })
        describe_metric_last_request = cms_20190101_models.DescribeMetricLastRequest(
            namespace='acs_ecs_dashboard',
            metric_name=metric_name,
            dimensions=json.dumps(dimesion),
        )
        describe_metric_last_resp = client.describe_metric_last(describe_metric_last_request)
        return describe_metric_last_resp.body.datapoints
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 CPU usage data, implying a read-only operation, but doesn't clarify aspects like whether it requires specific permissions, rate limits, data freshness, error handling, or output format. For a monitoring tool with zero annotation coverage, this leaves significant gaps in understanding its behavior.

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 appropriately sized and front-loaded: the first line states the purpose clearly, followed by a brief parameter explanation. There's no wasted text, and the structure is logical. However, it could be slightly more concise by integrating the parameter details more seamlessly, but it's still efficient.

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 complexity (simple monitoring with 2 parameters), no annotations, and the presence of an output schema (which handles return values), the description is minimally adequate. It covers the purpose and parameters but lacks behavioral details like error cases or usage context. With the output schema reducing the need to explain returns, it meets a basic threshold but has clear gaps in guidance and transparency.

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 description adds meaningful context beyond the input schema. The schema has 0% description coverage (titles only: 'Region' and 'Instance Ids'), but the description provides examples: '区域ID,如cn-beijing' (region ID, e.g., cn-beijing) and 'ECS实例ID列表' (ECS instance ID list). This clarifies the expected format and purpose of the parameters, compensating well for the low schema coverage. Since there are only 2 parameters, this is sufficient for a high score.

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: '获取ECS实例CPU使用率数据' (Get ECS instance CPU usage data). It specifies the verb (获取/get) and resource (ECS实例CPU使用率数据/ECS instance CPU usage data), making the function unambiguous. However, it doesn't explicitly differentiate from sibling tools like get_disk_usage_data or get_memory_usage_data beyond the resource name, which is why it's not a 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 describe_ecs_instances (which might list instances) or other monitoring tools, nor does it specify prerequisites or contexts for usage. The only implied usage is from the purpose, but no explicit when/when-not instructions are given.

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/RadiumGu/alicloud-ops-mcp'

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