Skip to main content
Glama
eunyuljo

aws-helper MCP Server

by eunyuljo

get_ec2_instances

Retrieve AWS EC2 instances by region and state to monitor cloud infrastructure and manage resources.

Instructions

EC2 인스턴스 목록을 조회합니다

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
regionNoAWS 리전 (기본값: ap-northeast-2)ap-northeast-2
stateNo인스턴스 상태 필터 (running, stopped, pending 등)

Implementation Reference

  • The main handler function that fetches EC2 instances using AWS SDK's DescribeInstancesCommand, applies optional state filter, extracts relevant instance details, and returns formatted markdown text.
    async function getEC2Instances(args: any) {
      const region = args?.region || 'ap-northeast-2';
      const state = args?.state;
      
      const client = new EC2Client({ region });
      
      const filters = [];
      if (state) {
        filters.push({
          Name: 'instance-state-name',
          Values: [state]
        });
      }
      
      const command = new DescribeInstancesCommand({
        Filters: filters.length > 0 ? filters : undefined
      });
      
      const response = await client.send(command);
      
      const instances = [];
      for (const reservation of response.Reservations || []) {
        for (const instance of reservation.Instances || []) {
          const nameTag = instance.Tags?.find(tag => tag.Key === 'Name');
          instances.push({
            id: instance.InstanceId,
            name: nameTag?.Value || 'N/A',
            type: instance.InstanceType,
            state: instance.State?.Name,
            privateIp: instance.PrivateIpAddress,
            publicIp: instance.PublicIpAddress || 'N/A',
            launchTime: instance.LaunchTime?.toISOString(),
            az: instance.Placement?.AvailabilityZone
          });
        }
      }
      
      return {
        content: [
          {
            type: 'text',
            text: `📊 EC2 인스턴스 목록 (${region})\n\n` +
                  `총 ${instances.length}개 인스턴스\n\n` +
                  instances.map(i => 
                    `🖥️ **${i.name}** (${i.id})\n` +
                    `   상태: ${i.state}\n` +
                    `   타입: ${i.type}\n` +
                    `   Private IP: ${i.privateIp}\n` +
                    `   Public IP: ${i.publicIp}\n` +
                    `   가용영역: ${i.az}\n`
                  ).join('\n')
          }
        ]
      };
    }
  • Input schema defining optional 'region' (default 'ap-northeast-2') and 'state' (enum: running, stopped, pending, terminated) parameters for the tool.
    inputSchema: {
      type: 'object',
      properties: {
        region: {
          type: 'string',
          description: 'AWS 리전 (기본값: ap-northeast-2)',
          default: 'ap-northeast-2'
        },
        state: {
          type: 'string',
          description: '인스턴스 상태 필터 (running, stopped, pending 등)',
          enum: ['running', 'stopped', 'pending', 'terminated']
        }
      }
    }
  • src/index.ts:36-54 (registration)
    Tool metadata registration in ListToolsRequestSchema handler, including name, description, and input schema.
    {
      name: 'get_ec2_instances',
      description: 'EC2 인스턴스 목록을 조회합니다',
      inputSchema: {
        type: 'object',
        properties: {
          region: {
            type: 'string',
            description: 'AWS 리전 (기본값: ap-northeast-2)',
            default: 'ap-northeast-2'
          },
          state: {
            type: 'string',
            description: '인스턴스 상태 필터 (running, stopped, pending 등)',
            enum: ['running', 'stopped', 'pending', 'terminated']
          }
        }
      }
    },
  • src/index.ts:93-95 (registration)
    Switch case in CallToolRequestSchema handler that dispatches execution to the getEC2Instances function.
    case 'get_ec2_instances':
      return await getEC2Instances(args);

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/eunyuljo/sample-mcp-server-with-claude-desktop'

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