# `HexpmMcp.MCP.StdioLifecycle`
[🔗](https://github.com/joshrotenberg/hexpm-mcp/blob/main/lib/hexpm_mcp/mcp/stdio_lifecycle.ex#L1)

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.

# `child_spec`

Returns a specification to start this module under a supervisor.

See `Supervisor`.

# `start_link`

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

---

*Consult [api-reference.md](api-reference.md) for complete listing*
