Skip to main content
Glama

list_ec2_instances

Retrieve and display EC2 instance details including ID, type, state, and public IP for AWS resource management.

Instructions

Lists EC2 instances in the current region, showing ID, type, state, and public IP.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
regionNoOptional AWS region to list instances from (overrides default)

Implementation Reference

  • The main handler function for the 'list_ec2_instances' tool. It uses the EC2Client (region-specific if provided) to send a DescribeInstancesCommand, extracts instance details including ID, name (from tags), type, state, IPs, launch time, and tags, formats as JSON, and notes the default region if not overridden.
    if (name === "list_ec2_instances") {
        // Create a region-specific client if provided, otherwise use default
        // Note: Re-instantiating client for every request isn't ideal for perf but fine for this scale
        // To strictly support region override we'd need to recreate the client or default to the global one
        // For simplicity here using the global one unless specific tool logic is needed.
        // Actually, if args.region is passed, we should use a new client.
    
        const region = (args as { region?: string })?.region;
        const client = region ? new EC2Client({ region }) : ec2Client;
    
        const command = new DescribeInstancesCommand({});
        const response = await client.send(command);
    
        const instances = response.Reservations?.flatMap(
            (r) =>
                r.Instances?.map((i) => ({
                    InstanceId: i.InstanceId,
                    Name: i.Tags?.find((t) => t.Key === "Name")?.Value,
                    InstanceType: i.InstanceType,
                    State: i.State?.Name,
                    PublicIpAddress: i.PublicIpAddress,
                    PrivateIpAddress: i.PrivateIpAddress,
                    LaunchTime: i.LaunchTime,
                    Tags: i.Tags,
                })) || []
        ) || [];
    
        const content: any[] = [
            {
                type: "text",
                text: JSON.stringify(instances, null, 2),
            }
        ];
    
        if (!region) {
            content.push({
                type: "text",
                text: "\n(Checked default region 'us-east-1'. Use the 'region' argument to check other regions like 'ap-south-1', 'us-west-2', etc.)"
            });
        }
    
        return {
            content: content,
        };
    }
  • src/index.ts:118-130 (registration)
    Registration of the 'list_ec2_instances' tool in the ListTools response, including its name, description, and input schema for optional region parameter.
    {
        name: "list_ec2_instances",
        description: "Lists EC2 instances in the current region, showing ID, type, state, and public IP.",
        inputSchema: {
            type: "object",
            properties: {
                region: {
                    type: "string",
                    description: "Optional AWS region to list instances from (overrides default)",
                },
            },
        },
    },
  • The input schema definition for the 'list_ec2_instances' tool, specifying an optional 'region' string parameter.
    inputSchema: {
        type: "object",
        properties: {
            region: {
                type: "string",
                description: "Optional AWS region to list instances from (overrides default)",
            },
        },
    },
  • Initialization of the shared EC2Client used by the list_ec2_instances handler (and others).
    const ec2Client = new EC2Client({});
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries full burden. It mentions what fields are shown but doesn't disclose behavioral traits like pagination, rate limits, authentication requirements, error conditions, or whether this is a read-only operation. The description is minimal and lacks critical operational context.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that front-loads key information (action, resource, scope, output). Every word earns its place with zero wasted content, making it easy to parse quickly.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a listing tool with no annotations and no output schema, the description is incomplete. It doesn't explain the return format, pagination, error handling, or how the optional parameter affects behavior. Given the complexity of AWS EC2 operations and lack of structured fields, more context is needed for effective use.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema already documents the optional 'region' parameter. The description adds no additional parameter semantics beyond implying regional scope with 'current region', which aligns with but doesn't enhance the schema. Baseline 3 is appropriate when schema does the heavy lifting.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('Lists'), resource ('EC2 instances'), scope ('in the current region'), and specific output fields ('ID, type, state, and public IP'). It distinguishes from sibling tools like 'get_instance_details' by focusing on listing rather than detailed retrieval.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance is provided on when to use this tool versus alternatives like 'get_instance_details' or other listing tools. The description mentions 'current region' but doesn't explain how this interacts with the optional 'region' parameter or when to override defaults.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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/bhaveshopss/MCP-server'

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