Skip to main content
Glama
RadiumGu

Alibaba Cloud Operations MCP Server

by RadiumGu

get_memory_usage_data

Retrieve memory usage data for Alibaba Cloud ECS instances to monitor performance and identify resource constraints.

Instructions

获取ECS实例内存使用率数据

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

  • The primary handler for the 'get_memory_usage_data' tool, registered via @app.tool(). It dynamically locates and invokes the CMS_GetMemUsageData helper from cms_tools to fetch memory usage metrics from Alibaba Cloud CloudMonitor.
    @app.tool()
    def get_memory_usage_data(region: str = "cn-beijing", instance_ids: List[str] = None) -> str:
        """获取ECS实例内存使用率数据
        
        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 'mem' 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"内存使用率监控功能可用,region: {region}, 实例: {instance_ids}"
        except Exception as e:
            return f"内存监控查询失败: {str(e)}"
  • Helper function specifically providing memory usage (utilization) data via CloudMonitor API. Dynamically selected and called by the main handler based on name matching.
    @tools.append
    def CMS_GetMemUsageData(
        InstanceIds: List[str] = Field(description='AlibabaCloud ECS instance ID List'),
        RegionId: str = Field(description='AlibabaCloud region ID', default='cn-hangzhou')
    ):
        """获取内存利用率指标数据"""
        return _get_cms_metric_data(RegionId, InstanceIds, 'memory_usedutilization')
  • Core helper utility that executes the actual Alibaba Cloud CMS DescribeMetricLast API call to retrieve metric datapoints for the specified metric (e.g., memory_usedutilization).
    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
  • The @app.tool() decorator registers the get_memory_usage_data function as an MCP tool in the FastMCP server.
    @app.tool()
  • Pydantic Field definitions providing input schema/validation for the underlying CMS_GetMemUsageData helper (region and instance_ids parameters).
        InstanceIds: List[str] = Field(description='AlibabaCloud ECS instance ID List'),
        RegionId: str = Field(description='AlibabaCloud region ID', default='cn-hangzhou')
    ):
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. While it indicates this is a data retrieval operation ('获取'), it doesn't describe important behavioral aspects like whether this requires specific permissions, whether it's a real-time or historical query, rate limits, error conditions, or what the output format looks like. For a data retrieval tool with zero annotation coverage, this is insufficient.

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 concise with a clear purpose statement followed by parameter documentation. The two-sentence structure is efficient, though the parameter documentation could be slightly more detailed given the lack of schema descriptions.

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 that there's an output schema (which means the description doesn't need to explain return values), the description is minimally adequate for a data retrieval tool. However, with no annotations and incomplete parameter documentation (0% schema coverage), the description should provide more context about behavioral aspects and usage scenarios to be truly complete.

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 provides parameter documentation in the Args section, explaining that 'region' is a region ID like cn-beijing and 'instance_ids' is a list of ECS instance IDs. However, with 0% schema description coverage, the description compensates somewhat but doesn't provide complete parameter semantics - it doesn't explain format requirements, constraints, or provide examples beyond a single region example.

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实例内存使用率数据' (Get ECS instance memory usage data). This specifies both the verb (get) and resource (ECS instance memory usage data). However, it doesn't differentiate from sibling tools like 'get_cpu_usage_data' or 'get_disk_usage_data' beyond mentioning memory specifically.

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_cpu_usage_data' or 'describe_ecs_instances', nor does it provide context about prerequisites, timing considerations, or appropriate use cases for memory usage data versus other metrics.

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