Skip to main content
Glama
RadiumGu

Alibaba Cloud Operations MCP Server

by RadiumGu

stop_ecs_instances

Stop running Alibaba Cloud ECS instances to reduce costs or manage resources. Specify region and instance IDs to halt virtual servers.

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

  • Primary handler for 'stop_ecs_instances' tool. Registered via @app.tool(). Dynamically locates and calls the OOS_StopInstances function from oos_tools by matching keywords in function name.
    @app.tool()
    def stop_ecs_instances(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 oos_tools
            
            if not instance_ids:
                return "请提供ECS实例ID列表"
            
            for tool_func in oos_tools.tools:
                if hasattr(tool_func, '__name__') and 'stop' in tool_func.__name__.lower() and 'instance' in tool_func.__name__.lower():
                    result = tool_func(RegionId=region, InstanceIds=instance_ids)
                    return str(result)
            
            return f"ECS实例停止功能可用,region: {region}, 实例: {instance_ids}"
        except Exception as e:
            return f"ECS实例停止失败: {str(e)}"
  • Core helper function OOS_StopInstances invoked by the main handler. Uses Alibaba Cloud OOS to bulk stop ECS instances via execution template 'ACS-ECS-BulkyStopInstances'. Includes Pydantic Field definitions for input schema.
    @tools.append
    def OOS_StopInstances(
        InstanceIds: List[str] = Field(description='AlibabaCloud ECS instance ID List'),
        RegionId: str = Field(description='AlibabaCloud region ID', default='cn-hangzhou'),
        ForeceStop: bool = Field(description='Is forced shutdown required', default=False)
    ):
        """批量停止ECS实例,适用于需要同时管理和停止多台ECS实例的场景。"""
        
        parameters = {
            'regionId': RegionId,
            'resourceType': 'ALIYUN::ECS::Instance',
            'targets': {
                'ResourceIds': InstanceIds,
                'RegionId': RegionId,
                'Type': 'ResourceIds'
            },
            'forceStop': ForeceStop
        }
        return _start_execution_sync(region_id=RegionId, template_name='ACS-ECS-BulkyStopInstances', parameters=parameters)
  • Pydantic Field definitions providing input schema and descriptions for the OOS_StopInstances function parameters.
    InstanceIds: List[str] = Field(description='AlibabaCloud ECS instance ID List'),
    RegionId: str = Field(description='AlibabaCloud region ID', default='cn-hangzhou'),
    ForeceStop: bool = Field(description='Is forced shutdown required', default=False)
  • Shared helper function that starts an OOS execution template and polls for completion synchronously. Used by all OOS tools including stop instances.
    def _start_execution_sync(region_id: str, template_name: str, parameters: dict):
        client = create_client(region_id=region_id)
        start_execution_request = oos_20190601_models.StartExecutionRequest(
            region_id=region_id,
            template_name=template_name,
            parameters=json.dumps(parameters)
        )
        start_execution_resp = client.start_execution(start_execution_request)
        execution_id = start_execution_resp.body.execution.execution_id
    
        while True:
            list_executions_request = oos_20190601_models.ListExecutionsRequest(
                region_id=region_id,
                execution_id=execution_id
            )
            list_executions_resp = client.list_executions(list_executions_request)
            status = list_executions_resp.body.executions[0].status
            if status == FAILED:
                status_message = list_executions_resp.body.executions[0].status_message
                raise exception.OOSExecutionFailed(reason=status_message)
            elif status in END_STATUSES:
                return list_executions_resp.body
            time.sleep(1)
    @tools.append
Behavior2/5

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

With no annotations provided, the description carries full burden for behavioral disclosure. It only states the action ('停止') without explaining what 'stop' entails (e.g., graceful shutdown vs. forced stop, state changes, billing implications, or permissions required). This is inadequate for a destructive operation with zero annotation coverage.

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 and structured with a title and parameter list, but it's under-specified for a destructive tool. The two sentences earn their place by stating purpose and parameters, but more context is needed for safe usage, making it feel incomplete rather than optimally concise.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given this is a destructive tool with no annotations, 2 parameters, 0% schema coverage, and an output schema (which helps), the description is incomplete. It covers basic purpose and parameters but misses critical behavioral details like effects, permissions, or error handling, leaving gaps for safe agent invocation.

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 provides meaningful parameter semantics: 'region' is explained as '区域ID,如cn-beijing' (region ID, e.g., cn-beijing), and 'instance_ids' as 'ECS实例ID列表' (ECS instance ID list). With 0% schema description coverage, this compensates well by clarifying what each parameter represents, though it lacks format details like ID patterns or list constraints.

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 action ('停止' meaning 'stop') and resource ('ECS实例' meaning 'ECS instances'), making the purpose immediately understandable. However, it doesn't differentiate from sibling tools like 'reboot_ecs_instances' or 'start_ecs_instances' beyond the basic verb difference, missing explicit scope or behavioral 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 'reboot_ecs_instances' or 'start_ecs_instances'. The description lacks context about prerequisites, consequences, or typical use cases, offering only basic parameter documentation without usage context.

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