Skip to main content
Glama
tarnover
by tarnover

aws_iam

Manage AWS IAM roles and policies by performing actions like listing, creating, or deleting roles and policies directly through Ansible MCP Server operations.

Instructions

Manage AWS IAM roles and policies

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
actionYes
assumeRolePolicyDocumentNo
managedPoliciesNo
nameNo
pathNo
policyDocumentNo
policyNameNo
regionYes
roleNameNo

Implementation Reference

  • Registration of the 'aws_iam' tool in the toolDefinitions map, linking to its schema and handler.
    aws_iam: {
      description: 'Manage AWS IAM roles and policies',
      schema: aws.IAMSchema,
      handler: aws.iamOperations,
    },
  • Zod schema definition for 'aws_iam' tool inputs, including IAMActionEnum and parameters like action, region, roleName, policyName, etc.
    // AWS IAM Schema
    export const IAMSchema = z.object({
      action: IAMActionEnum,
      region: z.string().min(1, 'AWS region is required'),
      name: z.string().optional(),
      roleName: z.string().optional(),
      policyName: z.string().optional(),
      policyDocument: z.any().optional(),
      assumeRolePolicyDocument: z.any().optional(),
      path: z.string().optional(),
      managedPolicies: z.array(z.string()).optional()
    });
    
    export type IAMOptions = z.infer<typeof IAMSchema>;
  • The handler function that implements the aws_iam tool logic by dynamically generating Ansible playbooks for IAM operations (list, create, delete roles/policies) using AWS collection modules and executing them.
    export async function iamOperations(args: IAMOptions): Promise<string> {
      await verifyAwsCredentials();
    
      const { action, region, policyName, policyDocument, path, roleName, assumeRolePolicyDocument, managedPolicies } = args;
    
      const tempFiles: { filename: string, content: string }[] = [];
      let policyDocParam = '';
      let assumeRoleDocParam = '';
    
      if (policyDocument) {
        const policyFilename = 'policy.json';
        tempFiles.push({ filename: policyFilename, content: JSON.stringify(policyDocument, null, 2) });
        policyDocParam = `policy_document: "{{ lookup('file', '${policyFilename}') }}"`;
      }
    
      if (assumeRolePolicyDocument) {
        const assumeRoleFilename = 'assume_role_policy.json';
        tempFiles.push({ filename: assumeRoleFilename, content: JSON.stringify(assumeRolePolicyDocument, null, 2) });
        assumeRoleDocParam = `assume_role_policy_document: "{{ lookup('file', '${assumeRoleFilename}') }}"`;
      }
    
      let playbookContent = `---
    - name: AWS IAM ${action} operation
      hosts: localhost
      connection: local
      gather_facts: no
      tasks:`;
      
      switch (action) {
        case 'list_roles':
          playbookContent += `
        - name: List IAM roles
          amazon.aws.iam_role_info:
            region: "${region}"
          register: iam_roles
        
        - name: Display roles
          debug:
            var: iam_roles.iam_roles`;
          break;
          
        case 'list_policies':
          playbookContent += `
        - name: List IAM policies
          amazon.aws.iam_policy_info:
            region: "${region}"
          register: iam_policies
        
        - name: Display policies
          debug:
            var: iam_policies.policies`;
          break;
          
        case 'create_role':
          playbookContent += `
        - name: Create IAM role
          amazon.aws.iam_role:
            region: "${region}"
            name: "${roleName}"
            ${assumeRoleDocParam}
            state: present
    ${formatYamlParams({
      path,
      managed_policies: managedPolicies
    })}
          register: iam_result
        
        - name: Display role details
          debug:
            var: iam_result`;
          break;
          
        case 'create_policy':
          playbookContent += `
        - name: Create IAM policy
          amazon.aws.iam_policy:
            region: "${region}"
            policy_name: "${policyName}"
            ${policyDocParam}
            state: present
    ${formatYamlParams({ path })}
          register: iam_result
        
        - name: Display policy details
          debug:
            var: iam_result`;
          break;
          
        case 'delete_role':
          playbookContent += `
        - name: Delete IAM role
          amazon.aws.iam_role:
            region: "${region}"
            name: "${roleName}"
            state: absent
          register: iam_role_delete
        
        - name: Display deletion result
          debug:
            var: iam_role_delete`;
          break;
          
        case 'delete_policy':
          playbookContent += `
        - name: Delete IAM policy
          amazon.aws.iam_policy:
            region: "${region}"
            policy_name: "${policyName}"
            state: absent
          register: iam_policy_delete
        
        - name: Display deletion result
          debug:
            var: iam_policy_delete`;
          break;
          
        default:
          throw new AnsibleError(`Unsupported IAM action: ${action}`);
      }
      
      // Execute the generated playbook, passing policy docs if needed
      return executeAwsPlaybook(`iam-${action}`, playbookContent, '', tempFiles);
    }
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 for behavioral disclosure. 'Manage' implies both read and write operations, but it doesn't specify permissions required, rate limits, side effects (e.g., deletions), or response formats. For a tool with 9 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 a single, efficient sentence with no wasted words. It's appropriately sized and front-loaded, making it easy to scan. Every word contributes to the core message, though the message itself is under-specified.

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 (9 parameters, no annotations, no output schema), the description is incomplete. It doesn't explain parameters, return values, or behavioral traits. For a multi-action tool handling sensitive IAM operations, this minimal description leaves critical gaps in understanding how to use it effectively.

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

Parameters1/5

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

Schema description coverage is 0%, so the description must compensate for undocumented parameters. It mentions 'roles and policies' but doesn't explain any of the 9 parameters (e.g., action, region, name). The description adds no meaningful semantics beyond what's inferred from the tool name, failing to address the coverage gap.

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 IAM roles and policies' states a general purpose but lacks specificity. It mentions the resource (AWS IAM roles and policies) and a vague verb ('manage'), but doesn't distinguish from sibling AWS tools or specify what management operations are available. This is better than a tautology but remains vague about the exact functionality.

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 sibling tools like aws_cloudformation or aws_lambda, nor does it specify prerequisites, exclusions, or appropriate contexts for IAM management. Usage is implied only by the tool name and description, with no explicit instructions.

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