Skip to main content

Local credential broker for humans and AI agents, AWS-first

Project description

grantry

A local credential broker for humans and AI agents. AWS first.

grantry logs you into AWS IAM Identity Center once, then hands out short lived credentials on demand. You get a clean command line. Your AI coding agents get the same credentials over MCP, but only for the accounts and roles you allow, only for as long as you permit, and every request is written to an audit log.

Everything stays on your machine. grantry talks to AWS and nothing else. No account, no server, no telemetry. Tokens live in the OS keychain, never in a plain file, and no secret is ever written to a log.

CI License: Apache 2.0 Python


Why grantry exists

Every other credential tool assumes a person is at the keyboard. But agents are now heavy users of cloud credentials, and they are bad at logging in. They cannot click a device flow link, and they stall when a session expires. The common workaround is pasting long lived keys into the agent's environment. Those keys never expire and are never audited. That is a real security problem.

grantry removes the workaround. The agent asks, grantry checks your rules, and hands over short lived credentials or a clear refusal. You keep one login, one policy, and one audit trail across every agent on your machine.

Install

Once grantry is published to PyPI:

uvx grantry --help        # run without installing
# or
pipx install grantry

Until then, install from source:

git clone https://github.com/saimeda32/grantry
cd grantry
uv sync
uv run grantry --help

Works on macOS, Linux, and Windows. Python 3.10 or newer.

Quick start

# 1. Point grantry at your Identity Center, just once. It remembers.
grantry --start-url https://your-org.awsapps.com/start --region us-east-1 login

# 2. Generate a starter policy from your real access.
grantry init

# 3. See what you can reach.
grantry ls

# 4. Run any command as a role.
grantry run my-dev/AWSReadOnlyAccess -- aws s3 ls

After grantry login, the native aws CLI, boto3, and Terraform work too. Run grantry populate once to create the matching profiles in ~/.aws/config, then use aws --profile ... with no grantry in the loop.

Commands

Command What it does
grantry login Log in to Identity Center once, for all accounts and roles.
grantry ls List the account and role identities you can use.
grantry run <id> -- <cmd> Run a command as a chosen identity.
grantry switch <id> Print shell exports so eval "$(grantry switch <id>)" adopts an identity.
grantry populate Write ~/.aws/config profiles for your access. Adds, updates, and prunes only its own profiles.
grantry check Diagnose your session and access, with clear exit codes.
grantry init Generate a working policy from your real access.
grantry audit Print the grant history, or write an HTML timeline with --visualize.
grantry graph Write an HTML map of what your agents can reach under the policy.
grantry mcp Run grantry as an MCP server for agents.
grantry install [client] Add grantry to an AI client's MCP config. Auto detects all if none named.
grantry admin assignments --as <id> Crawl who has what across the whole org. Admin only.
grantry logout Clear the saved session for the current instance.
grantry instances / grantry use <name> List remembered orgs, or switch between them.
grantry install / grantry uninstall Add or remove grantry from an AI client's MCP config.
grantry version Print the version.

Use it with your AI agents

One command wires grantry into your AI clients:

grantry install            # auto detect every client you have
grantry install cursor     # or a specific one
grantry install --dry-run  # preview without writing

Supported: claude-code, claude-desktop, cursor, windsurf, vscode. grantry is added without touching your other MCP servers, and each client gets its own audit label. Restart the client to load it.

The agent then has four tools: whoami, list_identities, get_credentials(identity, ttl), and check_access(identity). If no one is logged in, the agent can call request_login, which notifies you and waits for your approval, then resumes on its own.

Policy

Write ~/.grantry/policy.yaml, or let grantry init generate it from your real access. See examples/policy.yaml.

agents:
  allow:
    - identity: "*/AWSReadOnlyAccess"
    - identity: "dev-*/AWSPowerUserAccess"
  deny:
    - identity: "*prod*/*Admin*"
  max_ttl: 15m
humans:
  max_ttl: 12h

Three rules govern it:

  1. A deny always beats an allow.
  2. For agents, anything not allowed is refused. Safe by default.
  3. For you, anything not mentioned is allowed.

An identity is account-name/role-name, and * is a wildcard, so dev-*/AWSReadOnlyAccess means read only in any account whose name starts with dev.

A note on TTL and AWS: grantry cannot shorten an SSO credential below the lifetime AWS issues it with, because the reserved SSO roles do not allow client side re assumption. grantry reports the real AWS expiration and adds an advisory when a credential outlives your policy cap. The real control for short sessions is the permission set session duration, set by an admin in IAM Identity Center.

Admin: see who has what across the org

grantry admin assignments --as your-mgmt/AWSAdministratorAccess --visualize

This crawls the whole organization and writes an interactive graph of principals, permission sets, and accounts, with the links between them. It is safe to offer because AWS is the gatekeeper: only an identity that can assume a management or delegated admin role gets any data. The crawl caches principal names and uses retry hardening, so it handles organizations with thousands of assignments.

How your data is stored

grantry uses no database. It is a single user local tool.

  • Secrets (SSO tokens) live in the OS keychain, through keyring.
  • State lives as plain files in ~/.grantry/: instance.json, policy.yaml, and an append only audit.jsonl (mode 0600).
  • Interop: grantry login also writes the AWS CLI token cache in ~/.aws/sso/cache/, the same file aws sso login writes, so the native tools work.

Everything survives reboots. To remove grantry state: grantry logout and rm -rf ~/.grantry.

Security

  • Secrets live only in the OS keychain. Redaction happens in one place, so no log line can leak a token.
  • The MCP server is not a network service. It talks to the agent that started it over stdio.
  • Credentials are short lived and scoped to what the policy allows.
  • Every grant is recorded in ~/.grantry/audit.jsonl, and never includes the credentials themselves.

See SECURITY.md to report a vulnerability.

Roadmap

grantry v1 covers AWS Identity Center. The provider layer is written so Azure and GCP can be added without touching the engine, policy, audit, or MCP surface. Team mode (shared, signed policy) comes after that.

Contributing

See CONTRIBUTING.md. In short: fork, branch, write a test, keep ruff, mypy, and pytest green, open a pull request.

License

Apache 2.0.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

grantry-0.1.0.tar.gz (85.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

grantry-0.1.0-py3-none-any.whl (50.2 kB view details)

Uploaded Python 3

File details

Details for the file grantry-0.1.0.tar.gz.

File metadata

  • Download URL: grantry-0.1.0.tar.gz
  • Upload date:
  • Size: 85.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for grantry-0.1.0.tar.gz
Algorithm Hash digest
SHA256 6acc9f5d731841b552d47f9f97bac05ef0bbc47edf454b975c915f863dab9e73
MD5 97364f523083c2a4e7863b16e787368f
BLAKE2b-256 7746b6fbe471f621d3b7adf274f00ab62134af5c8392311c95298bc310cd513c

See more details on using hashes here.

Provenance

The following attestation bundles were made for grantry-0.1.0.tar.gz:

Publisher: publish.yml on saimeda32/grantry

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file grantry-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: grantry-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 50.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for grantry-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c617b242ed904272410338321b31cc151f879d9a923569a0f06645603d56be90
MD5 328f217d09cc637c1bb7b632c5d2ec88
BLAKE2b-256 206086d10fc5554e1d1fb70c93d33ab9e94823c5bfa8e382464502b99c97549c

See more details on using hashes here.

Provenance

The following attestation bundles were made for grantry-0.1.0-py3-none-any.whl:

Publisher: publish.yml on saimeda32/grantry

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page