MCPcopy Index your code
hub / github.com/bschwind/mqtt-broker

github.com/bschwind/mqtt-broker @main

Chat with this repo
repository ↗ · DeepWiki ↗ · + Follow
233 symbols 549 edges 14 files 7 documented · 3%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

mqtt-broker

A tokio-based MQTT v5 broker written in Rust.

Project Goals

The goals for this project are fairly straightforward:

  • Adhere to the MQTT V5 Spec
  • Be easily deployable as a single binary
  • Have reasonable performance and memory usage on a single node

I originally started this project as a simple, open-source broker for any IoT products I might make. If I were to sell such products, I would want to allow users to run their own broker in case I can no longer run one, and it should be as easy as possible to do so.

Extra features like a broker cluster or extra transport layers are nice to have features, but won't be considered until the core V5 spec is implemented. The exception to this is the WebSocket transport, which is specifically mentioned in the spec and quite useful to have.

Comparison to Other Brokers

Wikipedia has a fairly comprehensive list of brokers to choose from.

rumqtt at the moment appears to be the most fully-featured broker. Take a look there first if you're looking for a more "ready-to-go" Rust broker.

PubSubRT is another interesting Rust-based broker. It's an alternative to MQTT, not an implementation of it.

NATS.rs seems really nice too, but I haven't looked further into it yet.

Spec Compliance

This broker is currently not compliant with the MQTT V5 spec. Visit the spec compliance milestone to see the current progress.

Dependencies

  • cargo
  • rustc (version 1.39 or later)

Build

$ cargo build --release

Run

$ cargo run --release

Testing

$ cargo test

Code Format

The formatting options currently use nightly-only options.

$ cargo +nightly fmt

Code Linting

$ cargo clippy

Code Fuzzing

Fuzzing requires a nightly toolchain. Fuzzing for this project is currently confirmed to work with:

rustc 1.42.0-nightly (6d3f4e0aa 2020-01-25)

Running

cargo install cargo-fuzz
cargo +nightly fuzz run decoder_fuzzer_v311
cargo +nightly fuzz run decoder_fuzzer_v500
cargo +nightly fuzz run topic_filter_fuzzer
cargo +nightly fuzz run topic_fuzzer

Extension points exported contracts — how you extend this code

PacketSize (Interface)
(no doc) [44 implementers]
mqtt-v5/src/types.rs
PropertySize (Interface)
(no doc) [14 implementers]
mqtt-v5/src/types.rs
Encode (Interface)
(no doc) [30 implementers]
mqtt-v5/src/types.rs

Core symbols most depended-on inside this repo

calc_size
called by 66
mqtt-v5/src/types.rs
encode
called by 64
mqtt-v5/src/encoder.rs
insert
called by 36
mqtt-v5-broker/src/tree.rs
property_size
called by 28
mqtt-v5/src/types.rs
send
called by 27
mqtt-v5-broker/src/broker.rs
decode_mqtt
called by 20
mqtt-v5/src/decoder.rs
encode_string
called by 17
mqtt-v5/src/encoder.rs
encode_mqtt
called by 17
mqtt-v5/src/encoder.rs

Shape

Function 92
Method 57
Class 54
Enum 27
Interface 3

Languages

Rust100%

Modules by API surface

mqtt-v5/src/types.rs76 symbols
mqtt-v5/src/encoder.rs33 symbols
mqtt-v5/src/topic.rs31 symbols
mqtt-v5-broker/src/broker.rs28 symbols
mqtt-v5/src/decoder.rs27 symbols
mqtt-v5-broker/src/client.rs12 symbols
mqtt-v5/src/lib.rs11 symbols
mqtt-v5-broker/src/tree.rs11 symbols
mqtt-v5-broker/src/main.rs4 symbols

For agents

$ claude mcp add mqtt-broker \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact