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

Function matchesNamespace

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

Source from the content-addressed store, hash-verified

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