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

Function matchesNamespace

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

Source from the content-addressed store, hash-verified

567};
568
569const matchesNamespace = (tool: SearchableTool, namespace?: string): boolean => {
570 if (!namespace || normalizeSearchText(namespace).length === 0) {
571 return true;
572 }
573
574 const namespaceTokens = tokenizeSearchText(namespace);
575 if (namespaceTokens.length === 0) {
576 return true;
577 }
578
579 const integrationTokens = tokenizeSearchText(tool.integration);
580 const pathTokens = tokenizeSearchText(tool.path);
581
582 const isPrefixMatch = (tokens: readonly string[]): boolean =>
583 namespaceTokens.every((token, index) => tokens[index] === token);
584
585 return isPrefixMatch(integrationTokens) || isPrefixMatch(pathTokens);
586};
587
588const scoreToolMatch = (tool: SearchableTool, query: string): ToolDiscoveryResult | null => {
589 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