MCPcopy Create free account
hub / github.com/UsefulSoftwareCo/executor / matchesNamespace

Function matchesNamespace

packages/core/execution/src/tool-invoker.ts:518–535  ·  view source on GitHub ↗
(tool: SearchableTool, namespace?: string)

Source from the content-addressed store, hash-verified

516};
517
518const matchesNamespace = (tool: SearchableTool, namespace?: string): boolean => {
519 if (!namespace || normalizeSearchText(namespace).length === 0) {
520 return true;
521 }
522
523 const namespaceTokens = tokenizeSearchText(namespace);
524 if (namespaceTokens.length === 0) {
525 return true;
526 }
527
528 const integrationTokens = tokenizeSearchText(tool.integration);
529 const pathTokens = tokenizeSearchText(tool.path);
530
531 const isPrefixMatch = (tokens: readonly string[]): boolean =>
532 namespaceTokens.every((token, index) => tokens[index] === token);
533
534 return isPrefixMatch(integrationTokens) || isPrefixMatch(pathTokens);
535};
536
537const scoreToolMatch = (tool: SearchableTool, query: string): ToolDiscoveryResult | null => {
538 const normalizedQuery = normalizeSearchText(query);

Callers 1

tool-invoker.tsFile · 0.85

Calls 3

normalizeSearchTextFunction · 0.85
tokenizeSearchTextFunction · 0.85
isPrefixMatchFunction · 0.85

Tested by

no test coverage detected