@rpiirmdhni/litespeak
v1.3.2
Published
A lightweight, zero-setup, high-performance MQTT Broker & REST API platform for IoT.
Maintainers
Readme
⚡ LiteSpeak
A lightweight, zero-setup, high-performance MQTT Broker & REST API platform for IoT.
LiteSpeak is an open-source, dual-protocol Internet of Things (IoT) platform designed to eliminate the friction of traditional brokers. By combining a low-latency MQTT Broker (powered by Aedes) with a dynamic REST API (Express), LiteSpeak allows microcontrollers and applications to communicate instantly without the need for prior channel registration or complex authentication.
It acts as a lightweight alternative to commercial IoT cloud platforms, running seamlessly on Node.js and utilizing SQLite in Write-Ahead Logging (WAL) mode to handle high-concurrency sensor data streams.
🌟 Key Features
- 🤖 AI-Ready (MCP Integration): Native support for the Model Context Protocol (MCP) via Server-Sent Events. AI agents can seamlessly read sensor history or trigger hardware actuators directly through the built-in MCP server!
- Unified Broker (Bridge): Two-way synchronization! Data sent via the REST API is instantly broadcasted to all MQTT subscribers in real-time, functioning just like traditional enterprise IoT clouds.
- Zero-Friction Setup: No need to create accounts, generate tokens, or pre-register channels. Just publish to any topic and the system automatically tracks it.
- Standard Protocols: Fully compatible with MQTT 3.1 and 3.1.1. Connect easily with ESP8266, ESP32 (PubSubClient), or standard MQTT tools.
- Dual Protocol: Receive data via MQTT (
mqtt://) and retrieve/publish data via REST API (http://) simultaneously. - Dynamic Payloads: Send any JSON structure. The database adapts dynamically without needing rigid schemas.
- High Concurrency: Built-in SQLite WAL mode ensures no database locking, even when receiving hundreds of requests per second.
- Production-Ready: Pre-configured with PM2, Helmet (Security headers), CORS, GZIP Compression, and graceful Uncaught Exception handling.
🛠️ Tech Stack
LiteSpeak is powered by a modern, lightweight JavaScript ecosystem:
- Runtime: Node.js
- MQTT Broker: Aedes (High-performance TCP stream broker)
- REST API: Express.js (Routing & HTTP handling)
- AI Integration: MCP SDK (Server-Sent Events for AI agents)
- Database: SQLite3 (Using WAL mode for extreme concurrency)
- Process Manager: PM2 (For 24/7 production deployment)
- Security & Perf:
helmet,cors,compression
🥊 Why LiteSpeak?
Tired of commercial IoT platforms that restrict your hardware? LiteSpeak was built to eliminate the artificial limitations typically found in enterprise cloud services:
| Feature | 📉 Traditional Cloud Platforms (Free Tier) | ⚡ LiteSpeak | | -------------------- | ------------------------------------------- | ----------------------------------------------- | | Cost | High subscription fees for serious usage | 100% Free & Open Source | | Rate Limit | Heavily throttled (e.g., 1 request per 15s) | Unlimited / Zero Throttling | | Channels/Devices | Strictly capped (e.g., max 4 channels) | Unlimited (Bound only by server specs) | | Data Fields | Hardcoded limits (e.g., max 8 fields) | Unlimited JSON Fields | | Setup Time | Tedious registration & API Key generation | Instant (Zero-setup, just send the payload) |
🚀 Quick Start
1. Installation
Install LiteSpeak globally via NPM so you can run it from anywhere in your terminal:
npm install -g @rpiirmdhni/litespeak2. Run the Server
Simply type the following command to start both the MQTT Broker and the REST API:
litespeakYou should see the following logs indicating the server is healthy:
[2026-08-23 01:00:00][REST] API Server listening on port 8883
[2026-08-23 01:00:00][MCP] Server-Sent Events endpoint active on port 8883 at /mcp/sse
[2026-08-23 01:00:00][MQTT] Broker listening on port 1883
[2026-08-23 01:00:00][DB] Connected to the SQLite database.(Tip: By default, the REST API runs on port 8883 and MQTT Broker runs on port 1883. You can change this by setting the REST_PORT and MQTT_PORT environment variables in your terminal).
📡 API Reference & Usage
A. MQTT Protocol (Port 1883)
Use any MQTT Client (like MQTTX or ESP32 PubSubClient) to connect to localhost:1883 without a username or password.
| Action | Topic | Payload Example |
| ------------------ | ------------------------------- | ------------------------------------- |
| Publish Data | channels/{channel_id}/publish | {"temperature": 32, "humidity": 60} |
| Subscribe Data | channels/{channel_id}/publish | Receive real-time JSON payloads |
Note: Replace {channel_id} with any unique identifier for your device (e.g., channels/GREENHOUSE-01/publish). The channel will be created automatically upon the first payload. Any data published to this topic (via MQTT or REST API) will be instantly broadcasted to all active subscribers!
B. REST API (Port 8883)
| Method | Endpoint | Description |
| -------------- | ----------------------------------- | ------------------------------------------------------------------------------- |
| GET / POST | /update | Publish data via HTTP.GET: /update?api_key={channel_id}&temp=32POST JSON: {"api_key": "{channel_id}", "temp": 32} |
| GET | /channels/{channel_id}/feeds.json | Retrieve the history of sensor data for a specific channel. |
C. MCP Server (AI Agents)
LiteSpeak natively implements the Model Context Protocol (MCP) via SSE on the REST API port. Connect your AI Agents (like Claude Desktop) to http://localhost:8883/mcp/sse.
Available AI Tools:
publish_to_channel: Allows AI to control hardware actuators by sending JSON payloads via MQTT.read_channel_history: Allows AI to passively monitor sensor data from the SQLite database.active_channels(Resource): Exposes the list of active IoT channels to the AI.
Example Response for /feeds.json:
{
"channel": {
"id": "{channel_id}"
},
"feeds": [
{
"entry_id": 1,
"created_at": "2026-08-23T01:00:00Z",
"temp": 32
}
]
}🛠️ CLI Utilities
LiteSpeak comes with built-in utility commands:
litespeak help(or-h): Display the CLI help menu and available arguments.litespeak --version(or-v): Check the currently installed version.litespeak db:reset: Cleanly wipe the SQLite database and WAL files for a fresh start (make sure to stop the server first).
🏭 Production Deployment
For continuous 24/7 operation on a VPS or cloud server, you can use PM2 to manage the LiteSpeak process:
npx pm2 start litespeak --name litespeak-serverPM2 will automatically manage the process, restarting it if the server reboots or encounters a fatal crash.
👨💻 Author
Rafie Restu Ramadhani
- GitHub: @rpiirmdhni
📄 License
This project is licensed under the MIT License.
Built with ❤️ for IoT enthusiasts and the Maker community.
