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

Function runCallHelp

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

Source from the content-addressed store, hash-verified

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