Skip to main content
Glama
aliyun

Alibaba Cloud MCP Server

Official
by aliyun

StopInstances

Stop multiple Alibaba Cloud ECS instances simultaneously to manage resources efficiently. Specify instance IDs and choose forced shutdown if needed. Ideal for batch instance management and cost optimization.

Instructions

批量停止ECS实例,适用于需要同时管理和停止多台ECS实例的场景。

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
ForeceStopNo是否强制关机
InstanceIdsYesAlibabaCloud ECS instance ID List
RegionIdNoAlibabaCloud region IDcn-hangzhou

Implementation Reference

  • Handler function OOS_StopInstances for stopping multiple Alibaba Cloud ECS instances using OOS (Operations Orchestration Service) by triggering the 'ACS-ECS-BulkyStopInstances' template and waiting synchronously for completion.
    @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)
  • Registration of the OOS tools (including OOS_StopInstances) to the FastMCP server instance.
    for tool in oos_tools.tools:
  • Helper function that starts an OOS execution with given template and parameters, polls the status until it reaches an end state (Success, Failed, Cancelled), and raises exception on failure.
    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
  • Helper function to create an OOS client configured for the specified region.
    def create_client(region_id: str) -> oos20190601Client: config = create_config() config.endpoint = f'oos.{region_id}.aliyuncs.com' return oos20190601Client(config)

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/aliyun/alibabacloud-ecs-mcp-server'

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