ecs_list_instances
Retrieve a paginated list of ECS instances in your Alibaba Cloud region, filtered by region ID.
Instructions
List Alibaba Cloud ECS instances in the current region.
Tool call template
This tool declares no required parameters. Add optional parameters from the input schema as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {},
"name": "ecs_list_instances"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| regionId | No | The region ID (e.g., 'cn-hangzhou'). Defaults to ALIBABA_CLOUD_REGION_ID. | |
| pageSize | No | Number of results per page. Default 10. |
Implementation Reference
- src/tools/ecs/index.ts:52-67 (handler)The handler function for ecs_list_instances. It validates input (regionId, pageSize) using Zod, builds API params, calls Alibaba Cloud's DescribeInstances API, and returns the result as text content.
if (name === "ecs_list_instances") { const parsed = z.object({ regionId: z.string().default(config.ALIBABA_CLOUD_REGION_ID), pageSize: z.number().default(10) }).parse(args); const params = { RegionId: parsed.regionId, PageSize: parsed.pageSize }; const result = await client.request('DescribeInstances', params, requestOption); return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] }; } - src/tools/ecs/index.ts:8-22 (schema)The tool registration definition for ecs_list_instances, including its name, description, and inputSchema (regionId string, pageSize number).
name: "ecs_list_instances", description: "List Alibaba Cloud ECS instances in the current region.", inputSchema: { type: "object", properties: { regionId: { type: "string", description: "The region ID (e.g., 'cn-hangzhou'). Defaults to ALIBABA_CLOUD_REGION_ID." }, pageSize: { type: "number", description: "Number of results per page. Default 10." } } } - src/index.ts:35-35 (registration)Registration of all ECS tools (including ecs_list_instances) via registerEcsTools() in the ListToolsRequestSchema handler.
...registerEcsTools(), - src/index.ts:54-55 (registration)Routing of tool calls with 'ecs_' prefix (including ecs_list_instances) to the handleEcsTools function in the CallToolRequestSchema handler.
if (name.startsWith("ecs_")) { return await handleEcsTools(name, args);