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

  1. The agent calls an MCP tool (lockmq_queues, lockmq_read, …) or the CLI.
  2. 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.
  3. Catalogue operations run at once and are audited. A read or a peek becomes a signed ticket on lockhub, and the agent gets pending.
  4. lox run decides the ticket on your profile’s rules, or asks you. The console checks the signed decision.
  5. The console calls the broker, keeps only the fields lockmq renders, masks and caps the output, and audits the call (never message content).
  6. 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.

Operations
CommandReturnsDefault rule
lockmq overviewbroker version, nodes and their alarms, feature flags, totalsauto
lockmq queuesone page of queues, filtered (--filter GLOB) and sorted by name, messages, ready, unacked or consumersauto
lockmq queue NAMEone queue with its arguments, effective policy, bindings and consumersauto
lockmq exchanges, bindingsexchanges; bindings of a vhost, a queue or an exchangeauto
lockmq policiespolicies, operator policies, runtime parameters (URI passwords removed)auto
lockmq consumers, connections, channelswith prefetch and ack mode; on the served vhosts onlyauto
lockmq stream NAMEa stream’s queue data and first/last offsetsauto
lockmq stream-offset NAME --consumer REFa named consumer’s stored offset and its lagauto
lockmq read STREAM --from first|last|N|TIMESTAMPstream messages, maskedauto
lockmq peek QUEUE --count Nthe head of a classic or quorum queue, masked; tier peek onlyasked

--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.

All client commands

Three protocols, one broker user

Protocols
ProtocolUsed forProfile key
Management HTTP APIevery catalogue operation; peekurl (required)
Stream protocolstream reads, first/last offsets, a named consumer’s stored offsetstream_url
AMQP 0-9-1stream reads when the profile has no stream_url, or through sshamqp_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…
A peek’s side effects are on the screen before you approve it.

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. detect uses mask rules, key-name heuristics and value detectors.
  • Other bodies: a text/* body, or one with no content type, goes through the detectors (not redact-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-death and 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

Console keys and commands
Key / commandDoes
:reviewshow the pending loosening and the change requests of clients, apply or refuse
:statusthe policy in force, the session
Ctrl-O, :resultsprint each read and peek result in clear in the console (the agent still gets it masked)
:unmasklet clients ask for unmasked output (--unmask), each such request approved on lockhub, never auto-approved
:quit, Ctrl-Cend 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

Refusal codes
CodeRetryMeans
E_BAD_ARGSrewritean argument is missing, out of range or unknown
E_WRONG_QUEUE_TYPErewriteread on a queue or peek on a stream
E_VHOST_NOT_SERVEDask the userthe profile does not serve that vhost
E_PROTOCOL_NOT_CONFIGUREDask the userset stream_url or amqp_url
E_TIERask the userpeek on a profile with tier read
E_DELIVERY_LIMITask the usera peek could dead-letter or drop messages of this quorum queue
E_UNMASK_OFFask the user--unmask while unmasked output is off in the console
E_AUTO_DENIEDask the userthe profile’s rule for this action is deny
E_STALErewritethe queue changed between the approval and the run; nothing was read: ask again
-32009 (unconfined)ask the userthe 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_NAMEstopa vhost or name that is, or holds, a . or .. path segment
E_POLICYstopanything 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.