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

Function runCallHelp

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

Source from the content-addressed store, hash-verified

1887};
1888
1889const runCallHelp = (
1890 args: ParsedCallHelpArgs,
1891): Effect.Effect<void, Error, FileSystem.FileSystem | PlatformPath.Path> =>
1892 Effect.gen(function* () {
1893 if (args.scopeDir) process.env.EXECUTOR_SCOPE_DIR = resolve(args.scopeDir);
1894
1895 const target: ServerTarget = { baseUrl: args.baseUrl, serverName: args.serverName };
1896 const connection = yield* resolveExecutorServerConnection(target);
1897 const client = yield* makeApiClient(connection, target);
1898 const tools = yield* client.tools.list({ query: {} });
1899 const toolPaths = tools.map((tool) => tool.address);
1900
1901 const inspection = yield* Effect.try({
1902 try: () =>
1903 inspectToolPath({
1904 toolPaths,
1905 rawPrefixParts: args.pathParts,
1906 }),
1907 catch: (cause) =>
1908 cause instanceof Error ? cause : new Error(`Invalid tool path: ${String(cause)}`),
1909 });
1910
1911 if (inspection.matchingToolCount === 0) {
1912 const typed = inspection.prefixSegments.join(".");
1913 console.error(
1914 typed.length > 0
1915 ? `No tool path starts with "${typed}".`
1916 : "No tools are currently registered in this scope.",
1917 );
1918
1919 let fallback = inspectToolPath({ toolPaths, rawPrefixParts: [] });
1920 let mismatchToken: string | undefined = undefined;
1921
1922 for (let depth = inspection.prefixSegments.length - 1; depth >= 0; depth -= 1) {
1923 const candidatePrefix = inspection.prefixSegments.slice(0, depth);
1924 const candidate = inspectToolPath({
1925 toolPaths,
1926 rawPrefixParts: candidatePrefix,
1927 });
1928 if (candidate.matchingToolCount > 0) {
1929 fallback = candidate;
1930 mismatchToken = inspection.prefixSegments[depth];
1931 break;
1932 }
1933 }
1934
1935 const filtered = applyCallHelpChildFilters({
1936 children: fallback.children,
1937 args,
1938 fallbackQuery: mismatchToken,
1939 });
1940 const children = filtered.children.length > 0 ? filtered.children : fallback.children;
1941 const fallbackPrefix = fallback.prefixSegments.join(".");
1942 if (
1943 mismatchToken &&
1944 fallbackPrefix.length > 0 &&
1945 filtered.query &&
1946 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