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

Function resolveRequestedExecutorServerConnection

apps/cli/src/main.ts:712–751  ·  view source on GitHub ↗
(
  target: ServerTarget,
)

Source from the content-addressed store, hash-verified

710 }).pipe(Effect.mapError(toError));
711
712const resolveRequestedExecutorServerConnection = (
713 target: ServerTarget,
714): Effect.Effect<
715 RequestedExecutorServerConnection,
716 Error,
717 FileSystem.FileSystem | PlatformPath.Path
718> =>
719 Effect.gen(function* () {
720 if (target.baseUrl && target.serverName) {
721 return yield* Effect.fail(new Error("Use either --server or --base-url, not both."));
722 }
723
724 if (target.serverName) {
725 const store = yield* readCliServerConnectionStore();
726 const profile = findCliServerConnectionProfile(store, target.serverName);
727 if (!profile) {
728 return yield* Effect.fail(new Error(`No server profile named "${target.serverName}".`));
729 }
730 return { connection: withCliServerAuthFallback(profile.connection), source: "explicit" };
731 }
732
733 if (!target.baseUrl) {
734 const store = yield* readCliServerConnectionStore();
735 const profile = defaultCliServerConnectionProfile(store);
736 if (profile) {
737 return {
738 connection: withCliServerAuthFallback(profile.connection),
739 source: "default-profile",
740 };
741 }
742
743 const active = yield* readActiveLocalServerManifest();
744 if (active) return { connection: active.connection, source: "active-local" };
745 }
746
747 return {
748 connection: yield* parseExecutorServerConnection(target.baseUrl ?? DEFAULT_BASE_URL),
749 source: target.baseUrl ? "explicit" : "implicit-default",
750 };
751 });
752
753// Refresh an `oauth` (device-login) credential a minute before it expires, so
754// `executor call` against a hosted server keeps working long after the browser

Callers 2

main.tsFile · 0.85

Tested by

no test coverage detected