LangChain tools for the mq9 AI-native async Agent mailbox protocol
Project description
langchain-mq9
LangChain tools for the mq9 AI-native async mailbox protocol.
Give your LangChain Agents a persistent, priority-aware inbox — powered by RobustMQ.
Install
pip install langchain-mq9
Quick start
from langchain_mq9 import Mq9Toolkit
from langchain.agents import AgentType, initialize_agent
from langchain_openai import ChatOpenAI
toolkit = Mq9Toolkit(server="nats://demo.robustmq.com:4222")
tools = toolkit.get_tools()
agent = initialize_agent(
tools,
ChatOpenAI(model="gpt-4o-mini"),
agent=AgentType.OPENAI_FUNCTIONS,
verbose=True,
)
agent.invoke({"input": "Create a mailbox for me to receive task results."})
Tools
CreateMailboxTool
Creates a mq9 mailbox and returns its mail_id.
| Parameter | Type | Default | Description |
|---|---|---|---|
ttl |
int | 3600 | Mailbox TTL in seconds |
SendMessageTool
Sends an async message to a mailbox.
| Parameter | Type | Default | Description |
|---|---|---|---|
mail_id |
str | — | Target mailbox address |
content |
str | — | Message content |
priority |
str | "normal" |
"high", "normal", or "low" |
GetMessagesTool
Retrieves pending messages from a mailbox.
| Parameter | Type | Default | Description |
|---|---|---|---|
mail_id |
str | — | Mailbox to read from |
limit |
int | 10 | Max messages to return |
Mq9Toolkit
from langchain_mq9 import Mq9Toolkit
toolkit = Mq9Toolkit(server="nats://localhost:4222")
tools = toolkit.get_tools() # returns [CreateMailboxTool, SendMessageTool, GetMessagesTool]
Multi-Agent example
See examples/agent_example.py for a complete example of two Agents communicating asynchronously via mq9.
Why mq9?
- Store-first: messages persist until TTL expires — sender and receiver don't need to be online simultaneously
- Priority queuing: route urgent tasks ahead of background work
- No consumer state: simple, stateless protocol ideal for Agent workflows
- Built on NATS: fast, lightweight, zero broker dependencies
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 langchain_mq9-0.3.5.tar.gz.
File metadata
- Download URL: langchain_mq9-0.3.5.tar.gz
- Upload date:
- Size: 5.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3b17e2f046434278a0441f8d4c8b3f7666d61a1417b8d59514f0d174c320354f
|
|
| MD5 |
e3120958de21cdd1b00d5a5b0b80f320
|
|
| BLAKE2b-256 |
de6a79329cb15d91b0308984a001194672dcf6a25333c478595f0f9005beb830
|
File details
Details for the file langchain_mq9-0.3.5-py3-none-any.whl.
File metadata
- Download URL: langchain_mq9-0.3.5-py3-none-any.whl
- Upload date:
- Size: 5.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c59623a40b67049b060daa0856b1db87a12fcfaa9ce799ae8d7a52ef7501380d
|
|
| MD5 |
8c1e0862ff5a2d81d23de34d3533963d
|
|
| BLAKE2b-256 |
9663aa860bebca8af3f8485f977a5bfb34a104f878c0c16466d14d4ff5869388
|