Bot-to-Bot P2P communication over Tailscale using the LCP/1.1 UDP protocol. Enables AI agents on different machines to exchange signed, reliable messages in...
Peer-to-peer messaging between AI agents on different machines via UDP over Tailscale.
text
Agent A (Machine 1) Agent B (Machine 2)
┌──────────────────┐ ┌──────────────────┐
│ lcp_node.py │ UDP :9528 │ lcp_node.py │
│ (daemon) │ ◄────────────► │ (daemon) │
│ │ Ed25519 signed │ │
│ IPC: Unix sock │ ACK + Retry │ IPC: TCP :9529 │
└──────────────────┘ └──────────────────┘
▲ ▲
│ Local IPC │ Local IPC
lcp_send / lcp_check / lcp_ack (same commands)
pip install pynacl)Edit scripts/lcp_node.py and set:
python
MY_NAME = "AgentA" # Your agent name
PEER_NAME = "AgentB" # Peer agent name
MY_IP = "100.x.x.x" # Your Tailscale IP
PEER_IP = "100.y.y.y" # Peer Tailscale IP
bash
# macOS
python3 scripts/lcp_node.py
# Windows
python scripts/windows/lcp_node_win.py
bash
# Send a message
python3 scripts/lcp_send.py "Hello from Agent A!"
python3 scripts/lcp_send.py --type task "Please process data X"
python3 scripts/lcp_send.py --type result --reply-to <msg-id> "Done!"
# Check inbox
python3 scripts/lcp_check.py --pretty
# Archive processed messages
python3 scripts/lcp_ack.py
# Check daemon status
python3 scripts/lcp_status.py
JSON messages with structure:
json
{
"id": "uuid",
"from": "AgentA",
"to": "AgentB",
"timestamp": "ISO-8601",
"type": "chat|task|result|ping|pong",
"message": "content",
"replyTo": "optional-msg-id",
"security": {
"algo": "ed25519",
"pubkey": "<base64>",
"signature": "<base64>"
}
}
text
[Magic 4B: "LCP1"][Seq 4B][Type 1B][JSON payload...]
Type: 0x01=DATA, 0x02=ACK, 0x03=HEARTBEAT
Create a LaunchAgent plist pointing to lcp_node.py with RunAtLoad=true and KeepAlive for crash recovery.
Use Task Scheduler or nssm to run lcp_node_win.py as a service.
data/inbox/ — incoming messages (pending)data/inbox_archive/ — processed messagesdata/outbox/ — sent message copiesdata/seen_ids.json — duplicate detection stateParameterDefaultDescriptionLCP_PORT9528UDP port for peer communicationIPC_SOCKET/tmp/lcp.sockUnix socket for local IPC (macOS)IPC_PORT9529TCP port for local IPC (Windows)MAX_RETRIES5ACK retry attemptsHEARTBEAT_INTERVAL_S30Seconds between heartbeatsPEER_TIMEOUT_S120Seconds before marking peer offline
For multi-peer support, run multiple daemon instances on different ports or extend lcp_node.py with a peer registry. See references/protocol-spec.md for the full LCP/1.1 specification.