Emacs <-> MITM attack <-> rust-analyzer?

Is there a trivial way to MITM attack the emacs <-> rust-analyzer communication? Mainly, I want to:

(1) log all messages being passed in both directions
(2) eventually modify some messages

[The goal here is to see whether it is possible to easily add features without actually hacking on rust-analyzer itself.]

The communication with rust-analyzer is done with standard input / output as far as I am aware. You could in theory create a wrapper script / program, which calls into rust-analyzer, and forwards between rust-analyzer input/output, and your editor.

The protocol uses json encoded messages, and is specified here: Specification.

Besides that, I really recommend trying to hack on the rust-analyzer itself, or use rust-analyzer as a library. Compared to rustc, the code is relatively straight-forward to work with, and @matklad has put some work into documenting its architecture.