A lightweight, IoT-focused service for managing named registers with dynamic values and automatic lifecycle management.
A register is a named container that holds a current value, optional metadata, and a time-to-live (TTL). Think of it like a variable in memory that automatically expires if not refreshed. Each register has:
- Name - Unique identifier (e.g., "living-room-temperature")
- Value - Current data (any JSON type: number, string, object, array)
- Metadata - Optional key-value pairs with additional information
- TTL - How long the register stays valid without refresh
Registry provides a simplified Provider/Consumer model where:
- Providers publish registers and keep them alive by refreshing before TTL expires
- Consumers read register values and can request changes
- Automatic cleanup removes expired registers when TTL elapses
βββββββββββββββ βββββββββββββββ
β Provider β β Consumer β
β (Sensor) β β (Controller)β
ββββββββ¬βββββββ ββββββββ¬βββββββ
β β
β PUT /provider β GET /consumer
β (set value) β (read value)
β β
ββββββββββββ ββββββββββββββ
β β
v v
βββββββββββββββββββββββ
β Registry Server β
β β
β - In-memory store β
β - TTL management β
β - Change requests β
βββββββββββββββββββββββ
^ β
ββββββββββββ ββββββββββββββ
β β
β GET /provider β PUT /consumer
β (poll for changes) β (request change)
β β
ββββββββ΄βββββββ ββββββββ΄βββββββ
β Provider β β Consumer β
βββββββββββββββ βββββββββββββββ
go install github.com/burgrp/reg@latestOr build from source:
git clone https://github.com/burgrp/reg.git
cd reg
go build -o reg# Start server on default port (8080)
./reg serve
# Start server on custom port
./reg serve --rest :9000# Set environment variable
export REGISTRY=http://localhost:8080
# Provide a temperature register with initial value
./reg provide temperature 22.5
# Provide with metadata
./reg provide temperature 22.5 '{"unit":"celsius","location":"room1"}'
# Provide with custom TTL (default is 5 seconds)
./reg provide temperature 22.5 '{"unit":"celsius"}' --ttl 10s# Read current value
./reg get temperature
# List all registers
./reg list
# Interactive browsing (TUI)
./reg browse# Start MCP stdio server for AI assistant integration
export REGISTRY=http://localhost:8080
./reg mcp
# The MCP server exposes tools for AI assistants:
# - get_register: Get register value and metadata
# - list_registers: List all registers
# - request_change: Request value change (consumer operation)Use with MCP clients like Claude Desktop, Cline, or other MCP-compatible tools.
curl -X PUT http://localhost:8080/provider \
-H "Content-Type: application/json" \
-d '{
"registers": {
"temperature": {
"value": 22.5,
"metadata": {"unit": "celsius"},
"ttl": "10s"
}
}
}'curl http://localhost:8080/consumer?name=temperaturecurl -X PUT http://localhost:8080/consumer \
-H "Content-Type: application/json" \
-d '{
"registers": {
"temperature": {
"value": 25.0
}
}
}'- Architecture Overview - System design and components
- Lifecycle Management - How registers are created, updated, and expired
- REST API - Complete HTTP API reference
- Long Polling - Real-time updates with long polling
- Go Client Library - Using the Go client library
- JavaScript Client - JavaScript/Node.js client library
- Node-RED Library - Node-RED nodes for registry flows
- Client Examples - Code examples for common use cases
- Building and Testing - Development guide
- Contributing - How to contribute
- Protocol-agnostic core - Clean separation between business logic and transport
- REST API - Simple HTTP interface with JSON
- MCP Server - Model Context Protocol stdio server for AI assistant integration
- Long polling - Efficient real-time updates without WebSockets
- Automatic TTL management - Registers expire automatically if not refreshed
- Change requests - Consumers can request value changes from providers
- Batched operations - Client library batches multiple subscriptions efficiently
- Graceful shutdown - Clean shutdown with signal handling
- No dependencies - Minimal external dependencies, easy to deploy
- IoT device management - Sensors publish values, controllers consume and request changes
- Configuration management - Dynamic configuration with TTL-based expiration
- Distributed state - Lightweight state sharing between services
- Command and control - Send commands to devices via change requests
MIT License - see LICENSE file for details
Run ./reg version to see the current version.