StartInstances
Initiate and manage the simultaneous start of multiple Alibaba Cloud ECS instances, ideal for application deployment or high-availability scenarios.
Instructions
批量启动ECS实例,适用于需要同时管理和启动多台ECS实例的场景,例如应用部署和高可用性场景。
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| InstanceIds | Yes | AlibabaCloud ECS instance ID List | |
| RegionId | No | AlibabaCloud region ID | cn-hangzhou |
Implementation Reference
- The main handler function for the tool OOS_StartInstances, which starts multiple ECS instances using the OOS template 'ACS-ECS-BulkyStartInstances'. Note: The tool is named 'OOS_StartInstances', not exactly 'StartInstances', but matches the search.@tools.append def OOS_StartInstances( InstanceIds: List[str] = Field(description='AlibabaCloud ECS instance ID List'), RegionId: str = Field(description='AlibabaCloud region ID', default='cn-hangzhou'), ): """批量启动ECS实例,适用于需要同时管理和启动多台ECS实例的场景,例如应用部署和高可用性场景。""" parameters = { 'regionId': RegionId, 'resourceType': 'ALIYUN::ECS::Instance', 'targets': { 'ResourceIds': InstanceIds, 'RegionId': RegionId, 'Type': 'ResourceIds' } } return _start_execution_sync(region_id=RegionId, template_name='ACS-ECS-BulkyStartInstances', parameters=parameters)
- Helper function used by OOS_StartInstances to synchronously start an OOS execution and poll until completion.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)
- src/alibaba_cloud_ops_mcp_server/server.py:82-83 (registration)Registration loop where all tools from oos_tools.tools (including OOS_StartInstances) are registered to the MCP server using mcp.tool(tool).for tool in oos_tools.tools: mcp.tool(tool)
- src/alibaba_cloud_ops_mcp_server/server.py:7-76 (registration)Import of oos_tools module containing the tool.from alibaba_cloud_ops_mcp_server.tools import cms_tools, oos_tools, oss_tools, api_tools, common_api_tools from alibaba_cloud_ops_mcp_server.settings import settings logger = logging.getLogger(__name__) SUPPORTED_SERVICES_MAP = { "ecs": "Elastic Compute Service (ECS)", "oos": "Operations Orchestration Service (OOS)", "rds": "Relational Database Service (RDS)", "vpc": "Virtual Private Cloud (VPC)", "slb": "Server Load Balancer (SLB)", "ess": "Elastic Scaling (ESS)", "ros": "Resource Orchestration Service (ROS)", "cbn": "Cloud Enterprise Network (CBN)", "dds": "MongoDB Database Service (DDS)", "r-kvstore": "Cloud database Tair (compatible with Redis) (R-KVStore)", "bssopenapi": "Billing and Cost Management (BssOpenAPI)" } @click.command() @click.option( "--transport", type=click.Choice(["stdio", "sse", "streamable-http"]), default="stdio", help="Transport type", ) @click.option( "--port", type=int, default=8000, help="Port number", ) @click.option( "--host", type=str, default="127.0.0.1", help="Host", ) @click.option( "--services", type=str, default=None, help="Comma-separated list of supported services, e.g., 'ecs,vpc,rds'", ) @click.option( "--headers-credential-only", type=bool, default=False, help="Whether to use credentials only from headers", ) @click.option( "--env", type=click.Choice(["domestic", "international"]), default="domestic", help="Environment type: 'domestic' for domestic, 'international' for overseas (default: domestic)", ) def main(transport: str, port: int, host: str, services: str, headers_credential_only: bool, env: str): # Create an MCP server mcp = FastMCP( name="alibaba-cloud-ops-mcp-server", port=port, host=host, stateless_http=True ) if headers_credential_only: settings.headers_credential_only = headers_credential_only if env: settings.env = env if services: