| name | xmtp |
| description | Send and receive messages via the XMTP decentralized messaging protocol using the xmtp CLI tool. Use when the user asks to send, read, or monitor XMTP messages, manage conversations, create DMs or groups, check address reachability, or interact with the XMTP network. |
XMTP Messaging
Use the xmtp CLI tool for decentralized end-to-end encrypted messaging.
All data commands support --json for structured output. The binary is
built from this repository (cargo build -p xmtp-cli).
Profile Setup
Profiles store identity keys and message databases. A default profile is
auto-created on first TUI launch, but agents should create one explicitly.
xmtp new mybot --env dev
xmtp new mybot --import 0xHEX_PRIVATE_KEY
xmtp list --json
xmtp default --json
xmtp default mybot
xmtp info --json
Listing Conversations
xmtp conversations --json
xmtp conversations --consent allowed --json
xmtp conversations --profile mybot --json
Response format:
{
"conversations": [
{
"id": "abc123...",
"type": "dm",
"name": null,
"last_message": "Hello!",
"last_message_ns": 1710000000000000000
}
]
}
Reading Messages
xmtp messages <conversation_id> --json
xmtp messages <conversation_id> --limit 20 --json
Response format:
{
"conversation_id": "abc123...",
"messages": [
{
"id": "msg001...",
"conversation_id": "abc123...",
"sender_inbox_id": "inbox_xyz...",
"sent_at_ns": 1710000000000000000,
"delivery_status": "published",
"content": { "type": "text", "text": "Hello!" }
}
]
}
Content types: text, markdown, reaction, reply, read_receipt,
attachment, remote_attachment, unknown, system.
Sending Messages
xmtp send <conversation_id> "Hello from the agent!" --json
Creating Conversations
xmtp dm 0x1234...abcd --json
xmtp dm vitalik.eth --json
xmtp group 0xAddr1 0xAddr2 --name "Team Chat" --json
Managing Conversations
xmtp members <conversation_id> --json
xmtp request <conversation_id> accept --json
xmtp request <conversation_id> deny --json
xmtp can-message 0xAddr1 0xAddr2 --json
Real-Time Streaming
The stream command outputs NDJSON (one JSON object per line) and runs
until interrupted. Use this to monitor incoming messages in real time.
xmtp stream all --profile mybot
xmtp stream messages --profile mybot
xmtp stream conversations --profile mybot
NDJSON event types:
{"type":"ready","stream":"all"}
{"type":"message","message_id":"...","conversation_id":"...","sender_inbox_id":"...","sent_at_ns":...,"delivery_status":"published","content":{"type":"text","text":"Hi"}}
{"type":"conversation","conversation_id":"...","conversation_type":"dm","name":null}
Agent Workflow: Monitor and Respond
- Start streaming in a background process
- Parse each NDJSON line for incoming messages
- Fetch conversation context when needed
- Send a response
xmtp stream messages --profile mybot
xmtp messages <conversation_id> --limit 20 --json --profile mybot
xmtp send <conversation_id> "Got it, processing your request..." --json --profile mybot
Error Handling
- On success with
--json: structured JSON on stdout, exit code 0
- On failure with
--json: {"error":"description"} on stdout, exit code 1
- On failure without
--json: error message on stderr, exit code 1
Profile Selection
All commands accept --profile <name>. If omitted, the default profile
is used. Profile commands (list, info, default) use a positional
name argument instead.