feat(mcp): add granular allow/deny policy configuration#776
Merged
joshrotenberg merged 2 commits intomainfrom Mar 3, 2026
Merged
feat(mcp): add granular allow/deny policy configuration#776joshrotenberg merged 2 commits intomainfrom
joshrotenberg merged 2 commits intomainfrom
Conversation
Replace the binary --read-only flag with a TOML-based policy system that provides three safety tiers (read-only, read-write, full), per-toolset overrides, and explicit allow/deny lists. - Add policy.rs with PolicyConfig (TOML schema), Policy (resolved evaluator), SafetyTier enum, and show_policy MCP tool - Policy file resolution: --policy flag > REDISCTL_MCP_POLICY env > ~/.config/redisctl/mcp-policy.toml > built-in defaults - Replace CapabilityFilter::write_guard with CapabilityFilter::new using Policy::is_tool_allowed for per-tool evaluation - Replace AppState read_only bool with Arc<Policy>, add is_destructive_allowed() for defense-in-depth in destructive handlers - Add TOOL_NAMES constants to each toolset module for policy mapping - Update 29 destructive handlers to use is_destructive_allowed() - Fully backward compatible: no policy file + --read-only behaves identically to the previous binary model
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Replaces the binary
--read-onlyflag with a TOML-based policy system for granular tool access control. Closes #766.read-only(default),read-write(reads + non-destructive writes),full(everything)deny_categories = ["destructive"])--policyflag >REDISCTL_MCP_POLICYenv >~/.config/redisctl/mcp-policy.toml> built-in defaultsshow_policytool: agents can discover their own permissions at runtime--read-only=true/falsebehaves identically to beforeExample
mcp-policy.tomlKey changes
policy.rsPolicyConfig(TOML schema),Policy(evaluator),SafetyTierenum,show_policytool, 21 unit testsmain.rs--policyCLI arg,resolve_policy(),build_tool_toolset_mapping(),CapabilityFilter::newwithPolicy::is_tool_allowedstate.rsread_only: bool->policy: Arc<Policy>,is_write_allowed()consults tier, newis_destructive_allowed()TOOL_NAMESconstants +tool_names()on all 4 toolset modulesis_write_allowed()->is_destructive_allowed()for defense-in-depth atread-writetierTest plan
cargo fmt --all -- --checkcargo clippy -p redisctl-mcp --all-features -- -D warningscargo test -p redisctl-mcp --all-features(all unit, integration, doc tests pass)cargo check -p redisctl-mcp --no-default-featurescargo check -p redisctl-mcp --features cloudcargo check -p redisctl-mcp --features enterprisecargo check -p redisctl-mcp --features databaseshow_policyreturns expected config