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

Function matchesNamespace

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

Source from the content-addressed store, hash-verified

554};
555
556const matchesNamespace = (tool: SearchableTool, namespace?: string): boolean => {
557 if (!namespace || normalizeSearchText(namespace).length === 0) {
558 return true;
559 }
560
561 const namespaceTokens = tokenizeSearchText(namespace);
562 if (namespaceTokens.length === 0) {
563 return true;
564 }
565
566 const integrationTokens = tokenizeSearchText(tool.integration);
567 const pathTokens = tokenizeSearchText(tool.path);
568
569 const isPrefixMatch = (tokens: readonly string[]): boolean =>
570 namespaceTokens.every((token, index) => tokens[index] === token);
571
572 return isPrefixMatch(integrationTokens) || isPrefixMatch(pathTokens);
573};
574
575const scoreToolMatch = (tool: SearchableTool, query: string): ToolDiscoveryResult | null => {
576 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