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

Function runCallHelp

apps/cli/src/main.ts:1910–2033  ·  view source on GitHub ↗
(
  args: ParsedCallHelpArgs,
)

Source from the content-addressed store, hash-verified

1908};
1909
1910const runCallHelp = (
1911 args: ParsedCallHelpArgs,
1912): Effect.Effect<void, Error, FileSystem.FileSystem | PlatformPath.Path> =>
1913 Effect.gen(function* () {
1914 if (args.scopeDir) process.env.EXECUTOR_SCOPE_DIR = resolve(args.scopeDir);
1915
1916 const target: ServerTarget = { baseUrl: args.baseUrl, serverName: args.serverName };
1917 const connection = yield* resolveExecutorServerConnection(target);
1918 const client = yield* makeApiClient(connection, target);
1919 const tools = yield* client.tools.list({ query: {} });
1920 const toolPaths = tools.map((tool) => tool.address);
1921
1922 const inspection = yield* Effect.try({
1923 try: () =>
1924 inspectToolPath({
1925 toolPaths,
1926 rawPrefixParts: args.pathParts,
1927 }),
1928 catch: (cause) =>
1929 cause instanceof Error ? cause : new Error(`Invalid tool path: ${String(cause)}`),
1930 });
1931
1932 if (inspection.matchingToolCount === 0) {
1933 const typed = inspection.prefixSegments.join(".");
1934 console.error(
1935 typed.length > 0
1936 ? `No tool path starts with "${typed}".`
1937 : "No tools are currently registered in this scope.",
1938 );
1939
1940 let fallback = inspectToolPath({ toolPaths, rawPrefixParts: [] });
1941 let mismatchToken: string | undefined = undefined;
1942
1943 for (let depth = inspection.prefixSegments.length - 1; depth >= 0; depth -= 1) {
1944 const candidatePrefix = inspection.prefixSegments.slice(0, depth);
1945 const candidate = inspectToolPath({
1946 toolPaths,
1947 rawPrefixParts: candidatePrefix,
1948 });
1949 if (candidate.matchingToolCount > 0) {
1950 fallback = candidate;
1951 mismatchToken = inspection.prefixSegments[depth];
1952 break;
1953 }
1954 }
1955
1956 const filtered = applyCallHelpChildFilters({
1957 children: fallback.children,
1958 args,
1959 fallbackQuery: mismatchToken,
1960 });
1961 const children = filtered.children.length > 0 ? filtered.children : fallback.children;
1962 const fallbackPrefix = fallback.prefixSegments.join(".");
1963 if (
1964 mismatchToken &&
1965 fallbackPrefix.length > 0 &&
1966 filtered.query &&
1967 filtered.filteredCount > 0

Callers 1

main.tsFile · 0.85

Calls 9

inspectToolPathFunction · 0.90
makeApiClientFunction · 0.85
printCallBrowseHelpFunction · 0.85
printCallLeafHelpFunction · 0.85
errorMethod · 0.80
listMethod · 0.65
resolveFunction · 0.50

Tested by

no test coverage detected