MCPcopy Create free account
hub / github.com/AI45Lab/Code / check

Method check

core/src/permissions/manager.rs:82–125  ·  view source on GitHub ↗

Check permission for a tool invocation in a session

(
        &self,
        session_id: &str,
        tool_name: &str,
        args: &serde_json::Value,
    )

Source from the content-addressed store, hash-verified

80
81 /// Check permission for a tool invocation in a session
82 pub fn check(
83 &self,
84 session_id: &str,
85 tool_name: &str,
86 args: &serde_json::Value,
87 ) -> PermissionDecision {
88 // Get session policy or fall back to global
89 let policy = self.get_effective_policy(session_id);
90
91 // Session deny rules
92 for rule in &policy.deny {
93 if rule.matches(tool_name, args) {
94 return PermissionDecision::Deny;
95 }
96 }
97
98 // Global deny rules (if different policy)
99 if !self.session_policies.contains_key(session_id) {
100 // Already checked global
101 } else {
102 for rule in &self.global_policy.deny {
103 if rule.matches(tool_name, args) {
104 return PermissionDecision::Deny;
105 }
106 }
107 }
108
109 // Session allow rules
110 for rule in &policy.allow {
111 if rule.matches(tool_name, args) {
112 return PermissionDecision::Allow;
113 }
114 }
115
116 // Session ask rules
117 for rule in &policy.ask {
118 if rule.matches(tool_name, args) {
119 return PermissionDecision::Ask;
120 }
121 }
122
123 // Fall back to policy default
124 policy.default_decision
125 }
126}

Callers

nothing calls this directly

Calls 2

get_effective_policyMethod · 0.80
matchesMethod · 0.45

Tested by

no test coverage detected