Java
Discover and parse AID records in Java
Java
Not yet published to Maven Central. Consume the SDK from source (see
packages/aid-java/) until a Maven coordinate is available. Maven/Gradle coordinates will be added here once the package is published.
Discover by Domain
import org.agentcommunity.aid.Discovery;
import org.agentcommunity.aid.Discovery.DiscoveryOptions;
var result = Discovery.discover("supabase.agentcommunity.org", new DiscoveryOptions());
System.out.println(result.record.proto + " at " + result.record.uri + " ttl=" + result.ttl + " qname=" + result.queryName);
Options
var opts = new DiscoveryOptions();
opts.protocol = "mcp"; // Validate mcp after base lookup; proto probe is diagnostic
opts.timeout = java.time.Duration.ofSeconds(5);
opts.wellKnownFallback = true; // Only on ERR_NO_RECORD / ERR_DNS_LOOKUP_FAILED
opts.wellKnownTimeout = java.time.Duration.ofSeconds(2);
opts.requireDnssec = true; // Optional: fail if DNSSEC validation is missing
var result = Discovery.discover("example.com", opts);
Parse Raw TXT
import org.agentcommunity.aid.Parser;
import org.agentcommunity.aid.AidRecord;
public class Main {
public static void main(String[] args) throws Exception {
AidRecord rec = Parser.parse("v=aid2;u=https://api.example.com/mcp;p=mcp;s=Example");
System.out.println(rec.uri);
}
}
Notes
- PKA handshake runs automatically when v2
pka/kis present. Legacyaid1records still usepka/kid. - For
aid2PKA, the SDK sends the queried host in theAID-Domainheader by default and surfacesDiscoveryResult.domainBound(trueonly for a verified domain-bound proof — one whoseaid-pka-v2covered set includes"aid-domain";req). Requesting binding is not itself a mitigation — onlydomain-binding=requireenforces it. See Specification Appendix B.7. - Errors:
AidErrorexposes.errorCode(symbol) and.code(number).
Next: .NET | Protocols & Auth | Troubleshooting