a2al

package module
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 7, 2026 License: MPL-2.0 Imports: 10 Imported by: 0

README

npm PyPI Go Reference

Official websites: a2al.org · Tangled Network · tngld.net

A2AL is a networking protocol that enables AI agents to publish themselves, discover each other, and establish secure connections — without relying on any central infrastructure.

Each agent receives a globally unique, cryptographic address (AID). Once publsished to the network, any agent worldwide can resolve that AID and initiate an authenticated, encrypted connection — regardless of network topology, NAT boundaries, or IP changes.

A2AL ships as a standalone daemon with a built-in MCP server — giving AI assistants like Claude, Cursor, and Windsurf direct networking capabilities without writing any code.

Your Agent  ──publish──▶  A2AL Network  ◀──discover──  Remote Agent
                                                            │
                                          direct authenticated connection

The Problem

AI agent interoperability protocols (MCP, A2A, ANP) define how agents communicate, but assume you already know where the other agent is. In practice:

  • No standard, open mechanism exists for agents to announce their availability or discover peers — whether deployed in data centers, on edge infrastructure, or on personal devices
  • Agent connectivity depends on pre-configured endpoints, platform-specific registries, or manual coordination — none of which scale across organizational and network boundaries
  • Agents behind NAT or with dynamic IPs face additional reachability barriers that existing protocols do not address

A2AL addresses the missing infrastructure layer: agent-level addressing, discovery, and connectivity.

What A2AL Does

Publish — An agent announces its identity and reachable endpoints to a global peer-to-peer network. Endpoint records update automatically as network conditions change.

Discover — Resolve any agent by its AID, or search by capability (e.g. "translation agents supporting zh-en legal domain"). Discovery is fully decentralized — no registry to operate or depend on. Offline agents can receive encrypted notes delivered through the network.

Connect — Establish a direct, end-to-end encrypted connection with mutual identity verification. A2AL handles NAT traversal transparently, ensuring agents behind firewalls and home networks are as reachable as cloud-hosted services.

Getting Started

For agent operators — Install a2ald and open http://localhost:2121. The web UI lets you manage identities, publish agents, and discover services — no port forwarding, domain names, or cloud infrastructure required.

For developers — A2AL integrates into your existing stack:

Integration Audience How
MCP Server AI agents Native tool calls — zero code integration
a2ald + REST API Any language Local HTTP API for publish / discover / fetch / tunnel
pip install a2al Python developers Bundled sidecar binary, zero infrastructure setup
npm install -g a2ald Node / JS developers Install daemon via npm, no Go toolchain required
Go library Go developers import "github.com/a2al/a2al" — embed directly
MCP Integration

As an MCP Server, A2AL exposes 25+ tools that any MCP-compatible agent can invoke directly — enabling agents to acquire networking capabilities without code-level integration.

Claude Desktop / Cursor / Windsurf / Cline — add to your MCP config:

{
  "mcpServers": {
    "a2al": {
      "command": "a2ald",
      "args": ["--mcp-stdio"]
    }
  }
}

See doc/mcp-setup.md for platform-specific paths and full tool list.

CLI
a2al status                         # node and agent status
a2al register                       # create and register a new agent
a2al search <service>               # discover agents by capability
a2al info <aid>                     # fetch agent info and card
a2al get  <aid> /path               # HTTP GET to a remote agent (encrypted, NAT-traversing)
a2al post <aid> /path -d '{}'       # HTTP POST to a remote agent
a2al tunnel open <aid>              # open a persistent local port for sustained access
a2al tunnel                         # list active tunnels
a2al tunnel close <id>              # close a tunnel
a2al note send <local> <aid> <b64>  # send an encrypted note to an offline agent
SDK (Go)
agent := a2al.New(a2al.Config{...})
agent.Start()

// Discover and connect to a remote agent
conn, err := agent.Connect(targetAID)

Design Principles

Self-sovereign Identity — Each agent's address is derived from its own key pair. No registration authority is involved. Identity is verifiable end-to-end: no agent can claim an AID it does not hold the private key for.

Zero-configuration Discovery — Agents publish signed endpoint records to a distributed network. Any agent can resolve an AID to a live endpoint. The network operates at any scale — from a handful of nodes to millions.

Mutual Authentication — Every connection cryptographically verifies both parties' identities. You always know the agent on the other end is who it claims to be.

Network-agnostic — A2AL works across NAT, firewalls, and dynamic IPs. Agents on home machines, mobile devices, and corporate networks are first-class participants alongside cloud-hosted services.

Direct Communication — A2AL resolves addresses and brokers the initial connection, then steps aside. Application data flows directly between agents, not through the protocol.

Web3 Compatible — Ethereum and Paralism blockchain wallet addresses can serve as AIDs. Cross-key attestation allows an agent to prove ownership of both a native AID and a blockchain identity. Web3 integration is supported, not required.

Relationship to AI Protocols

A2AL is complementary to existing agent communication standards — it provides the networking foundation they assume but do not include.

Protocol Role How A2AL fits in
MCP Agent tool-calling interface A2AL operates as an MCP-installable tool, giving agents networking capability
A2A Agent collaboration semantics A2AL provides the discovery and connectivity layer A2A relies on
ANP Agent networking vision A2AL implements the decentralized network layer ANP envisions

Try the Demo

Encrypted chat between two machines. On each machine, two terminals:

a2ald        # terminal 1: network layer, joins the public Tangled Network
demo3-chat   # terminal 2: chat app — download pre-built binary below

Bob types Alice's AID → direct encrypted QUIC tunnel → chat.

Go developers: replace demo3-chat with go run ./examples/demo3-chat.

Download: (demos require a2ald v0.1.8+)

Windows users: the binaries are currently unsigned. When Windows SmartScreen shows a warning, click "More info" → "Run anyway". This is expected for open-source binaries without a paid code-signing certificate and does not indicate a security risk.

More scenarios (marketplace, swarm) and single-machine variants: doc/examples.md.

Status

A2AL is under active development. Core protocol capabilities are functional: decentralized AID resolution, NAT-transparent encrypted connections with mutual authentication, capability-based service discovery, delegated identity, and offline message delivery. Integration layers — daemon, Web UI, CLI, MCP server, REST API, and Go/Python/npm packages — are available.

See doc/API.md for the current library API.

Disclaimer

A2AL is a networking protocol project. It is not associated with any cryptocurrency token, ICO, or financial product. Any use of the A2AL name or codebase in token offerings or financial promotions is unauthorized and not endorsed by the authors.

Contributing

Contributions are welcome. Before your pull request can be merged, you must sign the Contributor License Agreement. A bot will prompt you automatically when you open a PR.

Please open an issue before starting significant work.

Author

XG.Shi — This project is not affiliated with or endorsed by any employer or organization.

License

Copyright (c) 2026 The A2AL Authors

Licensed under the Mozilla Public License 2.0.

Documentation

Index

Constants

View Source
const (
	// VersionEd25519 is the version byte for Ed25519-derived addresses (spec §6.1).
	VersionEd25519 byte = 0xA0
	// VersionP256 is reserved for P-256–derived addresses (spec §6.2).
	VersionP256 byte = 0xA1
	// VersionParalism is reserved for Paralism / Bitcoin HASH160 addresses (spec §6.2).
	VersionParalism byte = 0xA2
	// VersionEthereum is the version byte for Ethereum 20-byte addresses (spec §6.2).
	VersionEthereum byte = 0xA3
)

Variables

View Source
var (
	// ErrNotFound is returned when a Storage key is missing.
	ErrNotFound = errors.New("a2al: not found")
	// ErrInvalidAddress indicates a malformed or checksum-failed address string.
	ErrInvalidAddress = errors.New("a2al: invalid address")
)
View Source
var ParalismBech32HRPs = []string{"bc", "pr"}

ParalismBech32HRPs lists accepted Bech32 human-readable parts (extend for new Paralism HRPs).

View Source
var ParalismBech32PreferredHRP = "bc"

ParalismBech32PreferredHRP is used when formatting Address.String() for version Paralism.

Functions

func CommonPrefixLen

func CommonPrefixLen(a, b NodeID) int

CommonPrefixLen returns the number of leading bits where a and b agree (MSB first). If a == b, returns 256.

Types

type Address

type Address [21]byte

Address is a 21-byte logical address: version byte + 20-byte hash (spec §6.1).

func ParseAddress

func ParseAddress(s string) (Address, error)

ParseAddress parses any supported address string (spec §6.3 priority order).

func ParseEthereumAddress

func ParseEthereumAddress(s string) (Address, error)

ParseEthereumAddress is a convenience shortcut for Ethereum "0x" addresses.

func ParseParalismAddress

func ParseParalismAddress(s string) (Address, error)

ParseParalismAddress parses a Paralism/Bitcoin-style address string into a VersionParalism Address.

func (Address) String

func (a Address) String() string

String returns the canonical display form, dispatched by version byte.

type AddressCodec

type AddressCodec interface {
	Version() byte
	CanParse(s string) bool
	Parse(s string) ([20]byte, error)
	Format(addr20 [20]byte) string
}

AddressCodec handles string↔internal conversion for one blockchain address type.

type MemStorage

type MemStorage struct {
	// contains filtered or unexported fields
}

MemStorage is an in-memory Storage for tests and ephemeral use.

func NewMemStorage

func NewMemStorage() *MemStorage

NewMemStorage returns an empty MemStorage.

func (*MemStorage) Delete

func (s *MemStorage) Delete(key string) error

func (*MemStorage) Get

func (s *MemStorage) Get(key string) ([]byte, error)

func (*MemStorage) Put

func (s *MemStorage) Put(key string, value []byte) error

type NodeID

type NodeID [32]byte

NodeID is a 256-bit DHT routing key (spec §6.1).

func Distance

func Distance(a, b NodeID) NodeID

Distance is the XOR metric d(A,B) = NodeID_A ⊕ NodeID_B (spec §3.3).

func NodeIDFromAddress

func NodeIDFromAddress(addr Address) NodeID

NodeIDFromAddress returns SHA-256(version_byte || hash_20bytes).

type Storage

type Storage interface {
	Get(key string) ([]byte, error)
	Put(key string, value []byte) error
	Delete(key string) error
}

Storage is a key-value persistence abstraction. Implementations live in the application layer (desktop path, mobile sandbox, etc.).

Directories

Path Synopsis
cmd
a2al command
a2al is the command-line client for the local a2ald daemon (REST API only).
a2al is the command-line client for the local a2ald daemon (REST API only).
a2ald command
a2ald is the A2AL daemon: DHT/QUIC host, REST API, Web UI, TCP gateway, MCP.
a2ald is the A2AL daemon: DHT/QUIC host, REST API, Web UI, TCP gateway, MCP.
Package config holds Phase 3 daemon TOML settings (library layer; daemon owns persistence).
Package config holds Phase 3 daemon TOML settings (library layer; daemon owns persistence).
Package daemon implements the a2ald runtime: DHT/QUIC host, REST API, TCP gateway, and MCP server.
Package daemon implements the a2ald runtime: DHT/QUIC host, REST API, TCP gateway, and MCP server.
aidproxy
Package aidproxy implements the AID Resource Addressing Gateway.
Package aidproxy implements the AID Resource Addressing Gateway.
Package host is the Phase 2 SDK: DHT + QUIC, nat-sense, multi-candidate endpoints (2b), optional UPnP, Happy Eyeballs dial, Publish/Resolve/Connect/Accept.
Package host is the Phase 2 SDK: DHT + QUIC, nat-sense, multi-candidate endpoints (2b), optional UPnP, Happy Eyeballs dial, Publish/Resolve/Connect/Accept.
Package identity holds Phase 3 delegation proofs (master → operational key).
Package identity holds Phase 3 delegation proofs (master → operational key).
internal
nodeks
Package nodeks loads or creates the daemon DHT node identity (node.key).
Package nodeks loads or creates the daemon DHT node identity (node.key).
peerscache
Package peerscache persists DHT neighbor UDP dial strings for cold bootstrap.
Package peerscache persists DHT neighbor UDP dial strings for cold bootstrap.
registry
Package registry persists REST-registered agents (operational key + TCP target).
Package registry persists REST-registered agents (operational key + TCP target).
Package mobile exposes the a2ald daemon to Android and iOS via gomobile bind.
Package mobile exposes the a2ald daemon to Android and iOS via gomobile bind.
Package natmap provides optional NAT helpers (Phase 2b: UPnP IGD port mapping).
Package natmap provides optional NAT helpers (Phase 2b: UPnP IGD port mapping).
Package natsense implements observed address consensus (spec Phase 2a: ≥3 distinct reporters).
Package natsense implements observed address consensus (spec Phase 2a: ≥3 distinct reporters).

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL