Go

Discover agents using the Go library

Go

Install

Not yet published as a standalone Go module. Consume the SDK from source (packages/aid-go) until the github.com/agentcommunity/aid-go module repository and tags are published.

go mod edit -require=github.com/agentcommunity/aid-go@v0.0.0
go mod edit -replace=github.com/agentcommunity/aid-go=../agent-identity-discovery/packages/aid-go

Discover by Domain

package main

import (
    "fmt"
    "log"
    "time"

    aid "github.com/agentcommunity/aid-go"
)

func main() {
    rec, ttl, err := aid.Discover("supabase.agentcommunity.org", 5*time.Second)
    if err != nil { log.Fatal(err) }
    fmt.Println(rec.Proto, rec.URI, rec.Desc, ttl)
}

Options

Base-first DNS flow and guarded .well-known fallback:

res, err := aid.DiscoverWithOptions(
    "example.com",
    5*time.Second,
    aid.DiscoveryOptions{
        Protocol:          "mcp",       // _agent.<domain> first
        WellKnownFallback: true,         // only on ERR_NO_RECORD / ERR_DNS_LOOKUP_FAILED
        WellKnownTimeout:  2 * time.Second,
    },
)
// res.Record, res.TTL, res.DomainBound

DiscoverWithOptions returns a DiscoveryResult carrying Record, TTL, and DomainBound. The original aid.Discover(domain, timeout) form still returns (AidRecord, uint32, error) for backward compatibility.

Notes

  • TTL uses DNS value when available; for .well-known fallback, TTL is treated as 300.
  • PKA handshake runs automatically when v2 pka/k is present. Legacy aid1 records still use pka/kid.
  • For aid2 PKA, the SDK sends the queried host in the AID-Domain header by default and surfaces DiscoveryResult.DomainBound (true only for a verified domain-bound proof — one whose aid-pka-v2 covered set includes "aid-domain";req). Requesting binding is not itself a mitigation — only domain-binding=require enforces it. See Specification Appendix B.7.

Parse Raw TXT

rec, err := aid.Parse("v=aid2;u=https://api.example.com/mcp;p=mcp;s=Example")
if err != nil { /* handle */ }
fmt.Println(rec.URI)

Errors map to symbolic codes (e.g., ERR_NO_RECORD) and numeric codes (1000..1005).


Next: Python | Protocols & Auth | Troubleshooting