# `NervesMCP.DeviceProbe`
[🔗](https://github.com/nerves-project/nerves_mcp/blob/v0.1.0/lib/nerves_mcp/device_probe.ex#L5)

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.

# `mode`

```elixir
@type mode() :: :nerves | :elixir | :shell | :down | :unknown
```

# `status`

```elixir
@type status() :: %{
  mode: mode(),
  detail: String.t(),
  idle_ms: integer() | nil,
  last_probe_ms_ago: integer() | nil
}
```

# `child_spec`

Returns a specification to start this module under a supervisor.

See `Supervisor`.

# `mode`

```elixir
@spec mode(term()) :: mode()
```

Current detected mode. Fast, non-blocking; falls back to `:unknown`.

# `refresh`

```elixir
@spec refresh(term(), timeout()) :: {mode() | :busy, String.t()}
```

Run a probe synchronously in the caller and update the cached mode.

# `start_link`

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

# `status`

```elixir
@spec status(term()) :: status()
```

Full status map for the device_status tool.

# `touch`

```elixir
@spec touch(term()) :: :ok
```

Record MCP activity so the idle timer does not probe during active use.

---

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