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

Function selfhostDockerTarget

e2e/targets/selfhost-docker.ts:18–67  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

16 process.env.E2E_SELFHOST_DOCKER_URL ?? `http://localhost:${SELFHOST_DOCKER_PORT}`;
17
18export const selfhostDockerTarget = (): Target => ({
19 name: "selfhost-docker",
20 baseUrl: SELFHOST_DOCKER_BASE_URL,
21 mcpUrl: `${SELFHOST_DOCKER_BASE_URL}/mcp`,
22 capabilities: new Set(["api", "browser", "mcp-oauth"]),
23 newIdentity: () =>
24 Effect.promise(async (): Promise<Identity> => {
25 const { cookieHeader, cookies } = await signInSession(
26 SELFHOST_DOCKER_BASE_URL,
27 SELFHOST_ADMIN,
28 );
29 return {
30 label: SELFHOST_ADMIN.email,
31 credentials: SELFHOST_ADMIN,
32 headers: { cookie: cookieHeader },
33 cookies,
34 };
35 }),
36 // Same forced-consent completion as the selfhost dev target: the app forces
37 // `prompt=consent` on every MCP authorize, so authorize redirects to the
38 // relative `/mcp-consent?consent_code=...` screen instead of straight to the
39 // callback — mcporter's cookieConsentStrategy can't parse that redirect.
40 mcpConsent: (identity: Identity) =>
41 forcedMcpConsent(SELFHOST_DOCKER_BASE_URL, {
42 email: identity.credentials?.email ?? SELFHOST_ADMIN.email,
43 password: identity.credentials?.password || SELFHOST_ADMIN.password,
44 }),
45 // A real deployment cycle, not a warm `docker restart`: graceful stop
46 // (SIGTERM + docker's grace), remove the container, start a NEW one from
47 // the same image against the same data volume — what an upgrade, reboot,
48 // or `compose down && up` does to a user's instance. Only when this suite
49 // owns the container (attach mode can't assume the instance is docker).
50 ...(process.env.E2E_SELFHOST_DOCKER_URL
51 ? {}
52 : {
53 restart: () =>
54 Effect.promise(async () => {
55 // Published by the globalsetup after it resolved/built the image.
56 const image = process.env.E2E_SELFHOST_DOCKER_RESOLVED_IMAGE;
57 if (!image) throw new Error("selfhost-docker: no resolved image — boot ran?");
58 await stopSelfhostContainer(SELFHOST_DOCKER_PORT);
59 await runSelfhostContainer({
60 image,
61 port: SELFHOST_DOCKER_PORT,
62 webBaseUrl: SELFHOST_DOCKER_BASE_URL,
63 admin: SELFHOST_ADMIN,
64 });
65 }),
66 }),
67});

Callers

nothing calls this directly

Calls 4

signInSessionFunction · 0.90
forcedMcpConsentFunction · 0.90
stopSelfhostContainerFunction · 0.90
runSelfhostContainerFunction · 0.90

Tested by

no test coverage detected