Skip to content

toolNameMatchesPattern

toolNameMatchesPattern(name, pattern): boolean

Defined in: _worktrees/docs-release/gaunt-sloth/packages/core/src/utils/toolMatching.ts:26

Match a single tool name against a single pattern.

  • A pattern with no * is an exact match (name === pattern), preserving the original exact-name allow-list behavior.
  • A pattern containing * is treated glob-style: each * matches any run of characters (including none) and every other character is matched literally. The whole name must match — the pattern is anchored at both ends.

Regex metacharacters in the literal segments are escaped, so a . or + in a pattern matches that character literally, never as a regex class.

string

string

boolean

toolNameMatchesPattern('mcp__unimarket__buy', 'mcp__unimarket__*') // true
toolNameMatchesPattern('read_file', '*_file') // true
toolNameMatchesPattern('abcde', 'a*c*e') // true
toolNameMatchesPattern('read_file', 'gh_pr') // false