AgentMailbox — Python SDK
Python client for AgentMailbox, the context-sync protocol for AI agents. Mirrors the JS SDK feature-for-feature.
Install
pip install agentsmcp
The PyPI distribution is named agentsmcp (matching the npm SDK); the
import name stays agentmailbox:
from agentmailbox import AgentMailbox
For local development from a clone:
pip install -e ".[dev]"
Requires Python 3.10+.
Start the server
The Python SDK is a pure HTTP client — it talks to the AgentMailbox Node server. Start it first:
cd ~/agentmailbox
npm start
Async usage
import asyncio
from agentmailbox import AgentMailbox
async def main():
async with AgentMailbox("researcher@demo", server="http://localhost:3000") as a:
await a.connect()
result = await a.send(
"writer@demo",
{"task": "summarize diffusion models"},
context_snapshot={"step": "research_complete", "paper_count": 2},
)
print(result.thread_id)
asyncio.run(main())
Multi-agent (CC/BCC/ReplyAll)
async with AgentMailbox("orchestrator@demo", server=SERVER) as orchestrator:
await orchestrator.connect()
sent = await orchestrator.send(
"researcher@demo",
{"task": "find 50 papers on diffusion models"},
cc=["writer@demo"],
bcc=["logger@demo"],
context_snapshot={"step": "task_dispatched", "priority": "high"},
)
async with AgentMailbox("researcher@demo", server=SERVER) as researcher:
await researcher.connect()
inbound = await researcher.receive()
# inbound.context.snapshot → {"step": "task_dispatched", "priority": "high"}
# inbound.messages[0].cc → ["writer@demo"]
# inbound.messages[0].bcc → None (stripped from non-sender's view)
await researcher.reply_all(
sent.thread_id,
{"result": "found 50 papers"},
context_snapshot={"step": "research_complete", "paper_count": 50},
)
Run the bundled demos:
python examples/basic.py
python examples/multi_agent.py
Sync usage
For scripts and notebooks that aren't async-friendly:
from agentmailbox import AgentMailboxSync
agent = AgentMailboxSync("researcher@demo")
agent.connect()
result = agent.send("writer@demo", {"task": "..."})
print(result.thread_id)
AgentMailboxSync drives a fresh event loop per call via asyncio.run.
It's convenient but slower than the async client.
API
All methods return typed dataclasses (SendResult, ReceiveResult,
Thread, ContextFrame, Message, ParticipantRole, Context).
No untyped dicts in the public surface.
| Method | HTTP |
|---|---|
connect() |
POST /agents/register |
send(to, payload, ...) |
POST /messages/send |
reply_all(thread_id, payload) |
POST /messages/reply-all |
unread() |
GET /mailbox/:id/unread |
receive(from_agent=None) |
GET /mailbox/:id/unread + filter |
threads() |
GET /mailbox/:id |
sync(thread_id) |
GET /threads/:id/sync?as=:id |
participants(thread_id) |
GET /threads/:id/participants?as= |
mark_read(thread_id) |
POST /mailbox/:id/read |
Exceptions
AgentMailboxError— base class..status_codeset when raised from HTTP.NotFoundError— 404ServerError— 5xxConnectionError— server unreachable
License
MIT
Metadata
Release files for agentsmcp 0.1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| agentsmcp-0.1.2.tar.gz | 11.5 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| agentsmcp-0.1.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 20.9 kB
Release files / agentsmcp-0.1.2.tar.gz
| Download URL | agentsmcp-0.1.2.tar.gz |
|---|---|
| Size | 11.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a8d69cee2c690773693a24ffd402b97283e6b878416d1913d652fe8ffbe6839c
|
|
BLAKE2b-256 checksum How to use checksums |
1bc1cd2dc0264cadf9b3cdcfcc3baa01006c62e0e6c73949afb160cc9a49ef6b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.5
|
Release files / agentsmcp-0.1.2-py3-none-any.whl
| Download URL | agentsmcp-0.1.2-py3-none-any.whl |
|---|---|
| Size | 9.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
85ee9cbd8ab21d6a1bd3910773b32be730073277597b5d4ee160939305b15e95
|
|
BLAKE2b-256 checksum How to use checksums |
3995f36c44a01eb717862a3a8605a4be9c21f9660cce97fd03e052ec15c29175
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.5
|