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

Function discoverProtectedResource

apps/local/src/db/v1-v2-migration.ts:409–425  ·  view source on GitHub ↗
(endpoint: string)

Source from the content-addressed store, hash-verified

407};
408
409const discoverProtectedResource = async (endpoint: string): Promise<string | null> => {
410 for (const url of protectedResourceMetadataUrls(endpoint)) {
411 try {
412 const response = await fetch(url, {
413 headers: { accept: "application/json" },
414 signal: AbortSignal.timeout(5_000),
415 });
416 if (!response.ok) continue;
417 const json = (await response.json()) as unknown;
418 if (!isObjectRecord(json) || typeof json.resource !== "string") continue;
419 if (resourceMatchesEndpoint(json.resource, endpoint)) return json.resource;
420 } catch {
421 continue;
422 }
423 }
424 return null;
425};
426
427const discoverMcpOAuthResourceOverrides = async (
428 bindings: readonly Row[],

Callers 1

Calls 5

isObjectRecordFunction · 0.85
resourceMatchesEndpointFunction · 0.70
jsonMethod · 0.65
fetchFunction · 0.50

Tested by

no test coverage detected