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

Function makeProbeClient

mcp/tests/http.test.ts:343–363  ·  view source on GitHub ↗
(opts: {
      scope?: "account" | "agent";
      agentAddress?: string;
      whoamiThrows?: boolean | "unauthorized";
    })

Source from the content-addressed store, hash-verified

341 // requests of the same connection skip the probe, so whoami runs once.
342
343 function makeProbeClient(opts: {
344 scope?: "account" | "agent";
345 agentAddress?: string;
346 whoamiThrows?: boolean | "unauthorized";
347 }): McpClient {
348 return {
349 agentEmail: "",
350 scope: opts.scope ?? "account",
351 whoami: vi.fn(async () => {
352 if (opts.whoamiThrows === "unauthorized") throw makeHttpError(401);
353 if (opts.whoamiThrows) throw new Error("upstream 500");
354 return {
355 user: "owner@example.com",
356 scope: opts.scope ?? "account",
357 agentAddress: opts.agentAddress,
358 };
359 }),
360 listMessages: vi.fn(async () => ({ items: [], next_cursor: undefined })),
361 listAgents: vi.fn(async () => []),
362 } as unknown as McpClient;
363 }
364
365 async function startWithFactory(
366 factory: (bearer: string, o?: { agentEmail?: string; scope?: string }) => McpClient,

Callers 1

http.test.tsFile · 0.85

Calls 1

makeHttpErrorFunction · 0.85

Tested by

no test coverage detected