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

Method batchGetClassifications

server/src/db/catalog-db.ts:748–777  ·  view source on GitHub ↗

* Batch classification lookup — single query for all identifiers. * Returns the highest-confidence classification for each identifier value.

(
    identifierValues: string[]
  )

Source from the content-addressed store, hash-verified

746 * Returns the highest-confidence classification for each identifier value.
747 */
748 async batchGetClassifications(
749 identifierValues: string[]
750 ): Promise<Map<string, string>> {
751 if (identifierValues.length === 0) return new Map();
752
753 const result = await query<{ subject_value: string; object_value: string }>(
754 `SELECT DISTINCT ON (subject_value) subject_value, object_value
755 FROM catalog_facts
756 WHERE fact_type = 'classification'
757 AND subject_type = 'identifier'
758 AND subject_value = ANY($1)
759 AND predicate = 'classified_as'
760 AND superseded_by IS NULL
761 ORDER BY subject_value,
762 CASE confidence
763 WHEN 'authoritative' THEN 1
764 WHEN 'strong' THEN 2
765 WHEN 'medium' THEN 3
766 WHEN 'weak' THEN 4
767 END,
768 created_at DESC`,
769 [identifierValues]
770 );
771
772 const map = new Map<string, string>();
773 for (const row of result.rows) {
774 map.set(row.subject_value, row.object_value);
775 }
776 return map;
777 }
778
779 /**
780 * Batch create properties with identifiers and facts.

Callers 3

resolveIdentifiersMethod · 0.95
checkMethod · 0.80
checkMethod · 0.80

Calls 1

setMethod · 0.45

Tested by

no test coverage detected