MCPcopy Create free account
hub / github.com/Noumena-Network/code / getRuleByContentsForToolName

Function getRuleByContentsForToolName

src/utils/permissions/permissions.ts:366–394  ·  view source on GitHub ↗
(
  context: ToolPermissionContext,
  toolName: string,
  behavior: PermissionBehavior,
)

Source from the content-addressed store, hash-verified

364
365// Used to break circular dependency where a Tool calls this function
366export function getRuleByContentsForToolName(
367 context: ToolPermissionContext,
368 toolName: string,
369 behavior: PermissionBehavior,
370): Map<string, PermissionRule> {
371 const ruleByContents = new Map<string, PermissionRule>()
372 let rules: PermissionRule[] = []
373 switch (behavior) {
374 case 'allow':
375 rules = getAllowRules(context)
376 break
377 case 'deny':
378 rules = getDenyRules(context)
379 break
380 case 'ask':
381 rules = getAskRules(context)
382 break
383 }
384 for (const rule of rules) {
385 if (
386 rule.ruleValue.toolName === toolName &&
387 rule.ruleValue.ruleContent !== undefined &&
388 rule.ruleBehavior === behavior
389 ) {
390 ruleByContents.set(rule.ruleValue.ruleContent, rule)
391 }
392 }
393 return ruleByContents
394}
395
396/**
397 * Runs PermissionRequest hooks for headless/async agents that cannot show

Callers 3

matchingRulesForInputFunction · 0.85
getPatternsByRootFunction · 0.85
getRuleByContentsForToolFunction · 0.85

Calls 4

getAllowRulesFunction · 0.85
getDenyRulesFunction · 0.85
getAskRulesFunction · 0.85
setMethod · 0.80

Tested by

no test coverage detected