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
Metadata
Release files for langchain-mq9 0.3.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| langchain_mq9-0.3.5.tar.gz | 5.7 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| langchain_mq9-0.3.5-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 11.5 kB
Release files / langchain_mq9-0.3.5.tar.gz
| Download URL | langchain_mq9-0.3.5.tar.gz |
|---|---|
| Size | 5.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
3b17e2f046434278a0441f8d4c8b3f7666d61a1417b8d59514f0d174c320354f
|
|
BLAKE2b-256 checksum How to use checksums |
de6a79329cb15d91b0308984a001194672dcf6a25333c478595f0f9005beb830
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.13
|
Release files / langchain_mq9-0.3.5-py3-none-any.whl
| Download URL | langchain_mq9-0.3.5-py3-none-any.whl |
|---|---|
| Size | 5.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c59623a40b67049b060daa0856b1db87a12fcfaa9ce799ae8d7a52ef7501380d
|
|
BLAKE2b-256 checksum How to use checksums |
9663aa860bebca8af3f8485f977a5bfb34a104f878c0c16466d14d4ff5869388
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.13
|