Python library for Agent Identity & Discovery (AID) - v1.2.0 release
Project description
aid-discovery (Python)
Official Python implementation of the Agent Identity & Discovery (AID) specification.
AID enables you to discover AI agents by domain name using DNS TXT records. Type a domain, get the agent's endpoint and protocol - that's it.
Installation
pip install aid-discovery
Quick Start
from aid_py import discover, AidError
try:
# Discover an agent by domain
result = discover("supabase.agentcommunity.org")
print(f"Protocol: {result.record.proto}") # "mcp"
print(f"URI: {result.record.uri}") # "https://api.supabase.com/mcp"
print(f"Description: {result.record.desc}") # "Supabase MCP"
print(f"TTL: {result.ttl} seconds")
except AidError as e:
print(f"Discovery failed: {e}")
API Reference
discover(domain: str, *, protocol: str | None = None, timeout: float = 5.0, well_known_fallback: bool = True, well_known_timeout: float = 2.0) -> (dict, int)
Discovers an agent by looking up the _agent TXT record for the given domain.
Parameters:
domain(str): The domain name to discoverprotocol(str, optional): Try protocol-specific subdomain first (e.g.,mcp)timeout(float): DNS timeout in seconds (default 5.0)well_known_fallback(bool): If true, falls back tohttps://<domain>/.well-known/agentonERR_NO_RECORDorERR_DNS_LOOKUP_FAILED(default True)well_known_timeout(float): Timeout for the.well-knownHTTP fetch (default 2.0)
Returns:
DiscoveryResult: Object containing the parsed record and TTL
Raises:
AidError: If discovery fails for any reason
parse(txt: str) -> AidRecord
Parses and validates a raw TXT record string.
Parameters:
txt(str): Raw TXT record content (e.g., "v=aid1;uri=https://...")
Returns:
AidRecord: Parsed and validated record
Raises:
AidError: If parsing or validation fails
Data Types
AidRecord
Represents a parsed AID record with the following attributes:
v(str): Protocol version (always "aid1")uri(str): Agent endpoint URIproto(str): Protocol identifier (e.g., "mcp", "openapi")auth(str, optional): Authentication methoddesc(str, optional): Human-readable description
DiscoveryResult
Contains discovery results:
record(AidRecord): The parsed AID recordttl(int): DNS TTL in seconds
AidError
Exception raised when discovery or parsing fails:
code(int): Numeric error codemessage(str): Human-readable error message
Error Codes
| Code | Symbol | Description |
|---|---|---|
| 1000 | ERR_NO_RECORD |
No _agent TXT record found |
| 1001 | ERR_INVALID_TXT |
Record found but malformed |
| 1002 | ERR_UNSUPPORTED_PROTO |
Protocol not supported |
| 1003 | ERR_SECURITY |
Security policy violation |
| 1004 | ERR_DNS_LOOKUP_FAILED |
DNS query failed |
| 1005 | ERR_FALLBACK_FAILED |
.well-known fallback failed |
Advanced Usage
Custom Error Handling
from aid_py import discover, AidError
try:
result = discover("example.com")
# Use result.record...
except AidError as e:
if e.code == 1000: # ERR_NO_RECORD
print("No agent found for this domain")
elif e.code == 1001: # ERR_INVALID_TXT
print("Found a record but it's malformed")
else:
print(f"Other error: {e}")
Parsing Raw Records
from aid_py import parse, AidError
txt_record = "v=aid1;uri=https://api.example.com/agent;proto=mcp;desc=Example Agent"
try:
record = parse(txt_record)
print(f"Parsed: {record.proto} agent at {record.uri}")
except AidError as e:
print(f"Invalid record: {e}")
v1.1 Notes (PKA + Fallback)
-
PKA handshake: When a record includes
pka(k) andkid(i), the client performs an Ed25519 HTTP Message Signatures handshake to verify endpoint control. This requires an Ed25519 verification backend. Install one of:pip install aid-discovery[pka](installsPyNaClandcryptography)- Or add
PyNaCl>=1.5orcryptography>=42to your environment If no backend is available, discovery raisesERR_SECURITYwhen PKA is present.
-
.well-knownfallback: On DNS issues (ERR_NO_RECORDorERR_DNS_LOOKUP_FAILED), the client may fetchhttps://<domain>/.well-known/agent(TLS-anchored). Disable withwell_known_fallback=False.
Redirect Security
Client implementations do not automatically follow cross‑origin redirects from the discovered URI. If an initial request returns a redirect to a different origin (hostname or port), treat it as a potential security risk and either raise an error or require explicit confirmation.
More on PKA
See the documentation “Quick Start → PKA handshake expectations” for header coverage, algorithm requirements, timestamps, and key format.
Development
This package is part of the AID monorepo. To run tests:
# From the monorepo root
pnpm test
# Or run Python tests directly
cd packages/aid-py
python -m pytest tests/
License
MIT - see LICENSE for details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file aid_discovery-1.2.0.tar.gz.
File metadata
- Download URL: aid_discovery-1.2.0.tar.gz
- Upload date:
- Size: 17.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f6af1ec16b84204d0f4dd579825c50d8eabd564f4fbd84e4d9e512c3eb8b4740
|
|
| MD5 |
5d5350578d58ac48b8c1c9ad78bd1441
|
|
| BLAKE2b-256 |
6bc65661aaf8d42349d0bf802304e3716156ea9528ba69626aaada5d7d0e57d9
|
Provenance
The following attestation bundles were made for aid_discovery-1.2.0.tar.gz:
Publisher:
release.yml on agentcommunity/agent-interface-discovery
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
aid_discovery-1.2.0.tar.gz -
Subject digest:
f6af1ec16b84204d0f4dd579825c50d8eabd564f4fbd84e4d9e512c3eb8b4740 - Sigstore transparency entry: 925262181
- Sigstore integration time:
-
Permalink:
agentcommunity/agent-interface-discovery@d89310b8ba6b13c3b81edb5fa9ecec7549b26fbd -
Branch / Tag:
refs/heads/main - Owner: https://github.com/agentcommunity
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@d89310b8ba6b13c3b81edb5fa9ecec7549b26fbd -
Trigger Event:
push
-
Statement type:
File details
Details for the file aid_discovery-1.2.0-py3-none-any.whl.
File metadata
- Download URL: aid_discovery-1.2.0-py3-none-any.whl
- Upload date:
- Size: 15.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f2307718c52532d422943725daa1fedfff52b3df4ea4703f85945b8784b54535
|
|
| MD5 |
0a55686fda4f96acb0dc0f2cec14fea8
|
|
| BLAKE2b-256 |
cf61a62067dfc2df8075b08d61ce687cf5e999c8190f450244b20d4a44b6c4ea
|
Provenance
The following attestation bundles were made for aid_discovery-1.2.0-py3-none-any.whl:
Publisher:
release.yml on agentcommunity/agent-interface-discovery
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
aid_discovery-1.2.0-py3-none-any.whl -
Subject digest:
f2307718c52532d422943725daa1fedfff52b3df4ea4703f85945b8784b54535 - Sigstore transparency entry: 925262234
- Sigstore integration time:
-
Permalink:
agentcommunity/agent-interface-discovery@d89310b8ba6b13c3b81edb5fa9ecec7549b26fbd -
Branch / Tag:
refs/heads/main - Owner: https://github.com/agentcommunity
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@d89310b8ba6b13c3b81edb5fa9ecec7549b26fbd -
Trigger Event:
push
-
Statement type: