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

Method matches_tool_name

core/src/permissions/rule.rs:102–118  ·  view source on GitHub ↗

Check if tool names match (case-insensitive, wildcard-aware)

(&self, rule_tool: &str, actual_tool: &str)

Source from the content-addressed store, hash-verified

100
101 /// Check if tool names match (case-insensitive, wildcard-aware)
102 fn matches_tool_name(&self, rule_tool: &str, actual_tool: &str) -> bool {
103 // If the rule contains wildcards, use glob matching on the tool name directly.
104 // e.g. "mcp__longvt__*" must use glob, not starts_with, because starts_with
105 // treats '*' as a literal character and will never match.
106 if rule_tool.contains('*') || rule_tool.contains('?') {
107 return self.glob_match(rule_tool, actual_tool);
108 }
109
110 // Handle MCP tools: mcp__server matches mcp__server__tool
111 if rule_tool.starts_with("mcp__") && actual_tool.starts_with("mcp__") {
112 // mcp__pencil matches mcp__pencil__batch_design
113 if actual_tool.starts_with(rule_tool) {
114 return true;
115 }
116 }
117 rule_tool.eq_ignore_ascii_case(actual_tool)
118 }
119
120 /// Match argument pattern against tool arguments
121 fn matches_args(&self, pattern: &str, tool_name: &str, args: &serde_json::Value) -> bool {

Callers 1

matchesMethod · 0.80

Calls 2

containsMethod · 0.80
glob_matchMethod · 0.45

Tested by

no test coverage detected