MoleculerPy REPL
Interactive CLI shell for MoleculerPy microservices framework.
Features
- 🖥️ Interactive Shell — Command-line interface for MoleculerPy brokers
- 📞 Call Actions — Invoke service actions with params
- 📨 Emit Events — Publish events to the cluster
- 🔍 Inspect Cluster — List actions, services, nodes, events
- ⚡ Tab Completion — Autocomplete for actions, events, nodes
- 🎨 Rich Output — Beautiful tables and colors (optional)
- 🔧 Extensible — Add custom commands easily
Quick Start
Installation
cd sources/moleculerpy-repl
pip install -e .
# Optional: rich for better output
pip install rich
Usage with Mock Broker
python3 examples/demo_repl.py
Usage with MoleculerPy
import asyncio
from moleculerpy import Broker
from moleculerpy_repl import REPL
async def main():
broker = Broker("node-1", transporter="nats://localhost:4222")
await broker.start()
# Start REPL
repl = REPL(broker)
await repl.run()
asyncio.run(main())
Commands
| Command | Alias | Description | Example |
|---|---|---|---|
actions |
a |
List available actions | actions |
services |
s |
List registered services | services |
nodes |
n |
List cluster nodes | nodes -d |
events |
ev |
List event subscriptions | events |
info |
i |
System information | info |
call |
c |
Call a service action | call math.add a=5 b=3 |
emit |
e |
Emit an event | emit user.created name=Bob |
broadcast |
b |
Broadcast event to all | broadcast system.shutdown |
help |
— | Show help | help call |
clear |
cls |
Clear screen | clear |
quit |
exit |
Exit REPL | quit |
Parameter Syntax
# Basic parameters → payload
mol $ call math.add a=5 b=3
# Meta parameters (prefix #) → context metadata
mol $ emit user.created name=Bob #userId=123 #source=api
# Options (prefix $) → call options
mol $ call slow.action $timeout=30000 $retries=3
# JSON parameters
mol $ call user.create --json '{"name": "Bob", "age": 30}'
# Load from file
mol $ call user.create --load params.json
# Force string with @ prefix
mol $ call search query=@123 # "123" as string, not int
Example Session
$ python3 examples/demo_repl.py
🚀 MoleculerPy REPL v0.1.0
Node ID: demo-node
Type 'help' for available commands.
demo $ services
Services:
Service Version State Nodes
------------------------------------------------------------
greeter 1 OK 1
math 1 OK 1
user 1 OK 1
demo $ actions
Actions:
Action Nodes State
------------------------------------------------------------
greeter.hello 1 OK
math.add 1 OK
math.multiply 1 OK
user.get 1 OK
user.list 1 OK
demo $ call math.add a=10 b=25
>> Response (0.00ms):
Result: 35
demo $ call user.list
>> Response (0.00ms):
[
{"id": "u1", "name": "John"},
{"id": "u2", "name": "Jane"}
]
demo $ emit user.created name=Charlie #userId=u4
[EVENT] user.created: {'name': 'Charlie'}
Event emitted: user.created
demo $ info
Broker Information:
----------------------------------------
Node ID: demo-node
Namespace: (none)
Version: 0.1.0
Protocol: 4
Transport:
----------------------------------------
Transporter: None
Serializer: JSON
Statistics:
----------------------------------------
Services: 3
Actions: 5
Events: 1
demo $ quit
Goodbye! 👋
Custom Commands
from moleculerpy_repl import REPL, BaseCommand, CommandResult
class HelloCommand(BaseCommand):
name = "hello"
description = "Say hello"
usage = "hello [name]"
aliases = ["hi"]
async def execute(self, broker, args):
name = args.positional[0] if args.positional else "World"
return CommandResult(
success=True,
output=f"Hello, {name}!"
)
repl = REPL(broker, custom_commands=[HelloCommand])
Architecture
moleculerpy-repl/
├── src/moleculerpy_repl/
│ ├── __init__.py # Public API: REPL, BaseCommand, etc.
│ ├── repl.py # Main REPL class (extends cmd.Cmd)
│ ├── parser.py # Argument parser with prefix system
│ ├── output.py # Formatter (uses rich if available)
│ └── commands/
│ ├── base.py # BaseCommand, CommandResult, Registry
│ ├── actions.py # `actions` command
│ ├── services.py # `services` command
│ ├── nodes.py # `nodes` command
│ ├── events.py # `events` command
│ ├── info.py # `info` command
│ ├── call.py # `call` command
│ └── emit.py # `emit`, `broadcast` commands
├── examples/
│ └── demo_repl.py # Demo with mock broker
└── docs/
├── PLAN.md # Implementation status
├── ARCHITECTURE.md
└── COMMANDS.md
Documentation
- Implementation Plan — Status and roadmap
- Architecture — Design decisions
- Command Reference — Full command documentation
Development Status
| Phase | Description | Status |
|---|---|---|
| Phase 1 | Core REPL module | ✅ Complete |
| Phase 2 | Discovery commands | ✅ Complete |
| Phase 3 | Action commands | ✅ Complete |
| Phase 4 | Advanced commands | ⏳ Pending |
| Phase 5 | MoleculerPy integration | ⏳ Pending |
| Phase 6 | DX polish | ✅ Partial |
License
MIT License — see LICENSE for details.
Acknowledgments
Inspired by moleculer-repl for Moleculer.js.
Metadata
Release files for moleculerpy-repl 0.14.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| moleculerpy_repl-0.14.3.tar.gz | 51.0 kB | Without provenance | Details for moleculerpy_repl-0.14.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| moleculerpy_repl-0.14.3-py3-none-any.whl | Python 3 | none | any | Details for moleculerpy_repl-0.14.3-py3-none-any.whl |
Total release size: 94.5 kB
Release files / moleculerpy_repl-0.14.3.tar.gz
| Download URL | moleculerpy_repl-0.14.3.tar.gz |
|---|---|
| Size | 51.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
44ee235b390ffe05f6171bdccbfb6011575cbe8c376aaa94dc900bd18486d8fd
|
|
BLAKE2b-256 checksum How to use checksums |
c777c8816b531c59f003f3261ccb451294e9f10a1be67b5325274265e98dec25
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.7
|
Release files / moleculerpy_repl-0.14.3-py3-none-any.whl
| Download URL | moleculerpy_repl-0.14.3-py3-none-any.whl |
|---|---|
| Size | 43.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a84c48d9afaa48f0897ae4fa50023a302533ebda89c15383abe37f42ef9566a9
|
|
BLAKE2b-256 checksum How to use checksums |
4815d92ab1a6103cc8fa52ac6f4e8eaba0f9ffccfcf8ff55d526646202019a8f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.7
|
Security for moleculerpy-repl 0.14.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.