HexpmMcp.MCP.StdioLifecycle (hexpm_mcp v0.3.6)

Copy Markdown View Source

Halts the VM cleanly when a stdio client disconnects.

Anubis stops its stdio transport with :normal on EOF, which is the correct reading of "the client went away". But the transport is a permanent child, so the supervisor restarts it, the new transport reads EOF immediately, and the cycle repeats until the restart intensity is exceeded. The supervisor then gives up, the application exits, and because releases are built with start_permanent: true a terminating permanent application takes the node down abnormally: exit status 1 and an erl_crash.dump on disk.

An MCP client reads that as the server having crashed on every ordinary disconnect. This process monitors the transport and turns the first clean stop into System.halt(0), ahead of the restart storm.

Only an orderly stop is treated this way. A transport that dies for any other reason is left to the supervisor, so real failures still restart and still surface.

Summary

Functions

Returns a specification to start this module under a supervisor.

Functions

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

start_link(opts)

@spec start_link(keyword()) :: GenServer.on_start()