Skip to main content
Glama
tarnover
by tarnover

aws_elb

Automate AWS Elastic Load Balancer management using Ansible. Create, delete, or list load balancers across regions, configure subnets, security groups, listeners, and health checks.

Instructions

Manage AWS Elastic Load Balancers

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
actionYes
healthCheckNo
lbTypeNoapplication
listenersNo
nameNo
regionYes
schemeNo
securityGroupsNo
subnetsNo
tagsNo
targetGroupsNo

Implementation Reference

  • Main handler function for 'aws_elb' tool. Generates dynamic Ansible playbooks to manage AWS Elastic Load Balancers (list, create, delete) based on input action and parameters.
    export async function elbOperations(args: ELBOptions): Promise<string> {
      await verifyAwsCredentials();
    
      const { action, region, name, lbType = 'application', scheme, subnets, securityGroups, listeners, healthCheck, tags, targetGroups } = args;
    
      // Determine module based on lbType
      let moduleName: string;
      let infoModuleName: string;
      switch (lbType) {
        case 'application':
          moduleName = 'amazon.aws.elb_application_lb';
          infoModuleName = 'amazon.aws.elb_application_lb_info';
          break;
        case 'network':
          moduleName = 'amazon.aws.elb_network_lb';
          infoModuleName = 'amazon.aws.elb_network_lb_info';
          break;
        case 'classic':
          moduleName = 'amazon.aws.elb_classic_lb';
          infoModuleName = 'amazon.aws.elb_classic_lb_info';
          break;
        default:
          throw new AnsibleError(`Unsupported ELB type: ${lbType}`);
      }
    
      let playbookContent = `---
    - name: AWS ELB ${action} operation (${lbType})
      hosts: localhost
      connection: local
      gather_facts: no
      tasks:`;
      
      switch (action) {
        case 'list':
          playbookContent += `
        - name: List ${lbType} load balancers
          ${infoModuleName}:
            region: "${region}"
          register: elb_info
        
        - name: Display load balancers
          debug:
            var: elb_info`; // Adjust var based on actual module output if needed
          break;
          
        case 'create':
          playbookContent += `
        - name: Create ${lbType} load balancer
          ${moduleName}:
            region: "${region}"
            name: "${name}"
            state: present
    ${formatYamlParams({
      scheme,
      subnets,
      security_groups: securityGroups,
      listeners, // May need adjustment for different LB types
      health_check: healthCheck, // May need adjustment
      tags,
      target_groups: targetGroups // For Application/Network LBs
    })}
          register: elb_result
        
        - name: Display load balancer details
          debug:
            var: elb_result`;
          break;
          
        case 'delete':
          playbookContent += `
        - name: Delete ${lbType} load balancer
          ${moduleName}:
            region: "${region}"
            name: "${name}"
            state: absent
          register: elb_delete
        
        - name: Display deletion result
          debug:
            var: elb_delete`;
          break;
          
        default:
          throw new AnsibleError(`Unsupported ELB action: ${action}`);
      }
      
      // Execute the generated playbook
      return executeAwsPlaybook(`elb-${action}`, playbookContent);
    }
  • Zod schema definition for 'aws_elb' tool inputs (ELBOptions), including action enum (list/create/delete), region, name, lbType (application/network/classic), subnets, etc.
    export const ELBSchema = z.object({
      action: ELBActionEnum,
      region: z.string().min(1, 'AWS region is required'),
      name: z.string().optional(),
      lbType: z.enum(['classic', 'application', 'network']).optional().default('application'),
      scheme: z.string().optional(),
      subnets: z.array(z.string()).optional(),
      securityGroups: z.array(z.string()).optional(),
      listeners: z.array(z.any()).optional(), // Consider defining a more specific listener schema
      healthCheck: z.any().optional(), // Consider defining a more specific health check schema
      tags: z.record(z.string()).optional(),
      targetGroups: z.array(z.any()).optional() // Added based on usage in aws.ts. Consider a specific schema.
    });
    
    export type ELBOptions = z.infer<typeof ELBSchema>;
  • Tool registration in the MCP server: maps 'aws_elb' to its description, schema (aws.ELBSchema), and handler (aws.elbOperations).
    aws_elb: {
      description: 'Manage AWS Elastic Load Balancers',
      schema: aws.ELBSchema,
      handler: aws.elbOperations,
    },
  • Zod enum for ELB actions used in the ELBSchema.
    export const ELBActionEnum = z.enum(['list', 'create', 'delete']);
    export type ELBAction = z.infer<typeof ELBActionEnum>;
  • Helper function executeAwsPlaybook used by the handler to run the generated Ansible playbook in a temp directory.
    async function executeAwsPlaybook(
      operationName: string, 
      playbookContent: string, 
      extraParams: string = '',
      tempFiles: { filename: string, content: string }[] = [] // For additional files like templates, policies
    ): Promise<string> {
      let tempDir: string | undefined;
      try {
        // Create a unique temporary directory
        tempDir = await createTempDirectory(`ansible-aws-${operationName}`);
        
        // Write the main playbook file
        const playbookPath = await writeTempFile(tempDir, 'playbook.yml', playbookContent);
        
        // Write any additional temporary files
        for (const file of tempFiles) {
          await writeTempFile(tempDir, file.filename, file.content);
        }
    
        // Build the command
        const command = `ansible-playbook ${playbookPath} ${extraParams}`;
        console.error(`Executing: ${command}`);
    
        // Execute the playbook asynchronously
        const { stdout, stderr } = await execAsync(command);
        
        // Return stdout, or a success message if stdout is empty
        return stdout || `${operationName} completed successfully (no output).`;
    
      } catch (error: any) {
        // Handle execution errors
        const errorMessage = error.stderr || error.message || 'Unknown error';
        throw new AnsibleExecutionError(`Ansible execution failed for ${operationName}: ${errorMessage}`, error.stderr);
      } finally {
        // Ensure cleanup happens even if errors occur
        if (tempDir) {
          await cleanupTempDirectory(tempDir);
        }
      }
    }
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. 'Manage' implies mutation capabilities (create/delete) and read operations (list), but it doesn't disclose critical behavioral traits such as authentication requirements, rate limits, destructive effects of 'delete', or response formats. For a tool with 11 parameters and no annotation coverage, this is a significant gap in transparency.

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 extremely concise with a single sentence, 'Manage AWS Elastic Load Balancers', which is front-loaded and wastes no words. It efficiently states the tool's scope without unnecessary elaboration, earning a high score for brevity and clarity in structure.

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?

Given the complexity (11 parameters, nested objects, no output schema, and no annotations), the description is incomplete. It doesn't provide enough context for an AI agent to understand how to invoke the tool correctly, such as explaining parameter dependencies, action-specific requirements, or expected outcomes. For a multi-action tool with significant input complexity, this is inadequate.

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

Parameters2/5

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

Schema description coverage is 0%, meaning none of the 11 parameters have descriptions in the schema. The tool description adds no meaning beyond the schema—it doesn't explain what parameters like 'healthCheck', 'listeners', or 'targetGroups' are for, their formats, or how they relate to actions. With low coverage and no compensation in the description, this falls short of the baseline.

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

Purpose3/5

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

The description 'Manage AWS Elastic Load Balancers' states the resource (AWS Elastic Load Balancers) and a general verb ('Manage'), but it's vague about what specific operations are included. It doesn't distinguish from sibling tools like aws_ec2 or aws_vpc, which also manage AWS resources. The purpose is clear at a high level but lacks specificity about the CRUD operations available.

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?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention any prerequisites, context for choosing between 'list', 'create', or 'delete' actions, or how it differs from other AWS tools in the sibling list. Without such guidance, users must infer usage from the input schema alone.

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

Related 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/tarnover/mcp-ansible'

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