Skip to main content

langchain-dns-aid

DNS-AID agent discovery middleware for LangChain. Enables agents to discover, publish, and unpublish themselves via DNS using the DNS-AID protocol.

Why middleware instead of tools?

Unlike tool-only integrations (CrewAI, LlamaIndex, etc.), the middleware approach uses LangChain's lifecycle hooks to auto-publish the agent on startup and auto-unpublish on shutdown. This prevents stale DNS records when agents crash or forget to clean up.

Install

pip install langchain-dns-aid

Quick start

from langchain import create_agent, init_chat_model
from langchain_dns_aid import DnsAidMiddleware

agent = create_agent(
    model=init_chat_model("gpt-4o"),
    middleware=[DnsAidMiddleware(
        agent_name="my-assistant",
        domain="agents.example.com",
        endpoint="assistant.example.com",
        capabilities=["code-review", "documentation"],
        backend_name="route53",
    )],
)

# Agent is auto-published to DNS on startup.
# It can discover other agents during conversation.
# On shutdown, it is auto-unpublished.

What it does

Hook Action
before_agent Auto-publishes the agent to DNS via SVCB records
after_agent Auto-unpublishes the agent, removing DNS records
Tools dns_aid_discover, dns_aid_publish, dns_aid_unpublish

Configuration

Parameter Default Description
agent_name None Agent DNS label (required for auto-publish)
domain None Domain to publish under (required for auto-publish)
protocol "mcp" Protocol: mcp, a2a, or https
endpoint "" Hostname where agent is reachable
port 443 Port number
capabilities None List of agent capabilities
backend_name None DNS backend: route53, cloudflare, mock, etc.
auto_publish True Auto-publish on agent start
auto_unpublish True Auto-unpublish on agent stop

Discovery only (no auto-publish)

agent = create_agent(
    model=init_chat_model("gpt-4o"),
    middleware=[DnsAidMiddleware(
        auto_publish=False,
        auto_unpublish=False,
    )],
)
# Agent gets dns_aid_discover tool but doesn't publish itself.

License

Apache-2.0

Metadata

Release files for langchain-dns-aid 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for langchain-dns-aid 0.1.0
File Size Uploaded
langchain_dns_aid-0.1.0.tar.gz 12.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for langchain-dns-aid 0.1.0
File Interpreter ABI Platform
langchain_dns_aid-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 23.8 kB

Release files / langchain_dns_aid-0.1.0.tar.gz

Download URL langchain_dns_aid-0.1.0.tar.gz
Size 12.3 kB
Tags Source
SHA-256 checksum
How to use checksums
eea39ed1a65f0835235d4920eebcc56e2aad39e8a0229acd87e5ffae0dc607a4
BLAKE2b-256 checksum
How to use checksums
3a6225de0b2cfbc0479ee66d374c553f63267e765eb2234cd468b4f4d1e682d5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Apr 13, 2026.

Transparency log

Release files / langchain_dns_aid-0.1.0-py3-none-any.whl

Download URL langchain_dns_aid-0.1.0-py3-none-any.whl
Size 11.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
667b0187894201368d6b0c16d933e6e224233baf38674621341d4d6129ef6e3d
BLAKE2b-256 checksum
How to use checksums
70c5fd1ea74520f5228e6bffdfa95f6b1971ce4f20c9f0715b0d5b390bc1ff6c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Apr 13, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page