MCPcopy
hub / github.com/coder/mux / startMetadataServer

Function startMetadataServer

src/node/services/mcpOauthService.test.ts:589–605  ·  view source on GitHub ↗
(
    body: unknown
  )

Source from the content-addressed store, hash-verified

587
588describe("resolveOAuthScope", () => {
589 async function startMetadataServer(
590 body: unknown
591 ): Promise<{ url: URL; close: () => Promise<void> }> {
592 const server = createServer((_req, res) => {
593 res.setHeader("Content-Type", "application/json");
594 res.end(JSON.stringify(body));
595 });
596 await new Promise<void>((resolve) => server.listen(0, "127.0.0.1", resolve));
597 const address = server.address();
598 if (!address || typeof address === "string") {
599 throw new Error("Failed to bind metadata server");
600 }
601 return {
602 url: new URL(`http://127.0.0.1:${address.port}/.well-known/oauth-protected-resource`),
603 close: () => new Promise<void>((resolve) => server.close(() => resolve())),
604 };
605 }
606
607 test("uses the challenge scope when present", async () => {
608 expect(await resolveOAuthScope({ raw: "", scope: "mcp.read" })).toBe("mcp.read");

Callers 1

Calls 3

resolveFunction · 0.70
closeMethod · 0.65
endMethod · 0.45

Tested by

no test coverage detected