feat: capability-scope permission model (read-only default) - #209
feat: capability-scope permission model (read-only default)#209lucagattoni wants to merge 3 commits into
Conversation
…only) Code-only slice of PR Wh1isper#200, rebased onto current main (post-docs-reorg Wh1isper#205). Every MCP tool is gated behind a capability scope; a fresh install is read-only until scopes are granted via the permissions config field or MCP_EMAIL_SERVER_PERMISSIONS. Out-of-scope tools are hidden from list_tools and rejected at call time. Docs are intentionally omitted here — they need re-homing into the new multi-file docs/ structure (configuration.md / security.md), handled separately. Adopts upstream's typed CredentialStorage and DEFAULT_CONFIG_PATH; adds only _VALID_PERMISSION_SCOPES and _permissions_override. Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013pd8meRq4jSiqaLq715nSD
…#205 structure) Homes the permission-scope documentation into upstream's multi-file docs: - security.md: new 'Permission scopes' section (scope table, read-only posture, config + env examples) - configuration.md: permissions setting + MCP_EMAIL_SERVER_PERMISSIONS env rows; note scope-gating on IMAP-only mutation tools - tools.md: scope-gating note in 'Conditional tools' - getting-started.md: read-only-by-default note + next-steps link - troubleshooting.md / guides.md: correct now-stale 'send_email'/'IMAP mutation tools always available' claims for the read-only default Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013pd8meRq4jSiqaLq715nSD
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #209 +/- ##
=======================================
+ Coverage 92.5% 92.7% +0.1%
=======================================
Files 10 10
Lines 2013 2059 +46
Branches 310 316 +6
=======================================
+ Hits 1863 1909 +46
Misses 107 107
Partials 43 43 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
The permission model makes the server read-only by default, so the mutating tools (send_email, save_to_mailbox, move/archive/delete/mark) are hidden unless scoped. The GreenMail E2E exercises the full tool surface, so it must opt in: set MCP_EMAIL_SERVER_PERMISSIONS=full for the spawned stdio server. Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013pd8meRq4jSiqaLq715nSD
|
Update after deeper review: my original conclusion in this comment was incorrect. Current PR #209 has therefore been reopened for rework. The existing implementation still needs redesign for the post-#212 architecture; full requirements are in the follow-up comment: #209 (comment) Thank you again for raising the authorization concern. |
|
Correction after a deeper review of current Two gaps remain in the post-#212 implementation:
The existing branch still cannot be rebased as-is: its dynamic tool visibility, global
Thank you again for raising this area. Your original scope model needs redesign, but the security concern itself remains valid and should stay open for rework. |
What this delivers
A capability-scope permission model for the email tools, rebased cleanly onto current
mainand with docs harmonized into the new multi-filedocs/structure (post-#205).This supersedes #200, which was branched a week ago and now conflicts with the docs reorganization (#205) and tooling changes (#204). Same feature, cleanly re-homed.
The feature
The server is read-only by default. Every mutating tool is gated behind a capability scope, set via the
permissionsconfig field orMCP_EMAIL_SERVER_PERMISSIONS. Out-of-scope tools are hidden from the tool list and rejected at call time.readdraftsave_to_mailbox(drafts-type folders unlessorganizealso granted)organizemove_emails,archive_emails,mark_emails_as_readdeletedelete_emailssendsend_emailmanageadd_email_accountfullUpgrading from a pre-scopes version? Set
permissions = ["full"]to restore prior behavior.Rebase notes (adopts upstream's current shape)
CredentialStorageand its refactoredDEFAULT_CONFIG_PATH; adds only_VALID_PERMISSION_SCOPESand_permissions_override.security.mdgets the substantive Permission scopes section;configuration.mdgets the setting + env-var rows;tools.mdnotes scope-gating in "Conditional tools";getting-started.mdgets a read-only note.send_email is missingtroubleshooting entry, and the guides.md "IMAP mutation tools always available" claim.Test plan
uv run pytest -q— 577 passeduv run ruff check/ruff format --check— cleanuv run pyright— 0 errors (the check added in chore: add pyright checks and update Python tooling #204)mkdocs build --strict— builds, no broken anchorsprettier --check docs/*.md— cleanSecurity hardening (the former #201) will follow as a separate rebased PR.
🤖 Generated with Claude Code
https://claude.ai/code/session_013pd8meRq4jSiqaLq715nSD