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

Function makeHarness

apps/cloud/src/mcp/agent-handler.test.ts:47–73  ·  view source on GitHub ↗
(owner: "not_found" | "terminated" = "not_found")

Source from the content-addressed store, hash-verified

45 });
46
47const makeHarness = (owner: "not_found" | "terminated" = "not_found") => {
48 const ownerChecks = { count: 0 };
49 const traces = { count: 0 };
50 const stub = {
51 validateMcpSessionOwner: async () => {
52 ownerChecks.count += 1;
53 return owner;
54 },
55 };
56 const namespace = {
57 idFromString: (sessionId: string) => sessionId,
58 get: () => stub,
59 };
60 // oxlint-disable-next-line executor/no-double-cast -- test boundary: the handler only reads the MCP_SESSION namespace in these legacy dead-session cases
61 const env = { MCP_SESSION: namespace } as unknown as Env;
62 // oxlint-disable-next-line executor/no-double-cast -- test boundary: no ExecutionContext capability is used before the dead-session response
63 const ctx = {} as unknown as ExecutionContext;
64 const handler = makeCloudMcpAgentHandler({
65 authProvider: AuthProviderLive,
66 makeModernServerBuilder: () => ({ build: () => Effect.die("unused modern builder") }),
67 traceRequest: async (request, _env, _ctx, handle) => {
68 traces.count += 1;
69 return handle(request);
70 },
71 });
72 return { ctx, env, handler, ownerChecks, traces };
73};
74
75describe("cloud MCP dead-session negative cache", () => {
76 beforeEach(() => {

Callers 1

Calls 2

makeCloudMcpAgentHandlerFunction · 0.90
handleFunction · 0.70

Tested by

no test coverage detected