lustro CLI
A command-line client for the Lustro
Android debug server. It talks only to the HTTP wire protocol under
/api/v1/ — the public, SemVer-governed contract — so it installs with zero
third-party runtime dependencies (Python standard library only) and works
without a source checkout.
Target: Python 3.9+.
Install
Each Lustro release publishes the CLI to PyPI as lustro-cli, with the version
of the library. Install it with uv or
pipx, which keep it apart from other Python packages.
uv also installs a Python when the computer has none.
uv tool install lustro-cli # or: pipx install lustro-cli, or: pip install lustro-cli
lustro open
uvx lustro-cli net list # runs the CLI without an install
The package installs one command under two names, lustro and lustro-cli, so
that uvx lustro-cli finds it by the package's name.
lustroon PyPI is a different project. It also installs alustrocommand, sopip install lustroanduvx lustroinstall that project, not this CLI.
To get the CLI of main before a release, install it from GitHub, or from a
checkout:
uv tool install "git+https://github.com/Twinsen81/Lustro#subdirectory=lustro-cli" # pipx takes the same URL
uv tool install ./lustro-cli # from a checkout; or: pipx install ./lustro-cli
pip install -e 'lustro-cli[test]' # to work on the CLI: adds pytest and jsonschema for the contract tests
The wheel bundles the wire-protocol schemas, the Network OpenAPI document, and
the golden fixtures (lustro_cli/wire/).
lustro --version prints the version of the CLI, the version of the wire
protocol that it implements, and the revision of the CLI, such as lustro 0.1.0 (protocol 1.17, revision 1). Each protocol version adds routes or fields, so two
builds of the CLI with the same version can differ in what they do: compare the
protocol. When an app's protocol, protocolVersion in GET /api/v1/_meta, is
newer, lustro ready and lustro meta print a warning on stderr: update the CLI.
The revision is a whole number that each change to the CLI on main increases
by one. The version changes only at a release, and the protocol only with the
wire protocol, so a fix to the CLI alone changes only the revision. A script that
needs a fix requires the revision of that fix or a later one, such as "revision 1
or later". The CHANGELOG names the revision of each change to
the CLI:
revision=$(lustro --version | sed -n 's/.*revision \([0-9][0-9]*\).*/\1/p')
if [ "${revision:-0}" -lt 1 ]; then
echo "lustro is older than revision 1: install it again" >&2
exit 1
fi
A CLI from before the revision prints no revision: count it as 0. lustro --version --json, with the options in either order, prints the three values as
a JSON object, such as {"version":"0.1.0","protocol":"1.17","revision":1}; a
CLI from before the revision prints the line of text there too. lustro mcp
reports the revision in its server info, next to the version.
An app on an older protocol
An app can stay on an older Lustro release, and so on an older protocol, and most
commands work with it. But an older app ignores a request field or a query
parameter that its protocol does not have, and answers 200, so a command with
such an option would succeed with a wrong result: a mock rule that answers instead
of failing, or a text search in place of a regex. So when a command uses one of
these options, the CLI first reads protocolVersion from _meta, and refuses the
command when the app is older, before it sends anything, with exit status 1:
| Option | Command | Protocol |
|---|---|---|
--sender |
send |
1.7 |
--regex |
net list, net poll, net wait, net ws events |
1.8 |
--failure |
mock add |
1.12 |
failure in a rule of the file |
mock sync |
1.12 |
error: protocol_too_old: --failure needs wire protocol 1.12, and the app uses 1.11, which ignores it
hint: update Lustro in the app, or leave out --failure
The MCP tools refuse regex of list_requests and failure of add_mock_rule
in the same way. A command without such an option sends no extra request. A
command for a route that an older app does not have, such as net ws list before
1.3, gets a 404 from the app. lustro api does not know the route, so it
refuses nothing; see Any route.
The MCP tool read_logs refuses from_ms and to_ms in the same way when the
app's Logs tab is older than 1.1, the version in tabs[].version of _meta,
because a Logs tab 1.0 returns the whole log. An app that gives the tab its
protocolVersion there is from before the tabs had versions of their own, and
its Logs tab is 1.0. mock sync rejects two rules with
the same id itself, with exit status 2, because an app before protocol 1.11
keeps the first of them and loses the other. Some values that a newer app
rejects, an older app accepts without an error: before 1.16, mock toggle and
mock delete answer 200 for an id that no rule has, and change nothing, and
net throttle takes a delay over 600000 ms and sets 0 for a negative one. Check
the result with mock list or net state.
Endpoint and token discovery
The CLI resolves the endpoint+token in this order (first hit wins, per field):
- Explicit
--token/--host/--port. - The
LUSTRO_TOKENenvironment variable (token only). - With
--package <id>, the app's prefs:adb [-s <serial>] shell run-as <id> cat shared_prefs/lustro_debug.xmlon debuggable builds gives the token, and the host and port of the app's last bind. They are the named app's own file. Each process of the app writes its token when it makes it, and each bind writes the host and port, so while the app is in the foreground and its server listens, they are the values of its current process. Before the bind, or while the app is in the background, they are those of its last bind. This read takes about 0.2 s. The dump of the log in step 4 takes longer as the device keeps more log, and on a physical device with full log buffers it can take 10 s. When the prefs give the token, the host, and the port, the CLI runs nologcat, also with--tokenorLUSTRO_TOKEN. Whenrun-asfails, as for a build that is not debuggable, or the prefs do not have all three, as before the app writes them, the CLI goes to step 4 for the rest. When the app does not run, its prefs keep the values of its last process: the connection then fails, and the CLI prints the cause. - The
LustroTokenlogcat ready line:adb [-s <serial>] logcat -d -v threadtime -s LustroToken, which shows the process ID of each line, is parsed for the most recentLustro ready endpoint=http://<host>:<port> token=<token>. Without--package, this is the first source for host/port/token, including a fallback port, and the last line counts, whatever app logged it. With--package <id>, only the lines of that app's current process count: the CLI gets its process IDs withadb shell pidof <id>, with the uid of each, and takes the last line of these processes. The line of another app, such as another build of the same app, and the line of an earlier process of the app are not used. That line can name a port that the app no longer uses, and a token that is no longer valid: a server that listens beyond loopback gets a new token in each process. If this gives no token either, the CLI prints the cause. - (best effort, without
--package) therun-asread of step 3, of the app in the foreground, because Lustro listens only while its app is in the foreground. This finds the app on a device that drops Info logs, such as one withadb shell getprop log.tagset toE, where the ready line never reaches logcat. It also replaces a ready line whose app does not listen on the line's port, or whose process has ended, when the app in the foreground listens on the port of its prefs.
The token goes only to its app's server. Any app on the device can log a line with the tag
LustroToken, and bind the app's port while the app is in the background. So the CLI sends a
token that it found in steps 3 to 5 only to a server whose listening socket has the uid of the
app that owns the token: for the prefs, the uid that run-as runs with (the cat that reads them
also reads its own /proc/self/status), and for a log line, the uid of the process that logged it
(stat -c %u /proc/<pid>). The process name is not
enough: pidof finds processes by name, and an app can give its process another app's name with
android:process. The CLI reads the uids that listen on the port of the device in
/proc/net/tcp and /proc/net/tcp6. With --package, the adb call of step 3 reads them, so the
check costs no extra adb call; without it, one adb call reads the uid of the line's process and
the sockets. A command checks before its first request, and again before a later request when
one second has passed or a connection failed, so that net poll and net wait check while the
app comes and goes. When another uid listens on the port, the CLI sends no request: it names that
app, from pm list packages -U, or before API 26 from dumpsys package packages, and exits 6.
When nothing listens, it sends nothing either, and prints the cause from adb, as for a connection
that fails. A token from the prefs goes to a host that is not loopback only when the prefs name
that host and port: a line of another app can name any host. A token from --token or
LUSTRO_TOKEN, and a port from --port, which is a local port, are your choice and get no
check. A host from --host that is not loopback gets none either.
If none of these determine the token, the CLI looks for the cause with adb, and
prints it and exits with its code (see Exit codes). It checks, in
this order: that adb finds one device that it can use (adb get-state), that the
app of --package is installed (adb shell pm path <pkg>), that its build
contains the Lustro runtime, that it runs (pidof), and that it is in the
foreground. For the runtime, it reads the entry names in the central directory of
the installed base.apk and looks for an entry under assets/lustro/. It reads
the end of the file with tail -c through adb exec-out: 64 KB, and a second
read when the central directory is larger. It does not use unzip, which API 28
emulator images do not have, or grep, which does not find the names on API 30
to 33. Every build with the Lustro runtime has such entries. A build without them
is a build with the -noop artifacts, which has no server, or a build from
before the app added Lustro: install a debug build that uses the Lustro
artifacts. Without --package, the CLI checks only the runtime of the app in the
foreground, which can be another app, such as the launcher when your app is not
running. Pass --package in a script, so that the CLI checks your app. A
connection that fails gets the same checks, because a ready line or the prefs from an
earlier start of the app give a token and a port that no longer answer. A command with
--port gets them only with --device or --package, which say that the app is
on a device, for example behind a forward that the script made itself. Without
them, the server of --port can be on this computer, and adb finds nothing about it.
A token from the ready line can be stale: when the app was installed again and the device
dropped the new line, the last line in the log is from the earlier install. A token from the
prefs can be stale too, when a new process of an app that listens beyond loopback answers
before it writes its new token. When the server answers 401 to a token that discovery found,
the CLI reads the prefs of the app (of --package, or in the foreground) and sends the request
once more with the token there, when that app's uid listens on the port (see above). When that
gets 401 too, or the CLI does not send it, the CLI looks for the cause with adb, as for a
connection that fails, and prints it with its exit code. In every other case, the CLI prints the
401 with exit 1. Right after an app starts, the server of another app with Lustro on the same
port can still listen there: the CLI does not send it the token, names that app, and exits 6.
That server closes when its app goes to the background, and the app's own server then binds the
port; lustro ready --package waits for it. Give each app with Lustro on one device its own
serverPort to prevent this. Without --package, lustro open compares the token of the line
with the one in the prefs of the app in the foreground before it prints the URL, because the
browser gets no second try.
The port that discovery finds is the app's port on the device. The CLI reaches
it through an adb forward, and the local port of the forward can be a
different number. So when the host is a loopback address and --port is not
given, the CLI reads adb forward --list and connects to the local port of the
first forward to the app's port on the selected device: --device, else
ANDROID_SERIAL, else the only device. Without such a forward, it makes one
on a local port that adb chooses (see The local port). When
adb can't make it, the command prints the device's cause and exits with its
code: 2 for more than one device with none selected, 3 for no device. Without
such a cause, it prints connection_failed and exits 6. It does not connect to
the same
port number on the computer instead: with several devices, that port can be a
forward to the app on another device. Without adb installed, there is no device
to forward to, and a command connects to that port on the computer. A command
with --port connects to that port and looks for no forward, for example when
the server runs on the computer. For lustro open, --port is the app's port,
which it forwards to.
Global flags
--host (default 127.0.0.1), --port (default 8080), --token (else
$LUSTRO_TOKEN), --device <serial> (adb -s), --package <id> (run-as
discovery), --json (JSON output). They go before or after the command:
lustro --json net list and lustro net list --json are the same.
Commands
| Command | Route |
|---|---|
lustro open [--local-port N] |
discovery + adb forward + print/open …/#lustro_token=<token>; exits 1 when adb forward fails |
lustro ready [--timeout SECONDS] |
GET /api/v1/_meta until the server answers, then prints the endpoint; at the timeout (30 s by default), prints the cause and exits with its code, and with --package exits 4 or 5 at once (see Wait until the app is ready) |
lustro meta |
GET /api/v1/_meta |
lustro schema [tabId] |
GET /api/v1/_schema or /api/v1/<tab>/_schema |
lustro net list |
GET network/transactions (one poll): the newest 50 transactions, newest first |
lustro net state |
the capture state from GET network/transactions: pause, overwrite mode, throttle, capture filter, and the number of enabled mock rules |
lustro net poll |
cursor loop; prints new transactions, and prints one again when it finishes |
lustro net wait [-- COMMAND] |
cursor loop; runs COMMAND, prints the first matching request that finishes, and exits |
lustro net get <id> |
GET network/transactions/<id>, with each body cut at 2 KB |
lustro net body <id> [request|response] [-o FILE] |
GET network/transactions/<id>/body/<direction>: saves a body as it is stored, the response by default; stdout without -o |
lustro net export --har FILE [--ids ID ...] |
GET network/transactions/_/export: saves the transactions, or only those in --ids, as a HAR file; stdout for --har - |
lustro net ws list |
GET network/websockets: the WebSocket connections, newest first |
lustro net ws get <id> |
GET network/websockets/<id>: one connection, with the headers of its handshake |
lustro net ws events <id> [--follow] |
GET network/websockets/<id>/events: the last 50 messages and lifecycle events, oldest first; with --follow, each new one as it comes |
lustro net ws payload <id> <seq> [-o FILE] |
GET network/websockets/<id>/events/<seq>/payload: saves a message's payload as it is stored; stdout without -o |
lustro net clear |
POST network/clear |
lustro net pause |
POST network/pause |
lustro net overwrite |
POST network/overwrite-mode |
lustro net throttle <ms> |
POST network/throttle |
lustro mock list |
GET network/rules |
lustro mock add --url-pattern … [--failure NAME] |
POST network/rules |
lustro mock delete <id> |
POST network/rules/delete |
lustro mock toggle <id> |
POST network/rules/toggle |
lustro mock sync <file.json> |
POST network/rules/_/sync (atomic): a JSON array of rules, or the output of lustro mock list --json |
lustro senders |
GET network/senders: the clients that send can use, the default first |
lustro send --url … [--sender NAME] |
POST network/send (synchronous), through the first sender or the one named |
lustro screen tree [--unmerged] [--settle MS] [--all] |
GET screen/tree: each window of the app, and its nodes on the screen with a text, a tag, a role, an action, or a state, one line each (see The screen) |
lustro api METHOD PATH [--param K=V] [--body JSON | --input FILE] |
any route: prints the response body (see Any route) |
lustro mcp |
an MCP server on stdin and stdout, whose tools call the routes above (see The MCP server) |
A test that changes the mock rules can save them first and restore them after:
lustro mock list --json > rules.json # {"items": [...]}
lustro mock add --url-pattern /v1/orders --status 500
# ... the test ...
lustro mock sync rules.json # the rules as they were
Wait until the app is ready
A script that starts the app waits for its server with lustro ready, before
its first command:
adb shell am start -W -n com.example.app/.MainActivity
lustro ready --package com.example.app --timeout 30 # prints http://127.0.0.1:8080
Each try runs discovery again and sends GET /api/v1/_meta, once a second,
because the app logs its ready line and writes its prefs only when its server starts, and
those of an earlier start name a token and a port that may not answer. When the server
answers, ready prints the endpoint that the CLI reaches it at and exits 0;
--json prints {"endpoint", "libraryVersion", "protocolVersion"}, without the
token. When the time is over, it prints the cause and exits with its code: no
device, an app that is not installed, a build without the Lustro runtime, an app
that is not running or not in the foreground, or a port that does not answer. It
makes the checks of the cause at the end. With --package, it also makes them
once after the first try that fails (while a device starts, after the first try
on which adb reaches it and its package manager answers), and stops at once
with exit 4 for an app
that is not installed, or exit 5 for a build without the Lustro runtime: the
installed APK does not change while ready waits. For every other cause, such
as an app that is not running yet, it waits. So an adb install that runs at
the same time as ready --package can end it at once with exit 4: install the
app before ready. Without --package, the checks run only at the end,
because the app in the foreground changes while the app starts, and it can be
the launcher. An error response that a new try
can't change, such as a 401 for a --token that is not the app's, ends the
wait at once with exit 1; ready tries again after a 5xx or a 429, and after
a 401 for a token that discovery found, which the next try reads again. While
another app's uid listens on the app's port, the CLI sends it no token, and ready
waits; when that lasts until the timeout, ready names that app and exits 6.
A 404 for GET /api/v1/_meta is not from Lustro, which always has that route.
It comes from another server on the port, such as the debug server of another
app, on the port that the app's prefs keep from its last start while the app is
stopped. ready waits, as for a port that does not answer. At the timeout, it
prints the cause that adb finds and says that another server answers on the
port, and exits with the code of the cause, or 6.
A script that needs the token, for the console URL or a curl call, gets it from
lustro open --print-only --json, which prints url, token, host, and
port and opens no browser. Like lustro open, it forwards the port; add
--no-forward when the script forwards it itself:
lustro ready --package com.example.app
TOKEN=$(lustro --package com.example.app open --print-only --json | jq -r .token)
Exit codes
Each cause has its own exit code, so that a script can act on it without reading the message:
| Code | Cause | What to do |
|---|---|---|
| 0 | The command did its work. | |
| 1 | The app answered with an error, such as 404 not_found, or the command did not get what it waited for: net wait at its timeout, and open when adb forward fails. |
Read the error on stderr. |
| 2 | The command can't run as given: a bad flag or input, an id that more than one item starts with, a search that the app rejects, or more than one device with none selected. | Change the command, or pass --device. |
| 3 | No device: adb is not installed, or it finds no device, or the device is offline or not authorized. | Connect a device, or start an emulator. |
| 4 | The app of --package is not installed. |
Install a debug build that uses the Lustro artifacts. |
| 5 | The installed build of --package does not contain the Lustro runtime: a build with the -noop artifacts, or one from before the app added Lustro. |
Install a debug build that uses the Lustro artifacts. This replaces the installed build. |
| 6 | The app can't be reached: it is not running or not in the foreground, it logged no ready line, its port does not answer, or another app holds its port, so the CLI did not send the app's token there. | Start the app, and keep it in the foreground. For another app on the port, run lustro ready --package, which waits for the app's own server, and give each app its own serverPort. |
Without --package, an app in the foreground without the runtime exits 6, not 5:
that app can be the launcher, or another app than yours. Every command that
finds the app exits with codes 3 to 6, and the error text of an MCP tool names
the same cause.
Live use of
lustro openrequires a running app: the server only listens while the app is foregrounded, and discovery reads theLustroTokenlog line viaadb. With no device, discovery falls back to flags /LUSTRO_TOKEN.
The local port
lustro open forwards a local port to the app's port on the device, and prints
the console URL with the local port. It uses the same port number, 8080 by
default: a forward on it, or else a new one. So a person gets the same URL each
time, also after an earlier command, such as lustro ready, made a forward on
a port that adb chose. That matters because the console keeps its state in the
browser for each origin, and the port is part of the origin. When another
process, such as a local development server or a forward to another device,
holds that port on the computer, open uses an existing forward to the app, or
else a free local port that adb chooses. To choose the local port yourself:
lustro open --local-port 18080 # forward local port 18080 to the app's port
lustro open --local-port 0 # adb chooses a free local port
lustro net list # connects through the forward, without --port
open --local-port N exits 1 when port N is taken. The other commands find
the forward in adb forward --list, as
discovery describes, so they need no --port.
This also applies to a forward that you make yourself, such as
adb forward tcp:18080 tcp:8080. Without a forward, a command makes one on a
local port that adb chooses, so it needs no open first. It does not take the
app's port number: the forward stays until adb restarts, and on local port 8080
it would keep a tool that starts later, such as a proxy or a development server,
from binding 8080. Only open prefers the same port number. The CLI runs
adb forward --no-rebind, so it does not take over a local port that a forward
of another device holds. --no-forward skips the forward, and the URL then
uses --local-port N, else the app's port.
The commands connect to the forward directly, whatever http_proxy,
HTTPS_PROXY, or the system's proxy settings say: the server is an adb forward
on this computer, which a proxy cannot reach, and the token must not leave it.
Several devices
The app on each device or emulator listens on port 8080 of that device, but
the computer has only one local port 8080. Select the device with
--device SERIAL or ANDROID_SERIAL for each command. The CLI then connects
through a forward to that device, on whatever local port the forward has, and
not through a forward to another device. Several agents or scripts can each
drive the app on their own device at the same time.
Output
The output is small by default, because an agent reads all of it.
- Rows. Each
net list,net poll, andnet waitrow starts with a short transaction id, then the start time, the method, the status (...in flight,ERRfor a failed request), the duration, and the URL. The short id is the first 8 characters of the id, or more characters when two listed ids start with the same 8. JSON output has the full id. - Ids.
net get,net body, andnet export --idstake a full id, or the start of one, such as the short id of a row. They find the id that starts with it in the transaction list, which is one more request. When more than one id starts with it, they print the matches and exit 2. When no id starts with it, they exit 1. The wire routes take only the full id. - The newest 50.
net listprints the newest 50 transactions, and says on stderr how many it left out.--last Nprints the newest N, and--allprints every one. - Filters.
net list,net poll, andnet waittake--url TEXT(the URL contains it, ignoring case),--method,--status(a code such as404, or a class such as5xx), and--errors(status 400 or higher, or a failed request). They combine with each other and with--search TEXT, which the app runs over the URL, the method, the headers, and the bodies, ignoring case.--regexmakes each word of the text a Java regular expression: all words must match, each in any field, and-wordleaves out. A regex that doesn't compile exits 2 with the reason.--urlis always plain text. - JSON Lines. With
--json, these commands print one compact JSON object per transaction, soheadandjqcan cut the output.--fields id,statusCode,urlkeeps only those keys, and implies--json. Other commands print one JSON document: compact when stdout is not a terminal, and indented when it is. - Bodies.
net getcuts each body at 2 KB and ends it with a marker such as[... 18251 more bytes: lustro net body <id> response].--max-body BYTESsets the cut,--no-bodyleaves the bodies out, and--fullprints them whole.net bodyprints one body as it is stored. - Updates.
net pollprints a transaction again, marked[update], when it was in flight and finishes or fails. With--json, the later line for an id replaces the earlier one. - WebSockets.
net ws listprints a row for each connection: a short id, the start time, the state (open,closed 1000,failed 403,canceled), the counts of sent and received messages, and the URL.net ws eventsprints the last 50 events of one connection, oldest first;--last Nand--allset how many. A message row has->for sent or<-for received, the type, the size, and the start of the payload; a lifecycle row has--. A sent message means that OkHttp queued it, which does not show that the server received it, and[not sent]marks one thatsend()refused. A long text ends with a marker such as[... 299961 more bytes: lustro net ws payload 3d2a7f10 5], andnet ws payloadprints a payload as it is stored.--sent,--received, and--search TEXT(with--regex, a regular expression) select events on the server.--followthen prints each new event as it comes, until Ctrl-C or until the app clears the connection.--jsonprints JSON Lines for both commands, and--fieldskeeps only the keys you name. A connection id can be its start, as for a transaction.
net wait polls until a matching request finishes, prints it, and exits 0. It
exits 1 after --timeout seconds (30 by default). It ignores the requests that
finished before it started, and a mocked request finishes in a few
milliseconds, so give the action that sends the request after --. net wait
runs it after its first poll:
lustro net wait --url /v1/orders --errors -- adb shell input tap 540 1200
The screen
lustro screen tree reads the Screen tab, when the app registers it: each window of the app,
the activity first and each dialog and popup after it, and in each the nodes on the screen that
have a text, a tag, a role, an action, or a state. A line has the node's id, its role or class,
its text, #tag, its states and actions, and its visible bounds in uiautomator's format:
window 0 activity com.example/com.example.MainActivity no-focus [0,0][1080,2400]
c5.15 Button "Save" #save click [53,1585][985,1667]
window 1 dialog com.example/com.example.MainActivity focus [120,963][960,1510]
c13.267 Button "OK" #dialog-ok click [745,1332][897,1437]
--all prints every node, also the containers and the nodes that are not on the screen.
--unmerged reads the unmerged Compose semantics tree, --settle MS waits until two reads in a
row are the same, for up to MS milliseconds, and --json prints the whole response. Each call
looks up the token and the port again, so a script that reads the screen often sends the GET
itself (see docs/AGENTS.md).
Any route
lustro api sends one request to any route, with the token and the port that
the other commands find, and prints the response body: JSON as JSON (compact
when stdout is not a terminal), any other body as it is. Use it for a tab that
has no commands of its own; lustro schema <tabId> prints the tab's routes.
lustro api GET network/transactions --param search=orders # PATH without / is under /api/v1/
lustro api GET /api/v1/network/transactions/<id>
lustro api POST network/throttle --body '{"delayMs": 2000}'
lustro api POST network/rules/_/sync --input rules.json # --input - reads stdin
--param KEY=VALUE adds a query parameter, and can repeat a key. A route ignores a
query parameter that it does not know, so the app names each one that the tab's
OpenAPI document does not declare for the route in a Lustro-Warning response
header, and every command prints it on stderr, once, such as
warning: unknown query parameter "uniqueName". An app older than protocol
1.15 sends no such header, so for a request with query parameters to that app,
lustro api prints a note on stderr that says so; lustro schema <tabId>
lists the parameters of each route. An error
response prints the error from its envelope on stderr, such as
error: 404 not_found: ..., and exits 1; nothing goes to stdout. A search
that the app rejects (a 400 with field: "search") exits 2, as a bad flag
does. See Exit codes for the others.
The MCP server
lustro mcp is a Model Context Protocol server on stdin and
stdout, for an agent that can only call MCP tools, such as Claude Desktop. An agent that can run
shell commands should run the commands above: the client puts the server's tools into the
agent's context in every session, and a command costs context only when the agent runs it.
The agent's client starts the server when a session starts, and stops it when the session ends. Add it to the client's MCP config:
{
"mcpServers": {
"lustro": {
"command": "lustro",
"args": ["mcp"]
}
}
}
With a coding agent
has the config for Claude Desktop, Claude Code, Cursor, VS Code, Codex, and Gemini CLI. A desktop
app starts the server with a short PATH: give command the full path that which lustro
prints. When adb is not on the PATH, the server looks for it in $ANDROID_HOME/platform-tools,
then in the default place of the Android SDK.
The tools: list_requests, get_request, list_mock_rules, add_mock_rule,
delete_mock_rule, set_throttle, read_logs, call_api, which reaches any route as
lustro api does, and get_schema, which returns the tabs or a tab's OpenAPI document. Each says
in its annotations and its description whether it changes the app.
docs/AGENTS.md lists the route of
each.
Each tool call finds the app as a command does, so the global flags apply to every call:
lustro mcp --device SERIAL selects the device. The server implements JSON-RPC 2.0 with the
standard library, one message per line, and serves the protocol versions from 2024-11-05 to
2026-07-28. Only protocol messages go to stdout; its own messages go to stderr. A warning from
the app, such as warning: unknown query parameter "uniqueName" for a call_api with a parameter
that the route does not declare, is a text block of its own after the output of the tool, and so is
the note for a call_api with query parameters to an app older than protocol 1.15. A tool argument
that the app's protocol is too old for is a tool error, as for a command (see
An app on an older protocol).
Contract tests
cd lustro-cli
pytest
The tests validate every golden fixture against its JSON Schema / OpenAPI
component, exercise the cursor-polling state machine, the error-envelope parser,
the LustroToken log-line parser, the output of each command, the MCP server's
messages and the route of each tool, and a client smoke test against a local
http.server.
Metadata
Release files for lustro-cli 0.1.0
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 |
|---|---|---|---|---|
| lustro_cli-0.1.0.tar.gz | 212.9 kB | With provenance | Details for lustro_cli-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| lustro_cli-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for lustro_cli-0.1.0-py3-none-any.whl |
Total release size: 364.6 kB
Release files / lustro_cli-0.1.0.tar.gz
| Download URL | lustro_cli-0.1.0.tar.gz |
|---|---|
| Size | 212.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ca3bcef2b64eb21e403e6e899bb97ef21d6dcd69248ca2d91b468249c1b70c5a
|
|
BLAKE2b-256 checksum How to use checksums |
32369ad142129fd4e7c31fd8783b8b05fb1ff7ca1056779df04d0733a8309607
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 24, 2026.
Transparency logRelease files / lustro_cli-0.1.0-py3-none-any.whl
| Download URL | lustro_cli-0.1.0-py3-none-any.whl |
|---|---|
| Size | 151.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
44ea89e2c7be683bdc52da87765fb311deb91c297957ebd37323bac193b487d5
|
|
BLAKE2b-256 checksum How to use checksums |
50c087cc77b6e28dd182fe2b4eab27394839cce03ebf6199edb38387a3cfd1cc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 24, 2026.
Transparency logSecurity for lustro-cli 0.1.0
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.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for lustro_cli-0.1.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 24, 2026.
Transparency logA 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.