Cli
cli
AXM MCP CLI — Lifecycle management for the MCP server.
Subcommands
serve Start the Streamable HTTP server. status Check whether the server is running. stop Send SIGTERM to the running server.
Running axm-mcp with no subcommand preserves backward-compatible
stdio mode.
install(*, port=DEFAULT_PORT, binary=None)
Install the MCP server as a launchd service.
Source code in packages/axm-mcp/src/axm_mcp/cli.py
is_axm_mcp_process(pid)
Return True only if pid's command line identifies an axm-mcp server.
Guards against OS PID reuse: an existence probe (:func:is_process_alive)
cannot tell our server apart from an unrelated process that inherited the
same PID. We inspect the target's command line (no psutil dependency)
and require the axm-mcp marker. Any failure (process vanished, read
error, mismatch) yields False — we never send SIGTERM on an unconfirmed
identity.
/proc/<pid>/cmdline is preferred where it exists (Linux): it yields the
full NUL-separated argv, whereas ps -o command= renders a column the
kernel may truncate for a long argv — an absolute venv path plus arguments
is long enough to lose the trailing marker, which silently turns a live
server into an "unverified" one. ps stays the fallback for platforms
without /proc (macOS).
Source code in packages/axm-mcp/src/axm_mcp/cli.py
is_process_alive(pid)
Check whether a process with pid is running.
main()
read_pid()
Read PID from file, returning None if absent or invalid.
Source code in packages/axm-mcp/src/axm_mcp/cli.py
remove_pid_file()
serve(*, host='127.0.0.1', port=DEFAULT_PORT, shared=None)
Start the MCP server with Streamable HTTP transport.
The PID file is transactional: a second serve refuses to start when a
live axm-mcp server already owns it (avoids clobbering the survivor's PID
with a doomed instance that then fails the bind), and the finally only
removes the file when it still contains our PID — so a failed start does
not delete the legitimate server's PID file.
Source code in packages/axm-mcp/src/axm_mcp/cli.py
status(*, host='127.0.0.1', port=DEFAULT_PORT)
Check whether the MCP server is running.
Source code in packages/axm-mcp/src/axm_mcp/cli.py
stop()
Stop the running MCP server.
Before sending SIGTERM, the target PID's identity is verified against the
axm-mcp command-line marker. If the PID has been reused by an unrelated
process (or vanished), the signal is NOT sent: the stale PID file is
removed and the command exits non-zero.
Source code in packages/axm-mcp/src/axm_mcp/cli.py
uninstall()
write_pid(pid)
Write PID file, creating parent directory if needed.