How it works
How lockmq works
Two processes in two accounts. Only the console holds the key.
Two processes
The console (lockmq console) runs as the dedicated lockmq account. It holds the broker credentials and the only broker connections, applies the policy and masks messages.
The clients (the lockmq CLI and lockmq mcp, the MCP server on stdio) run on the agent’s side. They hold no secret and open no broker connection.
The clients talk to the console over a Unix socket that only the lockmq-clients group reaches. The kernel’s peer credentials are checked on every connection.
agent's container (agent) console container (lockmq)
┌──────────────────────┐ socket ┌─────────────────────────────────────┐
│ your AI agent │ ──────────▶ │ lockmq console │
│ lockmq mcp / CLI │ ◀────────── │ policy · allowlist · masking │
│ (no secret, no │ JSON-RPC, │ tickets to lockhub · audit log │
│ broker connection) │ peer uid │ credentials (prompt/Vault) │
└──────────────────────┘ checked └───────────────┬─────────────────────┘
│ management API (GET)
│ stream protocol / AMQP
▼
RabbitMQ
The path of a request
- The agent calls an MCP tool (
lockmq_queues,lockmq_read, …) or the CLI. - The console checks that the operation exists, its protocol is configured, the vhost is served, the tier allows it and the arguments are in range. All of this happens before any broker call.
- Catalogue operations run at once and are audited. A
reador apeekbecomes a signed ticket on lockhub, and the agent getspending. lox rundecides the ticket on your profile’s rules, or asks you. The console checks the signed decision.- The console calls the broker, keeps only the fields lockmq renders, masks and caps the output, and audits the call (never message content).
- The answer goes back framed as untrusted data.
Your rules: auto, ask, deny
Each profile sets one rule per action. auto lets lox run approve without a question, ask always asks a human, deny is refused by the lock before any ticket.
[profiles.prod.auto]
connect = "ask" # default: a human approves the first connection
list = "auto" # queues, exchanges, bindings, counts
read = "auto" # stream reads: no offset stored, nothing removed
peek = "ask" # default: requeued queue reads, a human approves each
purge = "deny" # no such operation yet: locked down in advance
Defaults: connect and peek ask, list and read auto, get, publish, purge and delete ask. auto = "full-auto" sets every action to auto, for a local broker left to the agent.
An unmasked read is asked whatever the rule. A looser rule is a policy loosening, which waits for your confirmation. Auto rules in the usage guide
The catalogue: an allowlist
What is not listed does not exist. Every operation is a CLI command and an MCP tool.
| Command | Returns | Default rule |
|---|---|---|
lockmq overview | broker version, nodes and their alarms, feature flags, totals | auto |
lockmq queues | one page of queues, filtered (--filter GLOB) and sorted by name, messages, ready, unacked or consumers | auto |
lockmq queue NAME | one queue with its arguments, effective policy, bindings and consumers | auto |
lockmq exchanges, bindings | exchanges; bindings of a vhost, a queue or an exchange | auto |
lockmq policies | policies, operator policies, runtime parameters (URI passwords removed) | auto |
lockmq consumers, connections, channels | with prefetch and ack mode; on the served vhosts only | auto |
lockmq stream NAME | a stream’s queue data and first/last offsets | auto |
lockmq stream-offset NAME --consumer REF | a named consumer’s stored offset and its lag | auto |
lockmq read STREAM --from first|last|N|TIMESTAMP | stream messages, masked | auto |
lockmq peek QUEUE --count N | the head of a classic or quorum queue, masked; tier peek only | asked |
--dry-run on read and peek asks the console for its verdict and the approval screen, without a read or peek ticket and without reading a message. A first connection may still ask its connect ticket.
Three protocols, one broker user
| Protocol | Used for | Profile key |
|---|---|---|
| Management HTTP API | every catalogue operation; peek | url (required) |
| Stream protocol | stream reads, first/last offsets, a named consumer’s stored offset | stream_url |
| AMQP 0-9-1 | stream reads when the profile has no stream_url, or through ssh | amqp_url |
An operation that needs a protocol you did not configure is refused with the key to set. Tested against RabbitMQ 3.13 and 4.1.
Stream reads stay read-only
Over the stream protocol the consumer is opened without a name. No offset is stored and no single-active-consumer group is joined; it reads at most read_max messages, then closes.
Over AMQP 0-9-1 it is a consumer with x-stream-offset and manual acks. On a stream an ack only returns credit: nothing is removed.
A real consumer’s position never moves: store_offset is never called.
The console checks that the target is a stream before the read, not at each ack. Over AMQP, if someone else deletes the stream and declares a classic or quorum queue under the same name in between, those acks could remove its messages; broker permissions match names, not types, so they cannot prevent it. The stream protocol reader does not have this gap.
Queue peek: a per-profile setting
Reading a classic or quorum queue is not strictly read-only. The management get takes up to count ready messages from the head and requeues them in the same call.
- they come back
redelivered=true; - a quorum queue’s delivery count grows by one (over the limit, the message is dead-lettered or dropped);
- the order seen by active consumers can change;
- only ready messages at the head are visible.
So peek exists only on a profile you set to tier = "peek" (lockmq profile add asks, default no). Every peek is asked, unless the profile sets auto.peek = "auto", a loosening you confirm.
On a quorum queue the console reads the effective delivery limit (argument, policy, operator policy; the lowest; RabbitMQ 4.x’s default 20). It refuses a peek within delivery_headroom of it, from the highest count it saw this session.
╭─ PROD · rabbitmq.example.com:15671 / orders · user lockmq-ro · tier peek ─────
│ requested by uid 1000 (alice) · pid 48211 · process "lockmq" (self-reported name)
│ agent: see why order events fail in the dead-letter queue
│
│ PEEK orders.failed count 3
│
│ PII: masked (2 mask rules, 1 allow rules; body redact-unknown; detectors: card, email, iban, phone)
│ ▲ NOT READ-ONLY: messages are taken from the head and requeued; they come back redelivered=true and their delivery count grows by 1
│ ▲ queue: quorum · ready 1204 · unacked 0 (not visible) · consumers 0
│ ▲ delivery-limit 20 · max seen so far 2/20
╰─ pending: ticket 01J…
Masking messages
Masking covers message properties, application properties, headers and bodies. Queue, exchange and stream names are kept.
- JSON bodies are parsed and masked per leaf.
body_mode = "redact-unknown"(the production default) redacts every string no allow rule names.detectuses mask rules, key-name heuristics and value detectors. - Other bodies: a
text/*body, or one with no content type, goes through the detectors (notredact-unknown). Binary, compressed or invalid bodies, and bodies of any other declared type, become<bytes:N sha256:H type:T>. - References: a redacted value becomes
<redacted:rN.K>, the same reference for the same value within a result. The clear value stays in the console’s memory. - Dead-letter queues: mask rules of the queue read, of the origin queue in a message’s first
x-deathand of its exchange apply. Allow rules come only from the queue read, so a forged header can only add masking.
# .lockmq/pii.toml
[[mask]]
queue = ["orders/order-events"] # vhost/name globs; "//name" for the vhost /
body = "$.customer.email" # JSON path: $.a.b, $.a[*].b, $.a[3]
mode = "email" # redact (default) | partial | email
[[mask]]
queue = ["*/*"]
header = "x-customer-*"
[[allow]]
queue = ["orders/order-events", "orders/order-events.dlq"]
body = "$.items[*].sku"
The AI tightens, the human loosens
The console reads the config files every 2 seconds. A tightening (a lower limit, peek → read, a removed vhost, a new mask rule, a stricter rule) applies at once, whoever wrote it.
A loosening waits for you: read → peek, a larger limit, a lower headroom, a new vhost or URL, redact-unknown → detect, a new allow rule, a looser auto rule. :review in the console shows it, and you apply or refuse it.
No socket method loosens the policy. The agent may add mask rules (lockmq pii add) and queue change requests (lockmq request).
Console keys
| Key / command | Does |
|---|---|
:review | show the pending loosening and the change requests of clients, apply or refuse |
:status | the policy in force, the session |
Ctrl-O, :results | print each read and peek result in clear in the console (the agent still gets it masked) |
:unmask | let clients ask for unmasked output (--unmask), each such request approved on lockhub, never auto-approved |
:quit, Ctrl-C | end the session |
The switches are console-only and each change is audited. The session ends after idle_timeout without a request, after max_session, or on lockmq logout.
Refusals the agent can act on
| Code | Retry | Means |
|---|---|---|
E_BAD_ARGS | rewrite | an argument is missing, out of range or unknown |
E_WRONG_QUEUE_TYPE | rewrite | read on a queue or peek on a stream |
E_VHOST_NOT_SERVED | ask the user | the profile does not serve that vhost |
E_PROTOCOL_NOT_CONFIGURED | ask the user | set stream_url or amqp_url |
E_TIER | ask the user | peek on a profile with tier read |
E_DELIVERY_LIMIT | ask the user | a peek could dead-letter or drop messages of this quorum queue |
E_UNMASK_OFF | ask the user | --unmask while unmasked output is off in the console |
E_AUTO_DENIED | ask the user | the profile’s rule for this action is deny |
E_STALE | rewrite | the queue changed between the approval and the run; nothing was read: ask again |
-32009 (unconfined) | ask the user | the client does not run confined (on the host, with the Docker socket, or an older client) and the profile does not accept it: run the agent inside lea, or ask for unconfined = true on a non-production profile |
E_UNSAFE_NAME | stop | a vhost or name that is, or holds, a . or .. path segment |
E_POLICY | stop | anything else the policy refuses |
MCP clients get them as tool errors with a structured refusal (code, retry, hint).
CLI exit codes: 0 ok, 1 refused, denied or failed, 2 no console, 3 usage or configuration error.