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

Function matchesNamespace

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

Source from the content-addressed store, hash-verified

583};
584
585const matchesNamespace = (tool: SearchableTool, namespace?: string): boolean => {
586 if (!namespace || normalizeSearchText(namespace).length === 0) {
587 return true;
588 }
589
590 const namespaceTokens = tokenizeSearchText(namespace);
591 if (namespaceTokens.length === 0) {
592 return true;
593 }
594
595 const integrationTokens = tokenizeSearchText(tool.integration);
596 const pathTokens = tokenizeSearchText(tool.path);
597
598 const isPrefixMatch = (tokens: readonly string[]): boolean =>
599 namespaceTokens.every((token, index) => tokens[index] === token);
600
601 return isPrefixMatch(integrationTokens) || isPrefixMatch(pathTokens);
602};
603
604const scoreToolMatch = (tool: SearchableTool, query: string): ToolDiscoveryResult | null => {
605 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