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

Function runCallHelp

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

Source from the content-addressed store, hash-verified

1844};
1845
1846const runCallHelp = (
1847 args: ParsedCallHelpArgs,
1848): Effect.Effect<void, Error, FileSystem.FileSystem | PlatformPath.Path> =>
1849 Effect.gen(function* () {
1850 if (args.scopeDir) process.env.EXECUTOR_SCOPE_DIR = resolve(args.scopeDir);
1851
1852 const target: ServerTarget = { baseUrl: args.baseUrl, serverName: args.serverName };
1853 const connection = yield* resolveExecutorServerConnection(target);
1854 const client = yield* makeApiClient(connection, target);
1855 const tools = yield* client.tools.list({ query: {} });
1856 const toolPaths = tools.map((tool) => tool.address);
1857
1858 const inspection = yield* Effect.try({
1859 try: () =>
1860 inspectToolPath({
1861 toolPaths,
1862 rawPrefixParts: args.pathParts,
1863 }),
1864 catch: (cause) =>
1865 cause instanceof Error ? cause : new Error(`Invalid tool path: ${String(cause)}`),
1866 });
1867
1868 if (inspection.matchingToolCount === 0) {
1869 const typed = inspection.prefixSegments.join(".");
1870 console.error(
1871 typed.length > 0
1872 ? `No tool path starts with "${typed}".`
1873 : "No tools are currently registered in this scope.",
1874 );
1875
1876 let fallback = inspectToolPath({ toolPaths, rawPrefixParts: [] });
1877 let mismatchToken: string | undefined = undefined;
1878
1879 for (let depth = inspection.prefixSegments.length - 1; depth >= 0; depth -= 1) {
1880 const candidatePrefix = inspection.prefixSegments.slice(0, depth);
1881 const candidate = inspectToolPath({
1882 toolPaths,
1883 rawPrefixParts: candidatePrefix,
1884 });
1885 if (candidate.matchingToolCount > 0) {
1886 fallback = candidate;
1887 mismatchToken = inspection.prefixSegments[depth];
1888 break;
1889 }
1890 }
1891
1892 const filtered = applyCallHelpChildFilters({
1893 children: fallback.children,
1894 args,
1895 fallbackQuery: mismatchToken,
1896 });
1897 const children = filtered.children.length > 0 ? filtered.children : fallback.children;
1898 const fallbackPrefix = fallback.prefixSegments.join(".");
1899 if (
1900 mismatchToken &&
1901 fallbackPrefix.length > 0 &&
1902 filtered.query &&
1903 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