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

Method scanBrandForDomain

server/src/crawler.ts:203–241  ·  view source on GitHub ↗

* Scan a single domain for brand.json and upsert discovered/verified brand data.

(domain: string)

Source from the content-addressed store, hash-verified

201 * Scan a single domain for brand.json and upsert discovered/verified brand data.
202 */
203 async scanBrandForDomain(domain: string): Promise<void> {
204 const result = await this.brandManager.validateDomain(domain, { skipCache: true });
205 if (!result.valid || !result.raw_data) return;
206
207 if (result.variant === 'authoritative_location') {
208 const data = result.raw_data as { authoritative_location: string };
209 try {
210 const url = new URL(data.authoritative_location);
211 if (url.hostname === AAO_HOST &&
212 url.pathname === `/brands/${domain}/brand.json`) {
213 const hosted = await this.brandDb.getHostedBrandByDomain(domain);
214 if (hosted && !hosted.domain_verified) {
215 await this.brandDb.updateHostedBrand(hosted.id, { domain_verified: true });
216 log.debug({ domain }, 'Brand verified');
217 }
218 }
219 } catch {
220 // Invalid URL in authoritative_location — skip
221 }
222 } else if (result.variant === 'house_portfolio' ||
223 result.variant === 'brand_agent' ||
224 result.variant === 'house_redirect') {
225 const brandName = this.extractBrandName(result.raw_data, domain);
226 await this.brandDb.upsertDiscoveredBrand({
227 domain,
228 brand_name: brandName,
229 has_brand_manifest: result.variant === 'house_portfolio',
230 brand_manifest: result.variant === 'house_portfolio'
231 ? result.raw_data as Record<string, unknown>
232 : undefined,
233 source_type: 'brand_json',
234 });
235
236 // Extract properties from brand.json and upsert into catalog
237 if (result.variant === 'house_portfolio') {
238 await this.upsertBrandProperties(domain, result.raw_data as Record<string, unknown>);
239 }
240 }
241 }
242
243 /**
244 * Extract properties from brand.json and upsert them into the property catalog.

Callers 3

scanBrandsForDomainsMethod · 0.95
crawlSingleDomainMethod · 0.95
createRegistryApiRouterFunction · 0.80

Calls 6

extractBrandNameMethod · 0.95
upsertBrandPropertiesMethod · 0.95
updateHostedBrandMethod · 0.80
upsertDiscoveredBrandMethod · 0.80
validateDomainMethod · 0.45

Tested by

no test coverage detected