Skip to main content

Module cli

Module cli 

Source
Expand description

The argv-level entry point every agent’s plugin binary dispatches into.

The plugin binaries (re-ghidra-cc-mcp today; the agy and qwen ports later) own nothing but a main that hands its argv here. Flag parsing, config precedence, log initialization and the serve loop all live in this crate, so three front ends cannot drift into three subtly different config contracts.

product is the invoked binary’s own name. It appears only in the usage banner and error prefixes — never in an env var or a path — so each agent’s diagnostics name the binary the user actually ran.

Functions§

boot_smoke 🔒
Dev-only: boot the worker and drive attach + decompile end to end, logging to stderr. Needs a real Ghidra install and the GHIDRA_MCP_FIXTURE_* vars.
dispatch
Dispatch args (everything after argv[0]) and return the process exit code.
env 🔒
env_or_none 🔒
layer 🔒
The precedence rule itself, with the environment injected so it is testable without mutating the process environment (which races under a parallel test runner).
layered_config
Layer CLI flags over the environment over the agent’s settings file.
mk 🔒
parse_flags 🔒
Parse --key value and --key=value into a map. Non-flag tokens are skipped; unrecognized flags are collected rather than rejected, so they simply match no pick(..) above (forward compatibility).
run_serve 🔒
Layer config (CLI > env > settings file), initialize file logging, and serve. Err(code) carries the exit code; the reason is reported on STDERR, never stdout — stdout is the MCP channel.
usage 🔒
Version + usage, on stderr. Never stdout: an agent that launched this binary as an MCP server is reading stdout as JSON-RPC, and a usage banner there looks like a protocol violation rather than a mistyped command.