Repository navigation
feat(permissions): non-cumulative union mode for --permissions (closes #808) - #811
Conversation
closes taylorwilsdon#808) Add `+` separator syntax to --permissions for downstream MCPs that wrap a narrow tool allowlist and want the OAuth grant to match exactly. Example: --permissions gmail:readonly+send grants {gmail.readonly, gmail.send} only — no labels, modify, or compose that the cumulative ladder would force in. Existing `service:level` syntax is unchanged and remains the default. - parse_permissions_arg now produces frozenset[str] values when `+` is present, str otherwise - new helpers: get_additive_scopes_for_level, get_scopes_for_union - is_action_denied handles union entries via "most restrictive wins" - 24 new tests covering parsing, scope assembly, denied-action union semantics, and the canonical issue-taylorwilsdon#808 read+send case
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Merge Risk: ⚪ Minimal · up to
|
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@auth/permissions.py`:
- Line 273: Replace bare set type annotations with explicit string-set types to
satisfy mypy strict mode: change the variable annotation for combined in the
function/block that declares combined: set = set() to combined: set[str] =
set(), change all_scopes: set = set() to all_scopes: set[str] = set(), and
update the function signature of get_allowed_scopes_set to return
Optional[set[str]] instead of Optional[set]; ensure imports for Optional remain
correct and no other code logic is altered.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 8bec6690-30e2-4cda-b9ff-48bf29b20ca9
📒 Files selected for processing (3)
auth/permissions.pymain.pytests/test_permissions.py
|
Hey @taylorwilsdon, happy to rebase, or to rework the approach entirely if non-cumulative union mode isn't the direction you want for |
|
Thanks! |
Description
Fixes #808
Problem
--permissionsonly supported cumulative levels. Requestinggmail:sendtherefore also granted labels, modify, and compose scopes, so downstream servers exposing only Gmail read and send tools could not request a matching least-privilege OAuth grant.Changes
+syntax, for examplegmail:readonly+send.service:levelcumulative behavior unchanged.--help.User impact
--permissions gmail:readonly+sendnow grants exactlygmail.readonlyandgmail.send, so OAuth scopes can match a narrow tool allowlist without broad Gmail write access.Type of Change
Verification
uv run pytest tests/test_permissions.py tests/test_scopes.py -q— 74 passed.uv run pytest -q— 1,159 passed and 2 skipped; three unrelated Windows-only assertions failed on POSIX mode bits and slash direction.uv run ruff check auth/permissions.py main.py tests/test_permissions.py— passed.uv run ruff format --check auth/permissions.py main.py tests/test_permissions.py— passed.git diff --check upstream/main...HEAD— passed.Checklist
Additional Notes
Union mode is opt-in. A single cumulative level such as
gmail:sendbehaves exactly as before; callers that want read plus send without intermediate scopes must requestgmail:readonly+send.Summary by CodeRabbit
Release Notes
+syntax, such asgmail:readonly+send.