Detects what is on the other end of the device connection and decides which MCP tools should be exposed.
When no MCP activity has happened for idle_threshold ms, a small probe is
sent to the device. The probe evaluates the Nerves firmware UUID and classifies
the connection into one of:
:nerves- Elixir evaluated and a firmware UUID came back (confirmed Nerves):elixir- Elixir evaluated but no UUID (Elixir runs, not a Nerves device):shell- bytes came back but no valid Elixir result (some other serial):down- nothing came back at all:unknown- not probed yet / could not determine
The probe is resilient: a device that returns some output but cannot run
Elixir degrades to :shell rather than reporting failure, so the server can
still offer the shell tools.
NervesMCP.Server.server/0 reads mode/1 on every request and lists tools
accordingly. On a mode change we broadcast notifications/tools/list_changed
so connected clients refetch the tool list immediately.
Summary
Functions
Returns a specification to start this module under a supervisor.
Current detected mode. Fast, non-blocking; falls back to :unknown.
Run a probe synchronously in the caller and update the cached mode.
Full status map for the device_status tool.
Record MCP activity so the idle timer does not probe during active use.
Types
Functions
Returns a specification to start this module under a supervisor.
See Supervisor.
Current detected mode. Fast, non-blocking; falls back to :unknown.
Run a probe synchronously in the caller and update the cached mode.
@spec start_link(keyword()) :: GenServer.on_start()
Full status map for the device_status tool.
@spec touch(term()) :: :ok
Record MCP activity so the idle timer does not probe during active use.