MCPcopy Create free account
hub / github.com/adcontextprotocol/adcp / resolveOrgByDomain

Function resolveOrgByDomain

server/src/db/domain-resolution-db.ts:29–48  ·  view source on GitHub ↗
(domain: string)

Source from the content-addressed store, hash-verified

27 * Returns null if no match is found.
28 */
29export async function resolveOrgByDomain(domain: string): Promise<DomainResolution | null> {
30 const normalized = domain.toLowerCase().trim();
31
32 // Try database lookups first (fast)
33 const dbResult = await resolveFromDatabase(normalized);
34 if (dbResult) return dbResult;
35
36 // No DB match — check if the domain redirects to a different one
37 const redirectTarget = await resolveRedirectDomain(normalized);
38 if (redirectTarget && redirectTarget !== normalized) {
39 const redirectResult = await resolveFromDatabase(redirectTarget);
40 if (redirectResult) {
41 // Persist the alias so future lookups skip the HTTP check
42 persistRedirectAlias(normalized, redirectTarget);
43 return { ...redirectResult, method: 'redirect' };
44 }
45 }
46
47 return null;
48}
49
50/**
51 * Batch resolve multiple domains to organizations using database-only lookups.

Callers 2

triageEmailDomainFunction · 0.85
createProspectFunction · 0.85

Calls 4

resolveFromDatabaseFunction · 0.85
resolveRedirectDomainFunction · 0.85
persistRedirectAliasFunction · 0.85
trimMethod · 0.65

Tested by

no test coverage detected