get_ec2_summary
Retrieve summarized information about EC2 instances in a specified AWS region using the aws-helper MCP Server. Simplify instance management and monitoring.
Instructions
EC2 인스턴스 요약 정보를 제공합니다
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| region | No | AWS 리전 | ap-northeast-2 |
Input Schema (JSON Schema)
{
"properties": {
"region": {
"default": "ap-northeast-2",
"description": "AWS 리전",
"type": "string"
}
},
"type": "object"
}
Implementation Reference
- src/index.ts:175-225 (handler)The main handler function for 'get_ec2_summary' tool. It queries all EC2 instances in the specified region, aggregates counts by state (running, stopped, etc.) and by instance type, and returns a formatted text summary.async function getEC2Summary(args: any) { const region = args?.region || 'ap-northeast-2'; const client = new EC2Client({ region }); const command = new DescribeInstancesCommand({}); const response = await client.send(command); const summary = { total: 0, running: 0, stopped: 0, pending: 0, terminated: 0, byType: {} as Record<string, number> }; for (const reservation of response.Reservations || []) { for (const instance of reservation.Instances || []) { summary.total++; const state = instance.State?.Name || 'unknown'; if (state === 'running') summary.running++; else if (state === 'stopped') summary.stopped++; else if (state === 'pending') summary.pending++; else if (state === 'terminated') summary.terminated++; const type = instance.InstanceType || 'unknown'; summary.byType[type] = (summary.byType[type] || 0) + 1; } } return { content: [ { type: 'text', text: `📈 EC2 인스턴스 요약 (${region})\n\n` + `**상태별 현황:**\n` + `• 전체: ${summary.total}개\n` + `• 실행 중: ${summary.running}개\n` + `• 중지됨: ${summary.stopped}개\n` + `• 시작 중: ${summary.pending}개\n` + `• 종료됨: ${summary.terminated}개\n\n` + `**인스턴스 타입별:**\n` + Object.entries(summary.byType) .sort(([,a], [,b]) => b - a) .map(([type, count]) => `• ${type}: ${count}개`) .join('\n') } ] }; }
- src/index.ts:58-67 (schema)Input schema definition for the get_ec2_summary tool, specifying an optional 'region' parameter with default 'ap-northeast-2'.inputSchema: { type: 'object', properties: { region: { type: 'string', description: 'AWS 리전', default: 'ap-northeast-2' } } }
- src/index.ts:55-68 (registration)Registration of the 'get_ec2_summary' tool in the ListToolsRequestSchema handler, including name, description, and input schema.{ name: 'get_ec2_summary', description: 'EC2 인스턴스 요약 정보를 제공합니다', inputSchema: { type: 'object', properties: { region: { type: 'string', description: 'AWS 리전', default: 'ap-northeast-2' } } } },
- src/index.ts:96-97 (registration)Dispatcher registration in the CallToolRequestSchema switch statement that invokes the getEC2Summary handler.case 'get_ec2_summary': return await getEC2Summary(args);