Otp_debug_mcp - let an AI agent debug a live BEAM node (MCP server)

AI agents write more and more of our code, and many bugs only show up in the running system. On the BEAM that system can be inspected while it runs: distribution, process introspection, built-in tracing, supervisors that keep their restart history, hot code loading. otp_debug_mcp hands that to an agent such as Claude Code, through purpose-built tools with guardrails rather than a raw shell.

It’s an MCP server, written in Elixir, that connects to a running node as a hidden node. Nothing is installed on the target, and recon is loaded into memory for the session. The tools:

  • diagnose: health checks ranked worst first: message queues, crash loops (including ones that stay just under the restart limit), binary leaks, memory, atoms, schedulers.
  • process_info, supervision_tree, snapshot: drill down, and diff snapshots to tell a real leak from a busy moment.
  • trace_calls: tracing with hard limits on events, duration and call rate. On OTP 27+ it runs in its own trace session.
  • profile: own time, call counts and memory allocated per function.
  • cluster: compares every node to find the odd one out.
  • load_module: hot-loads a fixed .beam onto the node, only after you approve that load in a dialog.

It works with Elixir, Erlang, Gleam and LFE nodes, Mix releases, TLS distribution, Docker containers and Kubernetes pods. Releases bundle their own runtime, and there’s a Docker image.

Example: pointed at a demo node with “payments fail now and then”, the agent found the crash loop’s cause, file and line from one diagnose call.

It isn’t battle-tested yet. It’s been tested against demo nodes, in CI on OTP 26–28, on a second machine, and on a local Kubernetes cluster, but not on real production systems. Try it on staging first, and remember that tool output goes to your AI provider.

I’d really like feedback: what’s missing for your systems, what goes wrong, and what you’d never let an agent do on a node.

1 Like

The hidden-node approach is what makes this practical: nothing installed on the target and recon loaded only for the session are exactly the properties I’d want before letting an agent near a running system. Running tracing in its own trace session on OTP 27+ also addresses my main worry about an agent’s own instrumentation muddying the data it’s reading. The one gap I’d flag is that “not battle-tested on real production” leaves questions about overhead on hot paths and how the guardrails behave under load. Worth running against a staging node first.

1 Like

Update: 0.13.0

A week of work since the announcement (0.6.0 → 0.13.0). Most of it is about systems people run but didn’t write, all read through their own APIs from a hidden node, with nothing loaded on the target but recon, when it isn’t there already.

Products

- rabbitmq: memory and disk alarms (while one is set, every publisher is blocked), queues by messages ready and unacknowledged, and publish, delivery and ack rates from rabbit_core_metrics. Also channels with no prefetch limit, and connections in flow control or blocked.

- emqx: slow consumers (in flight, queued, dropped), client ids kicking each other off, alarms, and rules and actions failing.

- ejabberd: backed-up c2s processes. p1_server keeps the backlog in $internal_queue_len, not message_queue_len. Also offline queues at max_user_offline_messages, and MAM on a disc_only_copies table slowing every delivery.

- riak_core (ring, handoffs, swamped vnodes, riak_dt sets whose actors pile up), mnesia (lock queues sampled through the window, with the holder’s code), yaws, cowboy/ranch, shackle.

- The products in Docker run without epmd: the server dials their fixed distribution port via -erl_epmd_port, and each has its own CI job.

Tuning

- vm_config (in diagnose): schedulers against the container’s CPU quota, with throttled periods from cgroup cpu.stat; busy-waiting (+sbwt) in a quota; memory against the container limit; and limits including ulimit -n. It reads +S/+sbwt from beam’s own command line. The OTP 26 CI target runs with --cpus=1 +S 4:4 to check it.

- call_latency: one gen_server traced alone, with arity and return_to so the state is never copied into a trace message. Per request it gives mailbox wait against handling time. It uses its own trace session on OTP 27+, and the legacy one before that, refusing if someone else is tracing there.

- socket_tuning: every inet socket’s options and stats twice, grouped by owner. It flags Nagle with a message written in pieces (by writes per read), {active, true} floods, senders past high_watermark with send_timeout infinity, and small buffers.

- hot_spots (stack sampling, no tracing) and benchmark.

Tested against OTP 26 to 29 targets and over TLS distribution in CI. There are 35 recorded walkthroughs, where an agent given only the symptom finds the cause, and scripts/blind_eval.py reruns them as a regression suite. Erlang demos: examples/erlang/run.sh mnesia|inventory|tuning|…, plus examples/rabbitmq, emqx, ejabberd, sockets and container in Docker.

The usual caveat: it’s been tried on demos and in CI, not yet on a real production system. If you run one of these products and give it a try, reports of what it got wrong are the most useful thing you could send.

GitHub - ayarodionov/otp_debug_mcp: MCP server for AI-driven debugging of live Erlang/Elixir OTP nodes: hidden-node attach, recon-based diagnostic battery, safe tracing, snapshot/diff · GitHub

1 Like