otp_debug_mcp - let an AI agent debug your live BEAM nodes, safely

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.

3 Likes

Update: 0.13.0, and what changed since the announcement

Thanks to everyone who looked at this last week. Here’s what has landed since 0.6.0, the parts most relevant to Elixir apps first:

Phoenix and LiveView (phoenix)

- LiveView processes by view: memory, and which assigns hold it, read at both ends of a window. A list that gains an item per PubSub message shows as “assign orders grew 101 items in 10 s, in every open page”. Process memory alone misses it, because heaps grow in steps.

- Slow handle_events from Phoenix’s telemetry: a LiveView handles one message at a time, so a 400 ms event blocks that page’s PubSub messages too.

- Routes that an earlier route makes unreachable, channels by module, and PubSub topics by subscriber count.

The rest of the stack

- bandit: Thousand Island’s connection limit, acceptors waiting for room, and refused connections.

- postgrex: DBConnection pools (Ecto repos included). It shows who holds each checked-out connection and where in their code, the callers waiting, and, with server: true, pg_stat_activity lock waits matched to the holder.

- telemetry_handlers: handlers piling up (attached per request, never detached), handlers detached after raising, and each one’s cost per event.

- call_latency: for one GenServer, each request’s time waiting in the mailbox against its handling time. “Callers wait 300 ms behind a report call while the mailbox never looks long” is the case it’s for.

- hot_spots (a sampling profiler) and benchmark (compare a rewrite, loaded under another name, against the original, on the node).

Production setups

- vm_config, now the first thing diagnose runs. It compares schedulers against the container’s CPU quota, with how often the kernel throttles it from cgroup cpu.stat. It also compares memory against the container limit and lists every limit in use. A vm.args with +S 16 on a 2-CPU pod is a common way to get latency spikes without high CPU.

- socket_tuning: Nagle with messages written in pieces (40 ms per request on Linux), {active, true} flooding a mailbox, and sends blocked with send_timeout infinity.

How it’s tested. Each tool has a demo with a planted bug (examples/elixir/run.sh live, postgrex, telemetry…), and docs/walkthroughs.md has 35 recorded sessions in which Claude, given only the symptom and these tools, finds the cause. scripts/blind_eval.py reruns them as a regression suite.

Install: the README has release tarballs for macOS arm64 and Linux x86_64/arm64, a Docker image, and claude mcp add. If you point it at a real app, I’d like to hear where it was wrong or missing something. That’s the feedback I can’t get from demos.

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