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

Function serveJson

e2e/cloud/integrations-refresh.test.ts:50–72  ·  view source on GitHub ↗
(body: string)

Source from the content-addressed store, hash-verified

48/** A real node:http server on 127.0.0.1 that serves `body` on every request,
49 * closed by the scope's finalizer. */
50const serveJson = (body: string) =>
51 Effect.acquireRelease(
52 Effect.callback<{ readonly url: string; readonly close: () => void }>((resume) => {
53 const server = createServer((_request, response) => {
54 response.writeHead(200, { "content-type": "application/json" });
55 response.end(body);
56 });
57 server.listen(0, "127.0.0.1", () => {
58 const address = server.address();
59 const port = typeof address === "object" && address ? address.port : 0;
60 resume(
61 Effect.succeed({
62 url: `http://127.0.0.1:${port}/spec.json`,
63 close: () => {
64 server.close();
65 server.closeAllConnections();
66 },
67 }),
68 );
69 });
70 }),
71 (server) => Effect.sync(server.close),
72 );
73
74scenario(
75 "Connections · refreshing an MCP connection re-dials the live server and replaces its tools",

Callers 1

Calls 6

resumeFunction · 0.85
endMethod · 0.80
listenMethod · 0.80
addressMethod · 0.80
closeMethod · 0.65
syncMethod · 0.65

Tested by

no test coverage detected