MCPcopy Create free account
hub / github.com/Mnexa-AI/e2a / startHttpServer

Function startHttpServer

mcp/src/http-server.ts:373–391  ·  view source on GitHub ↗
(
  port: number,
  opts: HttpServerOptions,
)

Source from the content-addressed store, hash-verified

371 * sessions to drain; closing the listener is the whole shutdown.
372 */
373export async function startHttpServer(
374 port: number,
375 opts: HttpServerOptions,
376): Promise<{ close: () => Promise<void>; port: number }> {
377 const { app, cache } = buildApp(opts);
378 const server = app.listen(port);
379 await new Promise<void>((resolve, reject) => {
380 server.once("listening", resolve);
381 server.once("error", reject);
382 });
383 const actualPort = (server.address() as { port: number }).port;
384 return {
385 port: actualPort,
386 close: async () => {
387 await new Promise<void>((resolve) => server.close(() => resolve()));
388 cache.clear();
389 },
390 };
391}

Callers 4

mainFunction · 0.85
http.test.tsFile · 0.85
startWithFactoryFunction · 0.85

Calls 5

buildAppFunction · 0.85
resolveFunction · 0.85
clearMethod · 0.80
listenMethod · 0.45
closeMethod · 0.45

Tested by 1

startWithFactoryFunction · 0.68