grantry 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (65) hide show
  1. grantry-0.1.0/.github/dependabot.yml +15 -0
  2. grantry-0.1.0/.github/workflows/ci.yml +29 -0
  3. grantry-0.1.0/.github/workflows/codeql.yml +23 -0
  4. grantry-0.1.0/.github/workflows/publish.yml +20 -0
  5. grantry-0.1.0/.gitignore +9 -0
  6. grantry-0.1.0/CONTRIBUTING.md +58 -0
  7. grantry-0.1.0/LICENSE +202 -0
  8. grantry-0.1.0/PKG-INFO +212 -0
  9. grantry-0.1.0/README.md +198 -0
  10. grantry-0.1.0/SECURITY.md +35 -0
  11. grantry-0.1.0/docs/OVERVIEW.md +210 -0
  12. grantry-0.1.0/docs/index.html +122 -0
  13. grantry-0.1.0/docs/superpowers/plans/2026-07-15-grantry-phase1.md +2220 -0
  14. grantry-0.1.0/docs/superpowers/specs/2026-07-15-grantry-design.md +216 -0
  15. grantry-0.1.0/examples/policy.yaml +12 -0
  16. grantry-0.1.0/pyproject.toml +57 -0
  17. grantry-0.1.0/ruff.toml +9 -0
  18. grantry-0.1.0/src/grantry/__init__.py +3 -0
  19. grantry-0.1.0/src/grantry/__main__.py +6 -0
  20. grantry-0.1.0/src/grantry/admin.py +125 -0
  21. grantry-0.1.0/src/grantry/assignments_graph_template.html +710 -0
  22. grantry-0.1.0/src/grantry/audit.py +42 -0
  23. grantry-0.1.0/src/grantry/awscli_cache.py +43 -0
  24. grantry-0.1.0/src/grantry/broker.py +248 -0
  25. grantry-0.1.0/src/grantry/cli.py +593 -0
  26. grantry-0.1.0/src/grantry/config.py +17 -0
  27. grantry-0.1.0/src/grantry/graphdata.py +60 -0
  28. grantry-0.1.0/src/grantry/humanops.py +139 -0
  29. grantry-0.1.0/src/grantry/identity.py +21 -0
  30. grantry-0.1.0/src/grantry/instance.py +98 -0
  31. grantry-0.1.0/src/grantry/logging_setup.py +39 -0
  32. grantry-0.1.0/src/grantry/mcp_install.py +92 -0
  33. grantry-0.1.0/src/grantry/mcp_server.py +140 -0
  34. grantry-0.1.0/src/grantry/policy.py +104 -0
  35. grantry-0.1.0/src/grantry/providers/__init__.py +0 -0
  36. grantry-0.1.0/src/grantry/providers/aws.py +165 -0
  37. grantry-0.1.0/src/grantry/providers/base.py +46 -0
  38. grantry-0.1.0/src/grantry/render.py +196 -0
  39. grantry-0.1.0/src/grantry/scaffold.py +53 -0
  40. grantry-0.1.0/src/grantry/secrets.py +25 -0
  41. grantry-0.1.0/src/grantry/ttl.py +23 -0
  42. grantry-0.1.0/tests/__init__.py +0 -0
  43. grantry-0.1.0/tests/conftest.py +29 -0
  44. grantry-0.1.0/tests/fakes/__init__.py +0 -0
  45. grantry-0.1.0/tests/fakes/fake_sso.py +147 -0
  46. grantry-0.1.0/tests/test_admin.py +108 -0
  47. grantry-0.1.0/tests/test_audit.py +57 -0
  48. grantry-0.1.0/tests/test_aws_provider.py +63 -0
  49. grantry-0.1.0/tests/test_awscli_cache.py +53 -0
  50. grantry-0.1.0/tests/test_broker.py +210 -0
  51. grantry-0.1.0/tests/test_cli.py +199 -0
  52. grantry-0.1.0/tests/test_config.py +28 -0
  53. grantry-0.1.0/tests/test_e2e_slice.py +71 -0
  54. grantry-0.1.0/tests/test_graph.py +86 -0
  55. grantry-0.1.0/tests/test_humanops.py +103 -0
  56. grantry-0.1.0/tests/test_identity.py +36 -0
  57. grantry-0.1.0/tests/test_instance.py +52 -0
  58. grantry-0.1.0/tests/test_logging_setup.py +26 -0
  59. grantry-0.1.0/tests/test_mcp_install.py +106 -0
  60. grantry-0.1.0/tests/test_mcp_server.py +153 -0
  61. grantry-0.1.0/tests/test_policy.py +74 -0
  62. grantry-0.1.0/tests/test_scaffold.py +39 -0
  63. grantry-0.1.0/tests/test_secrets.py +27 -0
  64. grantry-0.1.0/tests/test_smoke.py +6 -0
  65. grantry-0.1.0/tests/test_ttl.py +22 -0
@@ -0,0 +1,15 @@
1
+ version: 2
2
+ updates:
3
+ - package-ecosystem: "pip"
4
+ directory: "/"
5
+ schedule:
6
+ interval: "weekly"
7
+ open-pull-requests-limit: 5
8
+ groups:
9
+ python-dependencies:
10
+ patterns:
11
+ - "*"
12
+ - package-ecosystem: "github-actions"
13
+ directory: "/"
14
+ schedule:
15
+ interval: "weekly"
@@ -0,0 +1,29 @@
1
+ name: ci
2
+ on:
3
+ push:
4
+ branches: [main]
5
+ pull_request:
6
+ jobs:
7
+ test:
8
+ runs-on: ${{ matrix.os }}
9
+ strategy:
10
+ fail-fast: false
11
+ matrix:
12
+ os: [ubuntu-latest, macos-latest, windows-latest]
13
+ python: ["3.10", "3.14"]
14
+ steps:
15
+ - uses: actions/checkout@v4
16
+ - name: Install uv
17
+ uses: astral-sh/setup-uv@v3
18
+ - name: Set up Python
19
+ run: uv python install ${{ matrix.python }}
20
+ - name: Sync
21
+ run: uv sync --all-extras --dev
22
+ - name: Ruff
23
+ run: uv run ruff check .
24
+ - name: Ruff format check
25
+ run: uv run ruff format --check .
26
+ - name: Mypy
27
+ run: uv run mypy
28
+ - name: Pytest
29
+ run: uv run pytest -q
@@ -0,0 +1,23 @@
1
+ name: codeql
2
+ on:
3
+ push:
4
+ branches: [main]
5
+ pull_request:
6
+ branches: [main]
7
+ schedule:
8
+ - cron: "0 6 * * 1"
9
+ jobs:
10
+ analyze:
11
+ runs-on: ubuntu-latest
12
+ permissions:
13
+ security-events: write
14
+ actions: read
15
+ contents: read
16
+ steps:
17
+ - uses: actions/checkout@v4
18
+ - name: Initialize CodeQL
19
+ uses: github/codeql-action/init@v3
20
+ with:
21
+ languages: python
22
+ - name: Analyze
23
+ uses: github/codeql-action/analyze@v3
@@ -0,0 +1,20 @@
1
+ name: publish
2
+ on:
3
+ release:
4
+ types: [published]
5
+ jobs:
6
+ publish:
7
+ runs-on: ubuntu-latest
8
+ environment: pypi
9
+ permissions:
10
+ # Trusted Publishing: PyPI trusts this workflow via OIDC, so no API token
11
+ # is stored anywhere.
12
+ id-token: write
13
+ steps:
14
+ - uses: actions/checkout@v4
15
+ - name: Install uv
16
+ uses: astral-sh/setup-uv@v3
17
+ - name: Build sdist and wheel
18
+ run: uv build
19
+ - name: Publish to PyPI
20
+ uses: pypa/gh-action-pypi-publish@release/v1
@@ -0,0 +1,9 @@
1
+ .venv/
2
+ __pycache__/
3
+ *.pyc
4
+ .mypy_cache/
5
+ .ruff_cache/
6
+ .pytest_cache/
7
+ dist/
8
+ uv.lock
9
+ dist/
@@ -0,0 +1,58 @@
1
+ # Contributing to grantry
2
+
3
+ Thanks for your interest. grantry is a small, focused tool, and contributions
4
+ are welcome.
5
+
6
+ ## Ground rules
7
+
8
+ - grantry stays local first. No feature should add a server, telemetry, or a
9
+ network call to anything other than the cloud provider itself.
10
+ - Secrets belong in the OS keychain. Never write a secret to a file or a log.
11
+ - Product code is fully typed and passes `mypy` in strict mode.
12
+ - Every change ships with a test. Network facing code is tested against a fake
13
+ server, never against a real account.
14
+ - Prose and comments use plain English and no em dashes.
15
+
16
+ ## Getting set up
17
+
18
+ grantry uses [uv](https://docs.astral.sh/uv/).
19
+
20
+ ```bash
21
+ git clone https://github.com/saimeda32/grantry
22
+ cd grantry
23
+ uv sync --all-extras --dev
24
+ ```
25
+
26
+ ## The checks
27
+
28
+ Run all of these before opening a pull request. CI runs the same on macOS,
29
+ Linux, and Windows across Python 3.10 and 3.14.
30
+
31
+ ```bash
32
+ uv run ruff check .
33
+ uv run ruff format --check .
34
+ uv run mypy
35
+ uv run pytest -q
36
+ ```
37
+
38
+ ## Workflow
39
+
40
+ 1. Fork the repository and create a branch with a clear name, for example
41
+ `feat/azure-provider` or `fix/refresh-race`.
42
+ 2. Write a failing test, then the code to make it pass.
43
+ 3. Keep the change focused. One idea per pull request.
44
+ 4. Make sure the checks above pass.
45
+ 5. Open a pull request and describe what changed and why.
46
+
47
+ ## Adding a cloud provider
48
+
49
+ A provider lives in `src/grantry/providers/` and implements the small `Provider`
50
+ protocol in `providers/base.py`: `name`, `start_login`, `refresh`,
51
+ `list_identities`, and `mint`. Nothing outside the provider package should
52
+ import a cloud SDK. Add a fake server under `tests/fakes/` and test the login
53
+ and mint flow end to end against it.
54
+
55
+ ## Reporting bugs
56
+
57
+ Open an issue with the command you ran, what you expected, and what happened.
58
+ Never paste real credentials or tokens.
grantry-0.1.0/LICENSE ADDED
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
grantry-0.1.0/PKG-INFO ADDED
@@ -0,0 +1,212 @@
1
+ Metadata-Version: 2.4
2
+ Name: grantry
3
+ Version: 0.1.0
4
+ Summary: Local credential broker for humans and AI agents, AWS-first
5
+ Author: Sai Kiran Meda
6
+ License: Apache-2.0
7
+ License-File: LICENSE
8
+ Requires-Python: >=3.10
9
+ Requires-Dist: botocore>=1.43
10
+ Requires-Dist: keyring>=25.7
11
+ Requires-Dist: mcp>=1.28
12
+ Requires-Dist: pyyaml>=6.0.3
13
+ Description-Content-Type: text/markdown
14
+
15
+ # grantry
16
+
17
+ **A local credential broker for humans and AI agents. AWS first.**
18
+
19
+ grantry logs you into AWS IAM Identity Center once, then hands out short lived
20
+ credentials on demand. You get a clean command line. Your AI coding agents get
21
+ the same credentials over MCP, but only for the accounts and roles you allow,
22
+ only for as long as you permit, and every request is written to an audit log.
23
+
24
+ Everything stays on your machine. grantry talks to AWS and nothing else. No
25
+ account, no server, no telemetry. Tokens live in the OS keychain, never in a
26
+ plain file, and no secret is ever written to a log.
27
+
28
+ [![CI](https://github.com/saimeda32/grantry/actions/workflows/ci.yml/badge.svg)](https://github.com/saimeda32/grantry/actions/workflows/ci.yml)
29
+ [![License: Apache 2.0](https://img.shields.io/badge/license-Apache--2.0-blue.svg)](LICENSE)
30
+ [![Python](https://img.shields.io/badge/python-3.10%2B-blue.svg)](pyproject.toml)
31
+
32
+ ---
33
+
34
+ ## Why grantry exists
35
+
36
+ Every other credential tool assumes a person is at the keyboard. But agents are
37
+ now heavy users of cloud credentials, and they are bad at logging in. They
38
+ cannot click a device flow link, and they stall when a session expires. The
39
+ common workaround is pasting long lived keys into the agent's environment.
40
+ Those keys never expire and are never audited. That is a real security problem.
41
+
42
+ grantry removes the workaround. The agent asks, grantry checks your rules, and
43
+ hands over short lived credentials or a clear refusal. You keep one login, one
44
+ policy, and one audit trail across every agent on your machine.
45
+
46
+ ## Install
47
+
48
+ Once grantry is published to PyPI:
49
+
50
+ ```bash
51
+ uvx grantry --help # run without installing
52
+ # or
53
+ pipx install grantry
54
+ ```
55
+
56
+ Until then, install from source:
57
+
58
+ ```bash
59
+ git clone https://github.com/saimeda32/grantry
60
+ cd grantry
61
+ uv sync
62
+ uv run grantry --help
63
+ ```
64
+
65
+ Works on macOS, Linux, and Windows. Python 3.10 or newer.
66
+
67
+ ## Quick start
68
+
69
+ ```bash
70
+ # 1. Point grantry at your Identity Center, just once. It remembers.
71
+ grantry --start-url https://your-org.awsapps.com/start --region us-east-1 login
72
+
73
+ # 2. Generate a starter policy from your real access.
74
+ grantry init
75
+
76
+ # 3. See what you can reach.
77
+ grantry ls
78
+
79
+ # 4. Run any command as a role.
80
+ grantry run my-dev/AWSReadOnlyAccess -- aws s3 ls
81
+ ```
82
+
83
+ After `grantry login`, the native `aws` CLI, boto3, and Terraform work too. Run
84
+ `grantry populate` once to create the matching profiles in `~/.aws/config`, then
85
+ use `aws --profile ...` with no grantry in the loop.
86
+
87
+ ## Commands
88
+
89
+ | Command | What it does |
90
+ |---|---|
91
+ | `grantry login` | Log in to Identity Center once, for all accounts and roles. |
92
+ | `grantry ls` | List the account and role identities you can use. |
93
+ | `grantry run <id> -- <cmd>` | Run a command as a chosen identity. |
94
+ | `grantry switch <id>` | Print shell exports so `eval "$(grantry switch <id>)"` adopts an identity. |
95
+ | `grantry populate` | Write `~/.aws/config` profiles for your access. Adds, updates, and prunes only its own profiles. |
96
+ | `grantry check` | Diagnose your session and access, with clear exit codes. |
97
+ | `grantry init` | Generate a working policy from your real access. |
98
+ | `grantry audit` | Print the grant history, or write an HTML timeline with `--visualize`. |
99
+ | `grantry graph` | Write an HTML map of what your agents can reach under the policy. |
100
+ | `grantry mcp` | Run grantry as an MCP server for agents. |
101
+ | `grantry install [client]` | Add grantry to an AI client's MCP config. Auto detects all if none named. |
102
+ | `grantry admin assignments --as <id>` | Crawl who has what across the whole org. Admin only. |
103
+ | `grantry logout` | Clear the saved session for the current instance. |
104
+ | `grantry instances` / `grantry use <name>` | List remembered orgs, or switch between them. |
105
+ | `grantry install` / `grantry uninstall` | Add or remove grantry from an AI client's MCP config. |
106
+ | `grantry version` | Print the version. |
107
+
108
+ ## Use it with your AI agents
109
+
110
+ One command wires grantry into your AI clients:
111
+
112
+ ```bash
113
+ grantry install # auto detect every client you have
114
+ grantry install cursor # or a specific one
115
+ grantry install --dry-run # preview without writing
116
+ ```
117
+
118
+ Supported: `claude-code`, `claude-desktop`, `cursor`, `windsurf`, `vscode`.
119
+ grantry is added without touching your other MCP servers, and each client gets
120
+ its own audit label. Restart the client to load it.
121
+
122
+ The agent then has four tools: `whoami`, `list_identities`,
123
+ `get_credentials(identity, ttl)`, and `check_access(identity)`. If no one is
124
+ logged in, the agent can call `request_login`, which notifies you and waits for
125
+ your approval, then resumes on its own.
126
+
127
+ ## Policy
128
+
129
+ Write `~/.grantry/policy.yaml`, or let `grantry init` generate it from your real
130
+ access. See [examples/policy.yaml](examples/policy.yaml).
131
+
132
+ ```yaml
133
+ agents:
134
+ allow:
135
+ - identity: "*/AWSReadOnlyAccess"
136
+ - identity: "dev-*/AWSPowerUserAccess"
137
+ deny:
138
+ - identity: "*prod*/*Admin*"
139
+ max_ttl: 15m
140
+ humans:
141
+ max_ttl: 12h
142
+ ```
143
+
144
+ Three rules govern it:
145
+
146
+ 1. A deny always beats an allow.
147
+ 2. For agents, anything not allowed is refused. Safe by default.
148
+ 3. For you, anything not mentioned is allowed.
149
+
150
+ An identity is `account-name/role-name`, and `*` is a wildcard, so
151
+ `dev-*/AWSReadOnlyAccess` means read only in any account whose name starts with
152
+ `dev`.
153
+
154
+ A note on TTL and AWS: grantry cannot shorten an SSO credential below the
155
+ lifetime AWS issues it with, because the reserved SSO roles do not allow client
156
+ side re assumption. grantry reports the real AWS expiration and adds an advisory
157
+ when a credential outlives your policy cap. The real control for short sessions
158
+ is the permission set session duration, set by an admin in IAM Identity Center.
159
+
160
+ ## Admin: see who has what across the org
161
+
162
+ ```bash
163
+ grantry admin assignments --as your-mgmt/AWSAdministratorAccess --visualize
164
+ ```
165
+
166
+ This crawls the whole organization and writes an interactive graph of
167
+ principals, permission sets, and accounts, with the links between them. It is
168
+ safe to offer because AWS is the gatekeeper: only an identity that can assume a
169
+ management or delegated admin role gets any data. The crawl caches principal
170
+ names and uses retry hardening, so it handles organizations with thousands of
171
+ assignments.
172
+
173
+ ## How your data is stored
174
+
175
+ grantry uses no database. It is a single user local tool.
176
+
177
+ - **Secrets** (SSO tokens) live in the OS keychain, through `keyring`.
178
+ - **State** lives as plain files in `~/.grantry/`: `instance.json`,
179
+ `policy.yaml`, and an append only `audit.jsonl` (mode 0600).
180
+ - **Interop**: `grantry login` also writes the AWS CLI token cache in
181
+ `~/.aws/sso/cache/`, the same file `aws sso login` writes, so the native
182
+ tools work.
183
+
184
+ Everything survives reboots. To remove grantry state: `grantry logout` and
185
+ `rm -rf ~/.grantry`.
186
+
187
+ ## Security
188
+
189
+ - Secrets live only in the OS keychain. Redaction happens in one place, so no
190
+ log line can leak a token.
191
+ - The MCP server is not a network service. It talks to the agent that started
192
+ it over stdio.
193
+ - Credentials are short lived and scoped to what the policy allows.
194
+ - Every grant is recorded in `~/.grantry/audit.jsonl`, and never includes the
195
+ credentials themselves.
196
+
197
+ See [SECURITY.md](SECURITY.md) to report a vulnerability.
198
+
199
+ ## Roadmap
200
+
201
+ grantry v1 covers AWS Identity Center. The provider layer is written so Azure
202
+ and GCP can be added without touching the engine, policy, audit, or MCP
203
+ surface. Team mode (shared, signed policy) comes after that.
204
+
205
+ ## Contributing
206
+
207
+ See [CONTRIBUTING.md](CONTRIBUTING.md). In short: fork, branch, write a test,
208
+ keep `ruff`, `mypy`, and `pytest` green, open a pull request.
209
+
210
+ ## License
211
+
212
+ [Apache 2.0](LICENSE).