MCPcopy
hub / github.com/inkeep/open-knowledge / startWithShell

Function startWithShell

packages/server/src/mcp-mount.test.ts:466–486  ·  view source on GitHub ↗
(opts?: {
    contentAssetMiddleware?: MountMcpAndApiOptions['contentAssetMiddleware'];
  })

Source from the content-addressed store, hash-verified

464 }
465
466 async function startWithShell(opts?: {
467 contentAssetMiddleware?: MountMcpAndApiOptions['contentAssetMiddleware'];
468 }): Promise<{ port: number; shellDir: string }> {
469 const shellDir = makeShellDir();
470 const httpServer = createServer();
471 const mount = mountMcpAndApi({
472 httpServer,
473 hocuspocus,
474 log,
475 contentAssetMiddleware: opts?.contentAssetMiddleware,
476 reactShellMiddleware: sirv(shellDir, {
477 single: true,
478 gzip: true,
479 immutable: true,
480 }),
481 });
482 const port = await getFreeLoopbackPort();
483 await new Promise<void>((resolve) => httpServer.listen(port, '127.0.0.1', () => resolve()));
484 servers.push({ httpServer, mount });
485 return { port, shellDir };
486 }
487
488 test('serves index.html on root request (SPA shell entry)', async () => {
489 const { port } = await startWithShell();

Callers 1

mcp-mount.test.tsFile · 0.85

Calls 6

mountMcpAndApiFunction · 0.90
getFreeLoopbackPortFunction · 0.90
makeShellDirFunction · 0.85
createServerFunction · 0.85
listenMethod · 0.65
pushMethod · 0.45

Tested by

no test coverage detected