Skip to main content
Glama

⚡ AWS-Auth

Fast, Intelligent AWS SSO Authentication & Model Context Protocol (MCP) Server

CI Release License: MIT Python Version MCP Ready

Eliminate AWS SSO login fatigue. Zero configuration boilerplate, smart role prioritization, atomic credential caching, and native AI pair-programming integration.

Quick Start • Why aws-auth? • AI / MCP Integration • Features • Documentation


  ┌───────────────────────┐       ┌────────────────────────┐       ┌───────────────────────┐
  │  IAM Identity Center  │ ────> │       aws-auth         │ ────> │  ~/.aws/credentials   │
  │     (AWS SSO OIDC)    │       │  (Smart Role Selector) │       │ (Strict 0600 POSIX)   │
  └───────────────────────┘       └───────────┬────────────┘       └───────────┬───────────┘
                                              │                                │
                                  ┌───────────▼────────────┐       ┌───────────▼───────────┐
                                  │   MCP Server (stdio)   │       │ Terraform / K8s / CLI │
                                  │ (Claude / Cursor / AI) │       │ (Instant Compatibility)│
                                  └────────────────────────┘       └───────────────────────┘

💡 Why aws-auth vs Alternatives?

Feature

aws-auth

Official aws sso login

granted / assume

aws-vault

Zero-Config Account Discovery

✅ Automatic

❌ Requires manual ~/.aws/config

⚠️ Partial

❌ Manual

Model Context Protocol (MCP)

✅ Native built-in

❌ None

❌ None

❌ None

1-Second MRU / Pinned Logins

✅ Smart Prioritization

❌ None

⚠️ History prompt

❌ None

Real-time Substring & Alias Filter

✅ Instant typing

❌ None

✅ Yes

❌ None

Direct ~/.aws/credentials Sync

✅ Atomic & 0600

❌ Token cache only

⚠️ Shell wrapper

⚠️ Keychain wrapper

Legacy & GUI Tool Compatibility

✅ 100% Out of Box

⚠️ Many tools fail

⚠️ Requires wrapper

⚠️ Requires wrapper

WSL2 -> Windows Browser Bridge

✅ Automatic

❌ Fails / manual copy

⚠️ Partial

❌ No

EC2 SSM & EKS Context Switching

✅ Built-in

❌ Separate tools

❌ Separate tools

❌ No

👉 Read the full Feature Comparison Guide.


Related MCP server: MCP SysOperator

✨ Key Features

  • 🎯 AWS Best-Practice Named Profiles: Credentials are kept in named profile sections (e.g., [staging-admin]) and scoped to your terminal session via export AWS_PROFILE, preventing unsafe overwrites to [default].

  • ⚡ Zero-Boilerplate Discovery: No need to maintain hundreds of lines in ~/.aws/config. Enter your SSO Start URL once, and all authorized accounts and roles are loaded dynamically.

  • ⭐ Smart Role Prioritization (MRU): Automatically pins your most recently used roles (e.g. QA Admin, Prod Admin) to #1 and #2. Pressing Enter logs you in within 1 second.

  • 🔍 Interactive Substring Search: Type any keyword (prod, qa, admin, gpu, eks) at the selection prompt to instantly filter dozens of accounts.

  • 🤖 Native Model Context Protocol (MCP) Server: Expose AWS profile switching, caller identity, and EC2/EKS exploration to LLM pair programmers (Claude Desktop, Cursor, Antigravity, Gemini).

  • 🔒 Enterprise-Grade Security: Strict POSIX 0600 file permissions, atomic file replacement (os.replace), and 300-second expiration safety margins.

  • 🌐 WSL2 Seamless Browser Bridge: Automatically detects WSL2 and opens authorization URLs directly in your Windows host browser.

  • ☸️ DevOps Acceleration: Instant EC2 SSM shell sessions and 1-click Amazon EKS kubeconfig context switching.

  • Private Aurora/RDS Access: Three modes: token-only over VPN, SSM plus IAM-authenticated psql for DevOps, and SSM plus a private token file for an agent's database driver.

  • Connection Diagnostics & Isolated Commands: Check prerequisites with aws-auth doctor, or run tools under a named profile using aws-auth exec.


📦 Installation

Download the latest pre-compiled binary from GitHub Releases:

Windows (PowerShell 1-Liner)

Run in PowerShell to automatically download the binary, configure PATH, and set up shell integration:

irm https://raw.githubusercontent.com/N0mansky/aws-auth/main/install.ps1 | iex

Or manual download via PowerShell:

curl.exe -L https://github.com/N0mansky/aws-auth/releases/latest/download/aws-auth-windows-amd64.exe -o aws-auth.exe

Linux (x86_64)

curl -L https://github.com/N0mansky/aws-auth/releases/latest/download/aws-auth-linux-amd64 -o aws-auth
chmod +x aws-auth && sudo mv aws-auth /usr/local/bin/

macOS (Universal)

curl -L https://github.com/N0mansky/aws-auth/releases/latest/download/aws-auth-macos-universal -o aws-auth
chmod +x aws-auth && sudo mv aws-auth /usr/local/bin/

Option 2: Clone & Install from Source (Automated Shell Setup)

install.sh and install.ps1 automatically configure the shell integration wrapper in your shell profile:

git clone https://github.com/N0mansky/aws-auth.git
cd aws-auth

./install.sh                      # Linux / macOS / WSL2 (configures ~/.zshrc, ~/.bashrc)
powershell .\install.ps1          # Windows (PowerShell - configures $PROFILE)
.\install.bat                     # Windows (Command Prompt)

Option 3: Install via pip

pip install git+https://github.com/N0mansky/aws-auth.git

🐚 Shell Integration (AWS_PROFILE)

To enable seamless session scoping without child-process limitations, install.sh and install.ps1 automatically install a shell wrapper.

If you installed manually or via pip, add this block to your ~/.zshrc, ~/.bashrc, or ~/.profile:

# >>> aws-auth shell wrapper >>>
# Auto-export active profile on shell startup if present
if [ -z "${AWS_PROFILE:-}" ] && [ -f ~/.aws-auth/current_profile ]; then
    export AWS_PROFILE="$(cat ~/.aws-auth/current_profile)"
fi

# Scopes active profile to current terminal session via AWS_PROFILE
aws-auth() {
    command /usr/local/bin/aws-auth "$@"
    local ret=$?
    case "${1:-}" in
        rds|doctor|exec|--mcp|--credential-process|--export-env|--identity|--current-profile|--list-profiles|--version|--help)
            return "$ret" ;;
    esac
    if [ $ret -eq 0 ] && [ -f ~/.aws-auth/current_profile ]; then
        export AWS_PROFILE="$(cat ~/.aws-auth/current_profile)"
    fi
    return $ret
}
# <<< aws-auth shell wrapper <<<

Reload your shell or run source ~/.zshrc (or source ~/.bashrc). Terminal prompts like Starship (☁️ <profile>) and tools like kubectl or aws will instantly reflect your active profile!

When running python aws-auth.py or the binary directly, login saves the selected profile but cannot change the parent shell. An existing AWS_PROFILE continues to take precedence. To activate the most recent login in Bash/Zsh, run:

export AWS_PROFILE="$(cat ~/.aws-auth/current_profile)"
python aws-auth.py rds list

Alternatively, use python aws-auth.py rds list --profile staging-admin to select a profile for one command. An expired shell profile never causes an automatic switch to another account. EC2/EKS --no-auth skips browser login and uses noninteractive credential renewal where possible; profiles without renewal metadata require login to the same account/role.


🚀 Quick Start

1. Interactive Login

aws-auth
Available account-role combinations (Showing 1-10 of 18):
+-----+------------------------------+-----------------+------------------------------+-------------+
| #   | Account                      | Account ID      | Role                         | Region      |
+-----+------------------------------+-----------------+------------------------------+-------------+
| 1   | ⭐ Production-App (PROD)        | (111222333444)  | AdministratorAccess     | us-east-1   |
| 2   | ⭐ Staging-Web (QA)          | (555666777888)  | AdministratorAccess     | us-east-1   |
| 3   | Analytics-Data                  | (999888777666)  | AdministratorAccess     | us-east-1   |
...
Select number 1-10 (default: 1) (type keyword to filter): [ENTER]

✅ Profile 'production-app-admin' saved to ~/.aws/credentials.
✅ Active profile set to: production-app-admin (scoped via AWS_PROFILE)

If an agent gets ExpiredToken: With MCP, call aws_ensure_credentials for the same profile and retry once after success. In a shell, wrap the intended command so aws-auth renews credentials before running it, for example:

aws-auth exec --profile dev-readonly -- aws sts get-caller-identity

If renewal requires interactive login, run aws-auth and select the same account and role. --refresh-cache refreshes the account list, not credentials.

2. Configure Portal & Custom Aliases

aws-auth --configure

Customize environment labels and preferred accounts in ~/.aws-auth/config.json:

{
  "sso_start_url": "https://my-company.awsapps.com/start",
  "sso_region": "us-east-1",
  "preferred_accounts": ["Staging-Web", "Production-App"],
  "aliases": {
    "555666777888": "QA",
    "111222333444": "PROD"
  }
}

3. Connect to a Private Aurora Database

Choose the mode that matches the client's network access and interface:

Mode

Network path

Client

Token only

Existing Client VPN or VPC access

Agent/application's own database driver

Connect + token, interactive

SSM tunnel managed by aws-auth

DevOps psql session

Connect + token, external client

SSM tunnel managed by aws-auth

Agent's own driver, using a private JSON file

RDS discovery displays a numbered table with identifier, kind, engine, status, endpoint, port, and IAM authentication. Add --json for machine-readable output.

For an AI agent or application, generate a token for its own database driver:

aws-auth rds list --profile dev-readonly --json
aws-auth rds token staging-db --profile dev-readonly --reader --username agent_reader --json

The agent's database client should capture the JSON programmatically and use token as its connection password, keeping it out of chat, tool results, and logs. It connects directly to the selected endpoint using TLS with hostname verification and the AWS RDS CA bundle. Token generation needs no psql, AWS CLI, Session Manager plugin, or EC2 bridge. IAM authentication and the SQL user's privileges must already be configured. Use a dedicated read-only SQL user for agents. See the driver example and token lifecycle.

Tokens are valid for 15 minutes to establish a connection; an established session continues after token expiry. Generate a fresh token when reconnecting. --reader and --writer select endpoints; omitting both selects the writer/instance endpoint. The driver's host must match the endpoint used for signing. A reader endpoint alone does not enforce read-only access when Aurora has no replicas; SQL grants provide that boundary.

For DevOps on-call access when VPN is unavailable, open a tunnel and IAM-authenticated interactive psql session:

aws-auth rds connect staging-db --profile staging-admin --username db_user --select-database

For an AI agent that needs an SSM tunnel, hand connection settings to its driver without starting psql:

aws-auth --non-interactive rds connect staging-db --profile dev-readonly --reader \
  --username agent_reader --database appdb \
  --token-file ~/.aws-auth/staging-db.credentials.json

Keep this process running, or have the agent launch it as a managed background process. After the file appears, its driver reads connection from the JSON and connects through the local tunnel. The file contains the token, actual hostname for TLS verification, local address/port, database/user, and CA bundle path. It is written atomically with POSIX mode 0600 and removed when the owner exits normally, is interrupted, or receives SIGTERM. The owner also closes the tunnel. Tokens are not refreshed automatically; see agent tunnel lifecycle and driver example.

For a tunnel only, omit --username:

aws-auth doctor --profile staging-admin --region us-east-1 --target i-0123456789abcdef0 --local-port 15432
aws-auth rds connect staging-db --profile staging-admin --region us-east-1 --via i-0123456789abcdef0 --local-port 15432

For DevOps, run aws-auth rds connect staging-db --profile staging-admin; the CLI randomly picks a running EC2 instance with a compatible online SSM agent and remembers it for that account, region, and database. No tags or selection prompt are required. The local port defaults to the database port. An unavailable saved bridge triggers automatic discovery again. Use --choose-via to pick again or --via for an explicit override; add --remember-via to save an explicit override. The chosen instance must have network access to the database. See bridge selection and permissions.

Keep a tunnel-only session running while a database client connects. --username optionally manages an IAM-authenticated psql session and closes the tunnel on exit. --command and --file remain available for DevOps scripts through SSM. See the Aurora/RDS access guide for prerequisites and TLS hostname handling.


🤖 AI Agent Integration (Model Context Protocol)

Use the MCP integration guide to connect an agent over stdio, recover expired credentials, and inspect available tools. Profile selection stays within the MCP server.


🛠️ CLI Command Reference

# Core Authentication
aws-auth                     # Interactive SSO login & smart role switch
aws-auth --configure         # Interactive SSO portal setup
aws-auth --identity          # Show current STS caller identity
aws-auth --refresh-cache     # Force refresh remote account/role metadata
aws-auth --write-default     # Opt-in to write/sync credentials to [default] section

# Profile Management & Session Scoping
aws-auth --list-profiles          # List all stored AWS profiles (* marks active)
aws-auth --current-profile        # Print active profile name (fast query)
aws-auth -p, --use-profile NAME   # Activate named profile in current session
aws-auth -s, --switch-profile     # Interactive profile switcher
aws-auth --set-default NAME       # Copy profile credentials to [default] section
aws-auth --delete NAME            # Delete profile credentials

# Resource Discovery & DevOps
aws-auth --list-ec2          # List EC2 instances and connect via SSM
aws-auth --list-eks          # List EKS clusters and update kubeconfig

# Scripting & Headless Automation
aws-auth --current-profile --json # JSON output {"current_profile": "..."}
aws-auth --list-profiles --json
aws-auth --identity --json
eval $(aws-auth --export-env prod-profile)  # Export AWS keys to current shell

# AWS credential_process standard
aws-auth --credential-process my-profile

# Agent/client database access over VPN (capture token output inside the client)
aws-auth rds list --profile dev-readonly --json
aws-auth rds token staging-db --profile dev-readonly --reader --username agent_reader --json

# Agent/client database access through SSM (keep owner running; read JSON in driver)
aws-auth --non-interactive rds connect staging-db --reader --username agent_reader --database appdb --token-file ~/.aws-auth/staging-db.credentials.json

# DevOps fallback through SSM when VPN is unavailable
aws-auth rds connect staging-db --profile staging-admin --via i-0123456789abcdef0 --local-port 15432
aws-auth rds connect staging-db --reader --profile staging-admin --via i-0123456789abcdef0 --local-port 15433
aws-auth rds connect staging-db --profile staging-admin --username db_user --database appdb
aws-auth rds connect staging-db --username db_user --select-database
aws-auth rds connect staging-db --writer --username db_user --database appdb --file queries.sql --csv
aws-auth rds token staging-db --profile staging-admin --username db_user
aws-auth doctor --profile staging-admin --target i-0123456789abcdef0 --json
aws-auth exec --profile dev-readonly -- aws sts get-caller-identity

Regions resolve from --region, AWS_REGION, AWS_DEFAULT_REGION, the selected profile, then us-east-1. New logins save role expiration and renewal metadata. --credential-process renews credentials noninteractively when needed and returns Expiration when available. Older expired profiles require one fresh interactive login to save this metadata. rds token explicitly writes a sensitive authentication token to stdout; do not log its output.


📚 Documentation


🛠️ Development & Testing

Unified commands are provided via the Makefile:

make help          # View all available targets
make venv          # Initialize virtual environment and install dev dependencies
make test          # Run automated unit tests with pytest
make check         # Run full quality gate (secret scanning, Bandit SAST, audit, tests)
make build         # Compile standalone PyInstaller binary
make install       # Build and install dependencies plus shell integration

🤝 Contributing

Contributions are welcome! Please check out CONTRIBUTING.md for details on setting up a development environment, testing standards, and security policies.


📄 License

This project is licensed under the MIT License.

Available Tools

10 tools
aws_connection_diagnosticsB

Check identity, local dependencies, and SSM prerequisites without starting a session.

Inputs: region, target, local_port, profile_name. Returns: result

aws_ensure_credentialsA

Check if AWS credentials are valid, and automatically refresh using cached SSO refresh token if expired.

Args: profile_name: AWS profile name (defaults to the selected or active profile).

Inputs: profile_name. Returns: result

aws_get_caller_identityB

Get current AWS caller identity (Account ID, IAM Role/User ARN, User ID) using STS.

Args: profile_name: Optional profile name; otherwise uses the MCP server's selected profile.

Inputs: profile_name. Returns: result

aws_get_session_envC

Get profile environment; raw credentials require explicit include_credentials=True.

Args: profile_name: AWS profile name (defaults to the selected or active profile). include_credentials: Explicitly include sensitive raw credentials in the response.

Inputs: profile_name, include_credentials. Returns: result

aws_list_ec2_instancesB

List EC2 instances in a specific AWS region using the specified profile.

Args: region: AWS region (e.g. 'us-east-1', 'us-west-2') profile_name: AWS profile name to use (defaults to the selected or active profile).

Inputs: region, profile_name. Returns: result

aws_list_eks_clustersB

List EKS clusters in a specific AWS region and optionally configure local ~/.kube/config.

Args: region: AWS region (e.g. 'us-east-1', 'us-west-2') profile_name: AWS profile name to use (defaults to the selected or active profile). update_kubeconfig: If True, automatically configures kubeconfig for found clusters

Inputs: region, profile_name, update_kubeconfig. Returns: result

aws_list_profilesA

List all available local AWS profiles, current active default profile, and configured regions.

Inputs: no named parameters. Returns: result

aws_list_rds_databasesC

Discover Aurora clusters and standalone RDS instances without fetching secrets.

Inputs: region, profile_name. Returns: result

aws_switch_profileB

Select a named profile for this MCP server without modifying default credentials.

Args: profile_name: Name of the AWS profile to use in subsequent tool calls.

Inputs: profile_name (required). Returns: result

aws_update_kubeconfigB

Configure local kubeconfig to connect to a specific EKS cluster.

Args: cluster_name: Name of the EKS cluster region: AWS region of the cluster profile_name: AWS profile name to authenticate with

Inputs: cluster_name (required), region, profile_name. Returns: result

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A3.5/5.0

    Scored across 10 tools

    Disambiguation4/5

    Most tools have clearly distinct purposes (profile switching, credential refresh, identity lookup, resource listing). However, aws_connection_diagnostics overlaps slightly with aws_get_caller_identity and aws_ensure_credentials since it also checks identity and prerequisites, and aws_list_eks_clusters can optionally configure kubeconfig, duplicating aws_update_kubeconfig's role.

    Naming Consistency4/5

    All tools share the aws_ prefix and most follow an aws_verb_noun pattern (e.g., aws_switch_profile, aws_list_rds_databases, aws_get_caller_identity). The outlier is aws_connection_diagnostics, which uses a noun phrase instead of a verb, breaking the otherwise consistent convention.

    Tool Count5/5

    Ten tools is well-scoped for an AWS authentication and connectivity server. Each tool covers a distinct aspect of profile management, credential handling, identity verification, diagnostics, or resource discovery without feeling bloated.

    Completeness4/5

    The surface covers the core auth lifecycle: listing and switching profiles, validating/refreshing credentials, retrieving identity and session environment, and running diagnostics. Minor gaps exist around explicit credential clearing or role assumption, but the essential workflows are present.

    Maintenance

    ActivityMaintained
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      C
      quality
      D
      maintenance
      A Model Context Protocol (MCP) server that enables AI assistants like Claude to interact with your AWS environment. This allows for natural language querying and management of your AWS resources during conversations. Think of better Amazon Q alternative.
      3
      296
      ISC
    • A
      license
      C
      quality
      Not graded
      maintenance
      An MCP server for Infrastructure as Code that enables AI assistants to manage cloud resources through Ansible and Terraform operations. It supports executing playbooks, managing AWS services, and running Terraform commands with optional LocalStack integration.
      18
      -
    • A
      license
      A
      quality
      B
      maintenance
      A small AWS MCP for AI assistants: one server, one config entry, SSO re-auth baked in, generic CRUD over hundreds of resource types, live docs lookup, server-side scripting for batched workflows.
      30
      819 npm
      5
      MIT
    • A
      license
      Not graded
      quality
      D
      maintenance
      A Model Context Protocol (MCP) server that enables AI assistants to perform comprehensive AWS security analysis through natural language queries, bridging AI with AWS security services.
      2
      Apache 2.0