Command Palette

Search for a command to run...

UnylyUnyly
Browse all

AWS IAM MCP Server Intelligent IAM Management With AI

FreeNot checked

AWS IAM MCP Server Intelligent IAM Management With AI — Model Context Protocol server

GitHubEmbed

About

AWS IAM MCP Server Intelligent IAM Management With AI — Model Context Protocol server

README

Introduction

The AWS IAM MCP Server is a Model Context Protocol server that enables AI assistants to comprehensively and securely manage AWS Identity and Access Management (IAM). This powerful tool automates complex IAM tasks through natural language while adhering to security best practices.

Repository: github.com/awslabs/mcp
Documentation: awslabs.github.io/mcp/servers/iam-mcp-server
Container Image: public.ecr.aws/awslabs-mcp/awslabs/iam-mcp-server
Version: 1.0.12
Downloads: 6,800+
Publisher: AWS Labs MCP (Verified Account)


Why AWS IAM MCP Server?

Traditional Challenges

Managing IAM on AWS typically presents several challenges:

  • Complexity: Multiple concepts including users, roles, groups, policies, and permissions boundaries
  • Time-consuming: Navigating through AWS Console or writing AWS CLI commands
  • Error-prone: Incorrect permission configurations can create security risks
  • Difficult to audit: Tracking who has what permissions across the organization

Solution with MCP

The AWS IAM MCP Server enables you to:

  • Manage IAM using natural language
  • Automate complex IAM tasks
  • Test permissions before applying them (policy simulation)
  • Explore safely with read-only mode
  • Force delete with automatic cleanup

Core Features

1. User Management

Comprehensive IAM user management capabilities:

# List users with filtering
users = await list_users(
    path_prefix="/developers/",
    max_items=50
)

# Get detailed user information (includes policies, groups, access keys)
user_details = await get_user(user_name="john.doe")

# Create new user
new_user = await create_user(
    user_name="jane.smith",
    path="/developers/",
    permissions_boundary="arn:aws:iam::123456789012:policy/DeveloperBoundary"
)

# Delete user with force cleanup
await delete_user(user_name="old.user", force=True)

Force delete automatically:

  • Removes user from all groups
  • Detaches all managed policies
  • Deletes all inline policies
  • Deletes all access keys

2. Role Management

Create and manage IAM roles:

# Trust policy for EC2
trust_policy = {
    "Version": "2012-10-17",
    "Statement": [{
        "Effect": "Allow",
        "Principal": {"Service": "ec2.amazonaws.com"},
        "Action": "sts:AssumeRole"
    }]
}

# Create role
role = await create_role(
    role_name="EC2-S3-Access-Role",
    assume_role_policy_document=json.dumps(trust_policy),
    description="Role for EC2 instances to access S3",
    max_session_duration=7200,
    permissions_boundary="arn:aws:iam::123456789012:policy/RoleBoundary"
)

# List roles
roles = await list_roles(
    path_prefix="/service-role/",
    max_items=100
)

3. Group Management

Manage groups and members:

# Create group
group = await create_group(
    group_name="Developers",
    path="/teams/"
)

# Add users to group
await add_user_to_group(
    group_name="Developers",
    user_name="john.doe"
)

# Attach policy to group
await attach_group_policy(
    group_name="Developers",
    policy_arn="arn:aws:iam::123456789012:policy/DeveloperPolicy"
)

# Get group details (members, policies)
group_details = await get_group(group_name="Developers")

# Remove user from group
await remove_user_from_group(
    group_name="Developers",
    user_name="john.doe"
)

# Delete group with force cleanup
await delete_group(group_name="OldGroup", force=True)

4. Policy Management

Manage both managed and inline policies:

# List policies
policies = await list_policies(
    scope="Local",  # "All", "AWS", or "Local"
    only_attached=True,
    path_prefix="/custom/",
    max_items=100
)

# Attach policy to user
await attach_user_policy(
    user_name="developer",
    policy_arn="arn:aws:iam::123456789012:policy/DeveloperPolicy"
)

# Detach policy from user
await detach_user_policy(
    user_name="developer",
    policy_arn="arn:aws:iam::123456789012:policy/OldPolicy"
)

5. Inline Policy Management

Full CRUD operations for inline policies:

# Create or update inline policy for user
policy_document = {
    "Version": "2012-10-17",
    "Statement": [{
        "Effect": "Allow",
        "Action": ["s3:GetObject", "s3:PutObject"],
        "Resource": "arn:aws:s3:::my-bucket/*"
    }]
}

await put_user_policy(
    user_name="developer",
    policy_name="S3AccessPolicy",
    policy_document=policy_document
)

# Get inline policy
policy = await get_user_policy(
    user_name="developer",
    policy_name="S3AccessPolicy"
)

# List all inline policies
policies = await list_user_policies(user_name="developer")

# Delete inline policy
await delete_user_policy(
    user_name="developer",
    policy_name="S3AccessPolicy"
)

# Similar operations for roles
await put_role_policy(
    role_name="EC2-S3-Access-Role",
    policy_name="S3ReadOnlyPolicy",
    policy_document={
        "Version": "2012-10-17",
        "Statement": [{
            "Effect": "Allow",
            "Action": "s3:GetObject",
            "Resource": "*"
        }]
    }
)

6. Access Key Management

Manage access keys:

# Create access key
access_key = await create_access_key(user_name="developer")
# Warning: Secret key is only returned once!

# Delete access key
await delete_access_key(
    user_name="developer",
    access_key_id="AKIAIOSFODNN7EXAMPLE"
)

7. Security Simulation

Killer feature: Test permissions BEFORE applying them!

# Simulate policy evaluation
simulation = await simulate_principal_policy(
    policy_source_arn="arn:aws:iam::123456789012:user/developer",
    action_names=["s3:GetObject", "s3:PutObject", "s3:DeleteObject"],
    resource_arns=["arn:aws:s3:::my-bucket/*"],
    context_entries=[
        {
            "ContextKeyName": "aws:SourceIp",
            "ContextKeyValues": ["203.0.113.0/24"],
            "ContextKeyType": "ip"
        }
    ]
)

# Results show:
# - Which actions are allowed or denied
# - Which policies matched
# - Reasons for denial (if any)

Read-Only Mode: Safe Exploration

Why Read-Only Mode?

  • Safety: Prevent accidental modifications in production
  • Testing: Explore IAM resources without risk
  • Auditing: Run server in environments requiring only read access
  • Learning: Learn IAM concepts without fear of breaking things

Enable Read-Only Mode

# Using uvx
uvx awslabs.iam-mcp-server@latest --readonly

# Or locally
python -m awslabs.iam_mcp_server.server --readonly

MCP Client Configuration

{
  "mcpServers": {
    "awslabs.iam-mcp-server": {
      "command": "uvx",
      "args": ["awslabs.iam-mcp-server@latest", "--readonly"],
      "env": {
        "AWS_PROFILE": "your-aws-profile",
        "AWS_REGION": "us-east-1"
      }
    }
  }
}

Operations Blocked

When read-only mode is enabled, these operations return errors:

  • create_user
  • delete_user
  • create_role
  • attach_user_policy
  • detach_user_policy
  • create_access_key
  • delete_access_key

Operations Available

These operations continue to work normally:

  • list_users
  • get_user
  • list_roles
  • list_policies
  • simulate_principal_policy

Installation and Setup

1. Install Server

# Using uv (recommended)
uv tool install awslabs.iam-mcp-server

# Or using pip
pip install awslabs.iam-mcp-server

# Or using Docker/Container
docker pull public.ecr.aws/awslabs-mcp/awslabs/iam-mcp-server:1.0.12

2. Configure AWS Credentials

Option 1: AWS Profile (recommended)

export AWS_PROFILE=your-profile-name

Option 2: Environment Variables

export AWS_ACCESS_KEY_ID=your-access-key
export AWS_SECRET_ACCESS_KEY=your-secret-key
export AWS_REGION=us-east-1

Option 3: IAM Roles

  • Automatically uses IAM roles when running on EC2 or Lambda

3. Required IAM Permissions

The server requires the following IAM permissions:

{
  "Version": "2012-10-17",
  "Statement": [{
    "Effect": "Allow",
    "Action": [
      "iam:ListUsers",
      "iam:GetUser",
      "iam:CreateUser",
      "iam:DeleteUser",
      "iam:ListRoles",
      "iam:GetRole",
      "iam:CreateRole",
      "iam:DeleteRole",
      "iam:ListGroups",
      "iam:GetGroup",
      "iam:CreateGroup",
      "iam:DeleteGroup",
      "iam:AddUserToGroup",
      "iam:RemoveUserFromGroup",
      "iam:AttachGroupPolicy",
      "iam:DetachGroupPolicy",
      "iam:ListAttachedGroupPolicies",
      "iam:ListGroupPolicies",
      "iam:ListPolicies",
      "iam:GetPolicy",
      "iam:CreatePolicy",
      "iam:DeletePolicy",
      "iam:AttachUserPolicy",
      "iam:DetachUserPolicy",
      "iam:AttachRolePolicy",
      "iam:DetachRolePolicy",
      "iam:ListAttachedUserPolicies",
      "iam:ListAttachedRolePolicies",
      "iam:ListUserPolicies",
      "iam:ListRolePolicies",
      "iam:GetUserPolicy",
      "iam:GetRolePolicy",
      "iam:PutUserPolicy",
      "iam:PutRolePolicy",
      "iam:GetGroupsForUser",
      "iam:ListAccessKeys",
      "iam:CreateAccessKey",
      "iam:DeleteAccessKey",
      "iam:SimulatePrincipalPolicy",
      "iam:RemoveUserFromGroup",
      "iam:DeleteUserPolicy",
      "iam:DeleteRolePolicy"
    ],
    "Resource": "*"
  }]
}

4. Configure MCP Client

Amazon Q CLI:

{
  "mcpServers": {
    "awslabs.iam-mcp-server": {
      "command": "uvx",
      "args": ["awslabs.iam-mcp-server@latest"],
      "env": {
        "AWS_PROFILE": "your-aws-profile",
        "AWS_REGION": "us-east-1",
        "FASTMCP_LOG_LEVEL": "ERROR"
      }
    }
  }
}

Kiro:

{
  "mcpServers": {
    "awslabs.iam-mcp-server": {
      "command": "uvx",
      "args": ["awslabs.iam-mcp-server@latest"],
      "env": {
        "AWS_PROFILE": "your-aws-profile",
        "AWS_REGION": "us-east-1",
        "FASTMCP_LOG_LEVEL": "ERROR"
      }
    }
  }
}

Cursor or Cline:

{
  "mcpServers": {
    "awslabs.iam-mcp-server": {
      "command": "uvx",
      "args": ["awslabs.iam-mcp-server@latest"],
      "env": {
        "AWS_PROFILE": "your-aws-profile",
        "AWS_REGION": "us-east-1",
        "FASTMCP_LOG_LEVEL": "ERROR"
      }
    }
  }
}

Cursor or Cline:

{
  "mcpServers": {
    "awslabs.iam-mcp-server": {
      "command": "uvx",
      "args": ["awslabs.iam-mcp-server@latest"],
      "env": {
        "AWS_PROFILE": "your-aws-profile",
        "AWS_REGION": "us-east-1",
        "FASTMCP_LOG_LEVEL": "ERROR"
      }
    }
  }
}

Windows:

{
  "mcpServers": {
    "awslabs.iam-mcp-server": {
      "command": "uv",
      "args": [
        "tool",
        "run",
        "--from",
        "awslabs.iam-mcp-server@latest",
        "awslabs.iam-mcp-server.exe"
      ],
      "env": {
        "AWS_PROFILE": "your-aws-profile",
        "AWS_REGION": "us-east-1"
      }
    }
  }
}

Real-World Use Cases

1. Onboarding New Developers

Prompt: "Create a new developer user named alice.nguyen in the /developers/ path, 
add her to the Developers group, and attach the ReadOnlyAccess policy"

AI Assistant:
1. Creating user alice.nguyen...
2. Adding to Developers group...
3. Attaching ReadOnlyAccess policy...
Done! User alice.nguyen is ready with read-only access.

2. Audit IAM Permissions

Prompt: "Show me all users in the Developers group and their attached policies"

AI Assistant:
Developers Group Members:
1. john.doe
   - Attached Policies: DeveloperPolicy, S3ReadAccess
   - Inline Policies: CustomS3Access
   
2. jane.smith
   - Attached Policies: DeveloperPolicy
   - Inline Policies: None

3. Test Permissions Before Deployment

Prompt: "Test if the EC2-S3-Access-Role can read and write to s3://my-app-bucket/*"

AI Assistant:
Simulating permissions for EC2-S3-Access-Role...

Results:
- s3:GetObject on s3://my-app-bucket/* - ALLOWED
- s3:PutObject on s3://my-app-bucket/* - ALLOWED
- s3:DeleteObject on s3://my-app-bucket/* - DENIED
  Reason: No policy grants this permission

4. Cleanup Old Resources

Prompt: "List all users who haven't been used in the last 90 days and delete them"

AI Assistant:
Found 3 inactive users:
1. old.contractor (last used: 120 days ago)
2. test.user (last used: 150 days ago)
3. temp.account (last used: 200 days ago)

Deleting with force cleanup...
- Deleted old.contractor (removed 2 policies, 1 access key)
- Deleted test.user (removed 1 policy)
- Deleted temp.account (removed 3 policies, 2 access keys)

5. Create Role with Trust Policy

Prompt: "Create a role for Lambda functions to access DynamoDB table users-table"

AI Assistant:
Creating Lambda execution role...

1. Trust policy: Lambda service
2. Permissions: DynamoDB read/write on users-table
3. Role name: Lambda-DynamoDB-Access-Role

Role created: arn:aws:iam::123456789012:role/Lambda-DynamoDB-Access-Role

Security Best Practices

1. Principle of Least Privilege

# Bad: Too broad
policy = {
    "Effect": "Allow",
    "Action": "s3:*",
    "Resource": "*"
}

# Good: Specific
policy = {
    "Effect": "Allow",
    "Action": ["s3:GetObject", "s3:PutObject"],
    "Resource": "arn:aws:s3:::my-bucket/app-data/*"
}

2. Use Roles for Applications

# Prefer roles over users for applications
role = await create_role(
    role_name="App-S3-Access-Role",
    assume_role_policy_document=trust_policy
)

# Avoid creating users with access keys for applications

3. Permissions Boundaries

# Set maximum permissions
await create_user(
    user_name="contractor",
    permissions_boundary="arn:aws:iam::123456789012:policy/ContractorBoundary"
)

4. Policy Simulation

# ALWAYS test before applying
simulation = await simulate_principal_policy(
    policy_source_arn=user_arn,
    action_names=["s3:DeleteBucket"],
    resource_arns=["arn:aws:s3:::production-bucket"]
)

if simulation["EvaluationResults"][0]["EvalDecision"] == "allowed":
    print("WARNING: User can delete production bucket!")

5. Regular Access Reviews

# List users and check last used
users = await list_users()
for user in users:
    user_details = await get_user(user_name=user["UserName"])
    # Check PasswordLastUsed, AccessKeys last used
    # Remove unused users and keys

6. Access Key Rotation

# Rotate access keys regularly
old_keys = await list_access_keys(user_name="developer")
new_key = await create_access_key(user_name="developer")

# After application is updated with new key
for old_key in old_keys:
    await delete_access_key(
        user_name="developer",
        access_key_id=old_key["AccessKeyId"]
    )

7. Prefer Managed Policies

# Use managed policies for reusable permissions
await attach_user_policy(
    user_name="developer",
    policy_arn="arn:aws:iam::aws:policy/ReadOnlyAccess"
)

# Use inline policies only for unique permissions
await put_user_policy(
    user_name="developer",
    policy_name="UniqueS3Access",
    policy_document=unique_policy
)

Error Handling

The server provides comprehensive error handling:

Authentication Errors

Error: Unable to locate credentials. Configure AWS credentials using:
- AWS_PROFILE environment variable
- AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY
- IAM role (when running on AWS)

Permission Errors

Error: User lacks permission: iam:CreateUser
Required permissions: iam:CreateUser on resource: *

Resource Not Found

Error: User 'john.doe' not found in account 123456789012

Validation Errors

Error: Invalid trust policy document:
- Missing required field: Version
- Invalid Principal format


Container Deployment

Using Docker

# Pull the image
docker pull public.ecr.aws/awslabs-mcp/awslabs/iam-mcp-server:1.0.12

# Run in read-only mode
docker run -e AWS_PROFILE=your-profile \
  -e AWS_REGION=us-east-1 \
  -v ~/.aws:/root/.aws:ro \
  public.ecr.aws/awslabs-mcp/awslabs/iam-mcp-server:1.0.12 \
  --readonly

# Run with write access
docker run -e AWS_PROFILE=your-profile \
  -e AWS_REGION=us-east-1 \
  -v ~/.aws:/root/.aws:ro \
  public.ecr.aws/awslabs-mcp/awslabs/iam-mcp-server:1.0.12

Using Amazon ECS

{
  "family": "iam-mcp-server",
  "taskRoleArn": "arn:aws:iam::123456789012:role/IAMMCPServerRole",
  "containerDefinitions": [
    {
      "name": "iam-mcp-server",
      "image": "public.ecr.aws/awslabs-mcp/awslabs/iam-mcp-server:1.0.12",
      "command": ["--readonly"],
      "environment": [
        {
          "name": "AWS_REGION",
          "value": "us-east-1"
        }
      ],
      "logConfiguration": {
        "logDriver": "awslogs",
        "options": {
          "awslogs-group": "/ecs/iam-mcp-server",
          "awslogs-region": "us-east-1",
          "awslogs-stream-prefix": "ecs"
        }
      }
    }
  ]
}

Using Kubernetes

apiVersion: apps/v1
kind: Deployment
metadata:
  name: iam-mcp-server
spec:
  replicas: 1
  selector:
    matchLabels:
      app: iam-mcp-server
  template:
    metadata:
      labels:
        app: iam-mcp-server
    spec:
      serviceAccountName: iam-mcp-server
      containers:
      - name: iam-mcp-server
        image: public.ecr.aws/awslabs-mcp/awslabs/iam-mcp-server:1.0.12
        args: ["--readonly"]
        env:
        - name: AWS_REGION
          value: "us-east-1"

Statistics and Adoption

Official Statistics (as of 2026-01-24):

  • Downloads: 6,800+ from Amazon ECR Public Gallery
  • Version: 1.0.12 (updated 9 days ago)
  • Publisher: AWS Labs MCP (Verified Account)
  • Container Registry: Amazon ECR Public Gallery
  • License: Apache License 2.0

Supported MCP Clients:

  • Amazon Q CLI
  • Kiro
  • Cursor
  • Cline
  • Claude Desktop
  • VS Code with MCP extension

Test Results (Real AWS Account)

Tested on: 2026-01-24

AWS Account: 067847735476
Region: us-east-1
User: admin

Test 1: List Users

aws iam list-users

Result: SUCCESS - Found 1 user (admin) with AdministratorAccess

Test 2: Get User Details

aws iam get-user --user-name admin

Result: SUCCESS - Retrieved full user information including ARN and creation date

Test 3: List Attached Policies

aws iam list-attached-user-policies --user-name admin

Result: SUCCESS - AdministratorAccess policy attached

Test 4: List IAM Roles

aws iam list-roles --max-items 5

Result: SUCCESS - Found 5+ roles including:

  • AWS-QuickSetup-HostMgmtRole (multiple regions)
  • Trust policy: ssm.amazonaws.com
  • Max session: 3600 seconds

Test 5: List Custom Policies

aws iam list-policies --scope Local

Result: SUCCESS - Found 3 custom policies:

  • terraform-20260121174219249600000002
  • jenkins_lc_policy
  • pavm_cw_policy

Summary

Test Status Response Time
List Users PASS <1s
Get User PASS <1s
List Policies PASS <1s
List Roles PASS <1s
Custom Policies PASS <1s

All tests passed successfully. IAM MCP Server is working perfectly in read-only mode.


Production Ready

The IAM MCP Server has been tested and verified on real AWS infrastructure:

  • All read operations working correctly
  • Fast response times (under 1 second)
  • Accurate data retrieval
  • Safe read-only mode operational
  • Ready for AI assistant integration

Advanced Features

1. Path-Based Organization

# Organize resources using paths
await create_user(
    user_name="alice",
    path="/company/engineering/backend/"
)

# List by path
users = await list_users(path_prefix="/company/engineering/")

2. Max Session Duration

# Control session duration for roles
await create_role(
    role_name="ShortLivedRole",
    assume_role_policy_document=trust_policy,
    max_session_duration=3600  # 1 hour
)

3. Context-Based Simulation

# Test with specific conditions
simulation = await simulate_principal_policy(
    policy_source_arn=user_arn,
    action_names=["s3:GetObject"],
    resource_arns=["arn:aws:s3:::bucket/*"],
    context_entries=[
        {
            "ContextKeyName": "aws:SourceIp",
            "ContextKeyValues": ["203.0.113.0/24"],
            "ContextKeyType": "ip"
        },
        {
            "ContextKeyName": "aws:CurrentTime",
            "ContextKeyValues": ["2024-01-24T09:00:00Z"],
            "ContextKeyType": "date"
        }
    ]
)

Development

Running Tests

# Install development dependencies
uv sync --dev

# Run tests
uv run pytest

# Run with coverage
uv run pytest --cov=awslabs.iam_mcp_server

Local Development

# Install in development mode
uv pip install -e .

# Run server directly
python -m awslabs.iam_mcp_server.server

# Run with debug logging
FASTMCP_LOG_LEVEL=DEBUG python -m awslabs.iam_mcp_server.server

Conclusion

The AWS IAM MCP Server is a powerful tool that:

  • Automates IAM management with natural language
  • Increases productivity by eliminating the need to remember AWS CLI syntax
  • Reduces errors through policy simulation before applying changes
  • Enhances safety with read-only mode and force delete with cleanup
  • Implements security best practices by design

When to Use

Recommended for:

  • Managing multiple IAM users, roles, and groups
  • Regular IAM permission audits
  • User onboarding and offboarding
  • Testing IAM policies
  • Learning IAM concepts

Use with caution:

  • Production environments (use read-only mode)
  • When lacking proper IAM permissions
  • Without understanding basic IAM concepts

Resources

from github.com/vanhoangkha/AWS-IAM-MCP-Server-Intelligent-IAM-Management-with-AI

Installing AWS IAM MCP Server Intelligent IAM Management With AI

This server has no published package — it is built from source. Open the repository and follow its README.

▸ github.com/vanhoangkha/AWS-IAM-MCP-Server-Intelligent-IAM-Management-with-AI

FAQ

Is AWS IAM MCP Server Intelligent IAM Management With AI MCP free?

Yes, AWS IAM MCP Server Intelligent IAM Management With AI MCP is free — one-click install via Unyly at no cost.

Does AWS IAM MCP Server Intelligent IAM Management With AI need an API key?

No, AWS IAM MCP Server Intelligent IAM Management With AI runs without API keys or environment variables.

Is AWS IAM MCP Server Intelligent IAM Management With AI hosted or self-hosted?

Self-hosted: the server runs locally on your machine via the install command above.

How do I install AWS IAM MCP Server Intelligent IAM Management With AI in Claude Desktop, Claude Code or Cursor?

Open AWS IAM MCP Server Intelligent IAM Management With AI on unyly.org, pick your client tab (Claude Desktop, Claude Code, Cursor) and press Install — the config is generated automatically, no JSON editing.

Related MCPs

Compare AWS IAM MCP Server Intelligent IAM Management With AI with

Not sure what to pick?

Find your stack in 60 seconds

Author?

Embed badge for your README

Browse similar

All ai MCPs