list_ecs_services
Retrieve services within an ECS cluster to monitor and manage containerized applications in AWS.
Instructions
Lists services in a specific ECS cluster.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| cluster | Yes | The name or ARN of the ECS cluster. |
Implementation Reference
- src/index.ts:2194-2216 (handler)Handler function that lists ECS services in the specified cluster. Uses ListServicesCommand to get service ARNs, then DescribeServicesCommand for details like status, counts, and task definition. Limits to first 10 services.const cluster = (args as any).cluster; const command = new ListServicesCommand({ cluster }); const response = await ecsClient.send(command); const services = response.serviceArns || []; if (services.length === 0) return { content: [{ type: "text", text: "[]" }] }; // Describe for more info const batch = services.slice(0, 10); const descCommand = new DescribeServicesCommand({ cluster, services: batch }); const descResponse = await ecsClient.send(descCommand); const serviceDetails = descResponse.services?.map(s => ({ serviceName: s.serviceName, status: s.status, desiredCount: s.desiredCount, runningCount: s.runningCount, pendingCount: s.pendingCount, taskDefinition: s.taskDefinition })) || []; return { content: [{ type: "text", text: JSON.stringify(serviceDetails, null, 2) }] }; }
- src/index.ts:722-731 (registration)Tool registration in the ListToolsRequestSchema response array, defining the tool name, description, and input schema requiring a 'cluster' parameter.description: "Lists services in a specific ECS cluster.", inputSchema: { type: "object", properties: { cluster: { "type": "string", "description": "The name or ARN of the ECS cluster." } }, required: ["cluster"] } }, {
- src/index.ts:724-730 (schema)Input schema for the list_ecs_services tool, specifying an object with a required 'cluster' string parameter.type: "object", properties: { cluster: { "type": "string", "description": "The name or ARN of the ECS cluster." } }, required: ["cluster"] } },
- src/index.ts:38-38 (helper)Import of ECSClient and relevant commands (ListServicesCommand, DescribeServicesCommand) used by the list_ecs_services handler.import { ECSClient, ListClustersCommand, ListServicesCommand, DescribeClustersCommand, DescribeServicesCommand } from "@aws-sdk/client-ecs";
- src/index.ts:71-71 (helper)Initialization of the shared ECSClient instance used by the handler.const ecsClient = new ECSClient({});