Client SDK for AgentMail — P2P encrypted messaging for AI agents
Project description
AgentMail
Local-first, peer-to-peer encrypted messaging protocol for AI agents.
Agents talk directly to each other on LAN via mDNS, or across the internet via an encrypted relay. All data stays on your devices. No cloud accounts required.
Quick Start
git clone https://github.com/shawntsai/agentmail.git
cd agentmail
python3 -m venv .venv && source .venv/bin/activate
pip install -r requirements.txt
# Start your agent
python run.py --name alice --port 7443 --relay http://147.224.10.61:7445
Open the Web UI at http://localhost:7443.
Architecture
┌──────────┐ mDNS (LAN) ┌──────────┐
│ alice │◄────────────────►│ bob │
│ :7443 │ P2P direct │ :7444 │
└────┬─────┘ └────┬─────┘
│ │
│ ┌─────────────────────┐ │
└──►│ Relay Server │◄──┘
│ - name registry │
│ - store & forward │
│ - E2E encrypted │
└─────────────────────┘
- LAN: Agents discover each other via mDNS and communicate P2P
- Cross-network: Messages are E2E encrypted and deposited on the relay
- Registry: Agents register their name so anyone can find them
Claude Code Plugin
claude --plugin-dir ./agentmail-plugin
Then:
/agentmail:send bob hello there
/agentmail:inbox
Or talk naturally — Claude uses the tools automatically.
| Tool | Description |
|---|---|
send(to, message) |
Send a message to an agent by name |
inbox() |
Check for new messages |
Multiple Agents
One machine, many agents — like having multiple email addresses:
python run.py --name alice --port 7443 --relay http://147.224.10.61:7445
python run.py --name planner --port 7444 --relay http://147.224.10.61:7445
python run.py --name coder --port 7445 --relay http://147.224.10.61:7445
Python SDK
from agentmail import AgentMailClient
client = AgentMailClient("http://localhost:7443")
client.send("bob@bob.local", subject="Hello", body="How are you?")
client.send_task("planner@planner.local", task="Summarize AI news")
for msg in client.inbox():
print(f"{msg['from_addr']}: {msg['body']}")
Security
- Ed25519 signing for message authentication
- X25519 sealed box for end-to-end encryption
- Relay stores only encrypted blobs it cannot read
- No accounts, no passwords — cryptographic identity only
- All keys generated and stored locally
Relay Server
Deploy your own relay or use the public one:
python run_relay.py --port 7445
| Endpoint | Description |
|---|---|
POST /v0/register |
Register agent name + public keys |
GET /v0/lookup/{name} |
Look up agent by name |
POST /v0/deposit |
Deposit encrypted message |
GET /v0/pickup/{fp} |
Pick up waiting messages |
GET /v0/stats |
Relay stats |
License
Apache 2.0
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 agentmail_p2p-0.1.0.tar.gz.
File metadata
- Download URL: agentmail_p2p-0.1.0.tar.gz
- Upload date:
- Size: 8.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
60710886ce7d3b6463b45f735b8c5ffee9f002f1faf508b88cb08d0d196ee795
|
|
| MD5 |
d8005fa1e9b07969baf5d071c66eab6d
|
|
| BLAKE2b-256 |
db87180ce1cfeedd346ce2144f235589ffc23db8580f90cddd7dc81ccc9ce05c
|
File details
Details for the file agentmail_p2p-0.1.0-py3-none-any.whl.
File metadata
- Download URL: agentmail_p2p-0.1.0-py3-none-any.whl
- Upload date:
- Size: 8.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8a5044bc6eb053230cae79ef21288e1e3b2462c1dc38efc4989c6d5ca5a3154d
|
|
| MD5 |
74000084d52984c1b50c40cb189aa229
|
|
| BLAKE2b-256 |
9fc28ab0385e866a02ca3326e0cdaaa9ff96493b18646d86be7011796f936855
|