Undo × MCP: Time Traveling With Your AI Code Assistant

Undo × MCP: Time Traveling With Your AI Code Assistant

Author: Mark Williamson, CTO at Undo

Why your AI code assistant needs a time machine

AI code assistants based on LLMs (Large Language Models),  such as Claude Code, OpenAI Codex and GitHub Copilot, are popping up everywhere today and enabling us to write code faster than ever. They can also help out by analyzing source code, logs and output from other tools to help find bugs.

But, clever though they are, there is critical information they lack:

  • They can’t know the dynamic behavior of the software just by looking at the source code (they don’t have access to the inputs, variable values, etc).
  • Logs capture some dynamic behavior but only if you have them in the right place. If you don’t, you and the LLM need to go around tedious cycles of editing, rebuilding and reproducing the issue.

Looked at another way, LLMs can be brilliant when they have enough of the right context. But if they can’t see how your program actually behaves then they don’t have this and can’t get it.

We think time travel debugging is the right technology to close this gap.

Undo is our time travel debugger – a suite of tools that can record unmodified Linux software, then replay and debug it to understand how it went wrong (or just how it works). You get an immutable recording of everything the process did, at machine instruction granularity.

It works with C, C++, Rust, Go and Java (with more languages to come in future).

An AI Code Assistant suggests using Undo to debug code written years ago.

Quick start for impatient people

If you don’t have Undo yet, go get it, then return to this section!

This article is about an MCP (Model Context Protocol) server integration to use Undo’s UDB debugger with AI coding assistants. If you’re already a user of Undo + AI, you can try our first proof of concept right now, then return to the article when you’re ready.

Caveat: This is a tech preview, it’s bleeding edge and won’t work in all cases, but it should already be useful.

If you have a recent installation of Undo (v8.2.2 or higher should work, for older versions YMMV) then you can activate our AI extension at the UDB prompt using:

extend explain

This will download and install the explain extension. Now you have two new commands:

  • uexperimental mcp serve – Starts an MCP server on localhost:8000 for you to access from an external coding agent of your choice. This will turn over control of your debug session to the external coding agent (when the AI agent has disconnected you can simply quit the server with Ctrl-C and return to using UDB as a normal debugger.).
  • explain – Ask questions about the program you’re debugging (requires a working installation of Claude Code). Behind the scenes, this turns over control to Claude Code via MCP, then returns control to you once your question has been answered.

Good questions for the explain command ask for information about the program’s behavior or ask for help with reverse navigation. For instance:

What went wrong in this program?

What does the current backtrace mean?

Get me back out of libc.

Successive invocations of explain reuse the underlying Claude session, so you can have an ongoing dialogue during a single debug session.

Deep dive

What is Undo?

Undo provides software time travel. It can record the history of an x86 or ARM64 process, running on Linux, then wind back and forth through it down to machine instruction precision.

To do this, the Undo Engine instruments the process being recorded. The program requires no modification or special compilation — Undo injects JIT instrumentation at runtime to capture all the non-deterministic inputs to the program. Once this is done, the program can run as normal, while the Undo Engine captures every piece of non-deterministic information that flows into the program.

This includes:

  • System call results.
  • Thread scheduling.
  • Special machine instructions (e.g. x86’s rdtsc to read the time stamp counter).
  • Shared memory with other processes or hardware devices.
  • And so on…

With this information Undo can store the program’s execution into a portable recording file, which can be replayed any time – even on another machine. You can replay forward to see how the original execution unfolded or use time travel to rewind and jump around; ask questions like “When was the last time this function ran?” or “When did this variable get assigned this value?”.

On top of this machine-level capability, Undo supplies debug interfaces for C, C++, Rust, Go, Java, Kotlin and Scala.

With this available intermittent bugs can be recorded once and analyzed at will, memory corruptions become a matter of winding back to the bad write and complex code can be understood quickly by stepping backwards to see how execution unfolded.

Why does this matter to an AI?

AI based on Large Language Models (LLMs) is transforming how development is done. Code Assistants now generate considerable amounts of code in the real world. Agentic coding allows developers to assign work to an LLM and have it complete development tasks autonomously.

They’re also really good at digesting a big codebase and answering questions. What they’re less good at is understanding the dynamic behavior of a program – the reasoning required to infer what’s actually happened in the subtle corner cases that make for some of the hardest bugs.

Without enough information to tether them to what the program really did they’re also inclined to hallucinate a confident-but-wrong answer:

AI Code Assistant finally sees the issue... supposedly...

Undo recordings provide a complete trace of everything a program did when a bug occurred. There’s no need to guess – if the issue is captured in a recording then it can be understood. This provides a ground truth that can be used to guide and verify an LLM’s reasoning. With the information contained in a recording, AI coding agents can be smarter and more efficient.

What we’ve built so far

We’ve released an add-on extension called explain, which integrates with our UDB debugger. This is a tech preview but it can be used today to provide real assistance to debugging workflows.

This is shipped via our public Addons repository, so if you have a recent release of UDB you should be able to run:

extend explain

And get access to the command (put it in your .udbinit file to make it available in every session).

The extension provides a general-purpose MCP server (to integrate our UDB debugger with arbitrary AI agents) and a tightly-integrated explain command, which uses Claude Code behind the scenes to provide agentic reasoning.

To get this set up, read the Quick start for impatient people“. (Give yourself a pat on the back for being patient the first time around)

The MCP server makes it possible to turn over control of the UDB debugger to an AI agent. This makes the context of a time travel debug session available to any agent that supports MCP, giving it the ability to reason about the runtime behavior of a program:

AI Code Assistant Claude Code reasoning about information retrieved from the UDB MCP server.
Claude Code reasoning about information retrieved from the UDB MCP server.

The explain command provides an AI assistant within the debugger yourself – you can ask it questions about the code and its behavior, interleaved with your normal debugging commands.

This workflow makes use of an external coding agent (currently it supports Claude Code via its SDK but we expect to support others in the future). Behind the scenes, the command activates an MCP server and passes connection details, plus your question, to the coding agent – it can then make full use of its configured tools, including UDB itself, to assist you.

The explain command reasoning about a question the user asked, within the UDB debugger.
The explain command reasoning about a question the user asked, within the UDB debugger.

In either case, the extension supplies something resembling conventional debugger functionality to the LLM. To help the LLM get the best possible value from these we’ve restricted the commands available and modified them slightly to impedance match better with the AI’s expectations.

This produces some impressive results – explain can solve some bugs and provide helpful assistance in understanding others, though like any AI it can make mistakes. However, because it’s a human-like interface we still consider this a shallow integration. Making the full power of time travel debugging available to an LLM needs a deep match between the strengths of the two technologies.

What we’re building next

The real value in combining time travel debugging with AI is going to be unlocked as we integrate more and more deeply with the LLM’s capabilities.

Interactive debuggers are a human-centric user interface – they provide a precise interface for moving through program execution and inspecting the detailed state of the program. We don’t think that’s ultimately going to be the most powerful interface for an LLM.

Modern AIs excel at digesting and sifting text (often using separate agents to offload some processing and while preserving their context windows) so we’re working towards a query-oriented interface that’s specialized for LLM use. The tricky question is: given a recording of everything the program did, what are the most valuable queries we can provide?

That’s what we’re working on right now. The early signs here are very positive – we’re already seeing more successful investigation of real world bugs, with lower token costs. We’re looking forward to sharing more details in the near future.

Conclusions

The capabilities of time travel debugging mesh well with the abilities of code assistants: you can capture the complete history of a program and then use AI to help sift through for the interesting parts.

The explain extension makes it possible to get AI assistance within a debug session, automating routine parts of the work and suggesting theories. Please let us know what you’re able to do with it, or if you have suggestions!

We’re going to keep working to create an AI-native interface to time travel debugging, to make code assistants smarter and more efficient – watch this space.

In the meantime, why not try Undo for free?

Try Undo for free

Stay informed. Get the latest in your inbox.