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

Function runCallHelp

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

Source from the content-addressed store, hash-verified

1790};
1791
1792const runCallHelp = (
1793 args: ParsedCallHelpArgs,
1794): Effect.Effect<void, Error, FileSystem.FileSystem | PlatformPath.Path> =>
1795 Effect.gen(function* () {
1796 if (args.scopeDir) process.env.EXECUTOR_SCOPE_DIR = resolve(args.scopeDir);
1797
1798 const connection = yield* resolveExecutorServerConnection({
1799 baseUrl: args.baseUrl,
1800 serverName: args.serverName,
1801 });
1802 const client = yield* makeApiClient(connection);
1803 const tools = yield* client.tools.list({ query: {} });
1804 const toolPaths = tools.map((tool) => tool.address);
1805
1806 const inspection = yield* Effect.try({
1807 try: () =>
1808 inspectToolPath({
1809 toolPaths,
1810 rawPrefixParts: args.pathParts,
1811 }),
1812 catch: (cause) =>
1813 cause instanceof Error ? cause : new Error(`Invalid tool path: ${String(cause)}`),
1814 });
1815
1816 if (inspection.matchingToolCount === 0) {
1817 const typed = inspection.prefixSegments.join(".");
1818 console.error(
1819 typed.length > 0
1820 ? `No tool path starts with "${typed}".`
1821 : "No tools are currently registered in this scope.",
1822 );
1823
1824 let fallback = inspectToolPath({ toolPaths, rawPrefixParts: [] });
1825 let mismatchToken: string | undefined = undefined;
1826
1827 for (let depth = inspection.prefixSegments.length - 1; depth >= 0; depth -= 1) {
1828 const candidatePrefix = inspection.prefixSegments.slice(0, depth);
1829 const candidate = inspectToolPath({
1830 toolPaths,
1831 rawPrefixParts: candidatePrefix,
1832 });
1833 if (candidate.matchingToolCount > 0) {
1834 fallback = candidate;
1835 mismatchToken = inspection.prefixSegments[depth];
1836 break;
1837 }
1838 }
1839
1840 const filtered = applyCallHelpChildFilters({
1841 children: fallback.children,
1842 args,
1843 fallbackQuery: mismatchToken,
1844 });
1845 const children = filtered.children.length > 0 ? filtered.children : fallback.children;
1846 const fallbackPrefix = fallback.prefixSegments.join(".");
1847 if (
1848 mismatchToken &&
1849 fallbackPrefix.length > 0 &&

Callers 1

main.tsFile · 0.85

Calls 9

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

Tested by

no test coverage detected