LLM-powered coding assistants such as GitHub Copilot, Cursor, and Claude Code have fundamentally altered how software engineers interact with their development environments. These systems no longer merely suggest code; they autonomously execute sequences of tool calls: creating files, running terminal commands, querying databases, and invoking external APIs. A developer may delegate a multi-step refactoring task to an agent and return to discover that hundreds of files have been modified, shell commands have been executed, and environment state has been mutated in ways that are difficult to characterize, much less reverse.
This opacity is not merely inconvenient. It is a fundamental safety and reliability concern. Unlike a human developer whose individual keystrokes produce a recoverable edit history, an LLM agent collapses an entire strategy into a rapid burst of opaque tool invocations. The standard version-control workflow (commit, diff, revert) captures only file-system state and does not account for side effects such as outbound HTTP requests, database writes, or process spawning. When an agent makes a mistake midway through a compound operation, the developer is left without a principled mechanism to identify exactly which tool calls need to be reversed and in what order.
The Model Context Protocol (MCP), introduced by Anthropic in 2024 and rapidly adopted by the broader ecosystem (Anthropic, 2024), provides a standardized JSON-RPC interface through which LLM hosts discover and invoke tools exposed by MCP servers. While MCP successfully decouples tool providers from LLM runtimes, it is explicitly a transport and discovery protocol: it carries tool invocations faithfully but records nothing, enforces no audit trail, and provides no rollback primitive.
The correct architectural locus for recording and undo capability is the protocol layer itself, specifically a transparent proxy that intercepts MCP traffic without requiring changes to either endpoint. This design principle, analogous to how network monitoring tools operate at the packet layer, ensures that any MCP-compliant host and server combination immediately gains observability and undo capability simply by routing through the proxy.
This paper makes the following contributions:
The remainder of the paper is organized as follows. Section 2 provides background on MCP, existing observability tools, and copy-on-write snapshot concepts. Section 3 presents the system design. Section 4 describes the Rust implementation. Section 5 reports the evaluation. Section 6 discusses trade-offs and future directions. Section 7 concludes.
MCP defines a client-server protocol in which an MCP host (the LLM runtime or IDE integration) connects to one or more MCP servers (tool providers). The protocol is transported over standard I/O or WebSocket connections using JSON-RPC 2.0 message framing. Servers expose a capability manifest that lists available tools, each described by a name, a JSON Schema for its input parameters, and an optional annotation indicating whether the tool has side effects. The host discovers tools via a tools/list request and invokes them via tools/call messages, receiving structured results that the LLM can incorporate into its context window (Anthropic, 2024).
The protocol is deliberately minimal. It defines the shape of tool invocations but imposes no requirements on logging, access control, replay, or undo. This minimalism is appropriate for the protocol layer, as these concerns are rightly the responsibility of higher-level infrastructure, but it also means that current deployments universally lack these capabilities.
MCP has seen rapid adoption since its introduction. As of mid-2026, major LLM-powered development tools including Claude Code, Cursor, and a growing ecosystem of third-party integrations support the protocol natively. This breadth of adoption makes a protocol-level proxy approach particularly attractive: a single proxy implementation benefits all compliant hosts and servers without coordination.
The observability tooling available to developers today was designed for deterministic, human-authored code. Version control systems such as Git (Torvalds, 2005) record file-system snapshots at developer-chosen commit boundaries, but they do not capture the sequence of intermediate tool invocations that produced those snapshots. Distributed tracing frameworks such as OpenTelemetry (OpenTelemetry Authors, 2023) record structured spans for service calls, but require instrumentation at the application level and provide no undo primitive. Shell history provides a partial record of commands executed in a terminal, but this record is easily lost, does not capture outputs, and covers only a single tool category.
Several LLM observability platforms, including LangSmith, Weights & Biases Traces, and Arize Phoenix, provide tracing for LLM API calls and chain-of-thought reasoning steps (LangChain Inc., 2024; Weights & Biases, 2024). These systems are valuable for understanding model behavior but operate at the application framework layer and do not intercept MCP-level tool calls. They also lack undo semantics entirely.
The gap is therefore specific: there exists no tool that transparently records MCP tool calls with full fidelity and provides a principled mechanism for selective reversal.
Copy-on-write (CoW) is a resource-management strategy in which a copy of a data structure is deferred until a modification is actually made. CoW semantics underpin many file systems, including ZFS (Bonwick et al., 2003), Btrfs (Mason, 2007), and APFS (Apple, 2017), as well as virtual machine snapshot mechanisms and database multi-version concurrency control (MVCC). In the context of memplane, CoW is applied at the level of file-system objects and in-memory state representations: before forwarding a destructive MCP tool call to the server, the proxy snapshots the affected resources. If the call is later selected for undo, the snapshot provides the data needed for restoration without requiring a full replay of the session from the beginning.
MCP tools typically operate on bounded, identifiable resources: a file path, a database row identified by a key, a named environment variable. The input schema of each tool call therefore serves as a declaration of the resources it will affect, enabling the proxy to snapshot precisely those resources rather than the entire system state. This property makes CoW tractable at the proxy layer.
Undo in interactive systems has been studied extensively in the context of text editors and collaborative editing (Berlage, 1994; Ressel et al., 1996). The classical linear undo stack (reversing operations in strict LIFO order) is unsuitable for agent workflows where recent operations may be logically independent of an earlier mistake. Selective undo, which allows reversing an arbitrary past operation while preserving subsequent unrelated work, requires reasoning about dependencies between operations (Myers, 1987). We adapt this framework to the MCP setting, where dependencies arise from shared resource access: two tool calls are dependent if one reads or writes a resource that the other writes.
memplane is positioned as a transparent proxy in the MCP communication path. From the perspective of the LLM host, memplane appears to be a standard MCP server: it presents a capabilities manifest and responds to tools/list and tools/call messages. From the perspective of the upstream MCP server, memplane appears to be a standard MCP client. This double-impersonation requires no configuration changes at either endpoint; the host is simply directed to connect to the proxy's endpoint instead of the server's endpoint directly.
Figure 1 illustrates the high-level architecture. The proxy process hosts three principal subsystems: the intercept pipeline, which handles message routing and recording; the snapshot engine, which manages CoW state capture; and the undo planner, which computes minimal undo sets on demand.
Upon receiving a tools/call message from the LLM host, the intercept pipeline performs the following steps in sequence:
readOnly: true in the MCP capabilities manifest are treated as non-destructive. Unknown tools default to destructive (fail-safe).The entire intercept path adds latency only in the critical section between steps 2 and 4 for destructive calls, and between steps 5 and 6 for all calls. Steps 1 and 7 overlap with network I/O. We demonstrate in Section 5 that this latency is negligible relative to typical tool execution times.
The ledger is the durable record of all tool calls processed by the proxy. It must be append-only, tamper-evident, and efficiently queryable by sequence number, time range, and resource identifier. memplane uses RocksDB (Facebook Engineering, 2013) as the storage engine, configured with a column-family layout that separates call records, snapshot metadata, and the dependency graph index. RocksDB's log-structured merge tree (LSM) design naturally supports high-throughput sequential writes while providing O(log n) point lookups.
Tamper-evidence is achieved through a hash-chaining scheme. Each ledger entry includes a prev_hash field containing the SHA-256 hash of the immediately preceding entry. Any modification to a historical entry, or any insertion into the middle of the sequence, would invalidate all subsequent hashes and be immediately detectable. This property is particularly important for security-sensitive use cases where an audit trail must be provably unaltered.
The ledger stores both the pre-call and post-call halves of each entry as separate records, linked by sequence number. This two-phase structure allows the proxy to record the intent of a tool call (useful for crash recovery and partial-failure analysis) even before the call completes or returns a result.
The snapshot engine is responsible for preserving the state of resources that a destructive tool call is about to modify. Its operation is resource-type-specific: different resource types require different snapshot strategies.
For file-system resources, the engine records the full path, current modification time, file size, and file contents (for files below a configurable size threshold, currently 10 MB). For larger files, it records a content-addressable hash and deduplicates storage by checking whether an identical hash has been seen in a previous snapshot. For directories, it records the directory listing recursively, but defers content snapshots to individual files at write time, reducing the cost of operations that affect only a subset of a directory tree.
For database resources (when using an MCP server that exposes database operations), the engine can optionally integrate with the database's own MVCC mechanism. When the database supports it, the engine records the transaction ID at the time of the snapshot and uses the database's historical query capability for restoration. When it does not, the engine falls back to reading and storing the affected rows directly.
Snapshots are stored in a dedicated column family of the RocksDB ledger, keyed by snapshot ID. Snapshot metadata, including the list of resource identifiers covered, is stored alongside the call record for efficient lookup during undo planning.
The surgical undo algorithm answers the question: given a set of tool calls to be undone, what is the minimal set of additional undos required to restore a consistent state, and in what order should they be applied?
We model the call history as a directed acyclic graph (DAG) G = (V, E) where each vertex v ∈ V represents a recorded tool call and each directed edge (u, v) ∈ E represents a dependency: call v depends on the state produced by call u, meaning that v read or wrote a resource that u wrote. This dependency structure is inferred from the resource annotations stored with each call record.
Given a target set T ʬ V of calls the developer wishes to undo, the undo planner computes the dependency closure D(T) as follows:
The resulting set D(T) is the minimal set of calls that must be undone to safely restore the target state. Calls in D(T) are sorted in reverse topological order of their original execution, ensuring that each call is undone before any call that depended on it.
Each call is undone by invoking its snapshot's restore operation. For file-system resources, this means overwriting the current file with the snapshot content. For database resources, this means applying the reverse of the recorded mutations. For calls with no snapshot (read-only calls that should never appear in T) or for calls whose effects are externally visible and irreversible (outbound HTTP requests, emails), the planner emits a warning and skips the restore, flagging the undo operation as partial.
The planner exposes both a dry-run mode (reporting what would be undone and highlighting any partial-undo warnings) and an execute mode. Developers are expected to review the dry-run output before committing an undo operation.
memplane is implemented entirely in Rust using the Tokio async runtime. The choice of Rust is motivated by three requirements: memory safety without garbage collection (critical for a proxy that processes and stores potentially large and untrusted payloads), high throughput with low and predictable latency, and a rich ecosystem of async I/O libraries. The proxy handles multiple simultaneous MCP connections, common in IDE integrations that connect multiple tool servers, via Tokio's multi-threaded work-stealing executor.
Each MCP connection is managed by an independent ConnectionSession task that owns the intercept pipeline state for that connection. The snapshot engine and ledger writer are shared across sessions through Arc-wrapped, lock-minimized handles: the ledger writer uses a dedicated Tokio task with a bounded mpsc channel to serialize writes without blocking the intercept pipeline, and the snapshot engine uses a DashMap-based concurrent hash map to manage in-flight snapshot state. This design ensures that the critical path from message receipt to forward is never blocked by ledger I/O.
The central abstraction in memplane is the Interceptor trait, which defines the interface that all intercept-pipeline stages must implement. This trait enables a composable middleware architecture: interceptors can be stacked, and new behaviors (rate limiting, redaction of sensitive parameters, metrics emission) can be added without modifying existing code.
The CallContext structure carries per-call mutable state through the pipeline, including the assigned sequence number, any snapshot IDs created, and a resource-access log that is populated by the snapshot engine and later used for dependency-graph construction. The ChainedInterceptor combinator composes two Interceptor implementations such that before_call is invoked in order and after_call in reverse order, following the middleware convention familiar from web frameworks such as Tower (Pedersen & Contributors, 2019).
The primary data structures in the implementation are organized around the ledger entry lifecycle. A LedgerEntry is a flat, serializable struct containing all fields required for replay and undo. Serialization uses the bincode crate for compact binary encoding in the RocksDB store and serde_json for human-readable export. The SnapshotRecord struct holds the content of a single resource snapshot and is stored separately from the call record to allow deduplication across calls that snapshot the same resource in the same state.
The intercept pipeline is structured as a sequence of Tokio tasks connected by channels. When the proxy accepts a new connection from the LLM host, it spawns a ConnectionSession task that owns the inbound and outbound message queues. Tool call messages are dispatched to a pipeline processing task, which executes the interceptor chain synchronously within the Tokio cooperative scheduler, avoiding the overhead of spawning a separate task per call. Snapshot I/O (reading file content before a write call) is performed with tokio::fs to avoid blocking the executor thread, and ledger writes are offloaded to the dedicated ledger-writer task via an mpsc channel of type tokio::sync::mpsc::Sender<LedgerWriteOp>.
The proxy multiplexes multiple upstream MCP server connections behind a single downstream-facing endpoint. Each upstream server has its own reconnecting connection manager that handles server restarts gracefully. The capabilities manifest presented to the LLM host is the union of all upstream servers' manifests, with tool names namespaced by server identifier to avoid collisions.
The RocksDB instance is opened with three column families: cf_entries (ledger entries keyed by big-endian sequence number for ordered iteration), cf_snapshots (snapshot records keyed by snapshot ID), and cf_resource_index (an inverted index mapping resource IDs to the list of sequence numbers of calls that accessed them, used to accelerate dependency-graph construction). The resource index is updated atomically with the entry write using RocksDB's WriteBatch API, ensuring that the index and the entry are always consistent even in the presence of a crash.
For the content-addressable store (CAS) used for large file snapshots, memplane defaults to a local directory of flat files named by their SHA-256 hash, with an optional S3-compatible backend for distributed deployments. The CAS layer is abstracted behind a ContentStore trait, allowing additional backends to be added without modifying the snapshot engine.
We evaluated memplane across three dimensions: per-call proxy overhead, undo operation latency as a function of session size, and storage overhead relative to raw MCP traffic volume. Experiments were conducted on an Apple M2 Pro (12-core) running macOS 14.5, with the proxy, LLM host, and MCP server all running on the same machine to isolate proxy-specific overhead from network effects. The MCP server used in benchmarks was a filesystem tool server backed by an NVMe SSD. Session corpora were generated from real AI-assisted coding sessions and augmented with synthetic workloads to test boundary conditions.
| Call Type | Median Overhead (µs) | p95 Overhead (µs) | p99 Overhead (µs) | Notes |
|---|---|---|---|---|
| Read-only (no snapshot) | 18 | 31 | 52 | Ledger write only |
| Destructive, small file (<64 KB) | 38 | 67 | 104 | Snapshot + ledger write |
| Destructive, medium file (1 MB) | 312 | 489 | 621 | File read dominates |
| Destructive, large file (10 MB) | 2,840 | 3,910 | 4,450 | CAS write included |
| Shell command (no file snapshot) | 22 | 38 | 61 | No resource snapshot possible |
| Database row mutation (SQLite) | 94 | 147 | 198 | Row snapshot via MVCC |
For the most common case, destructive calls operating on small files that constitute the majority of code-editing operations, the median overhead is 38 microseconds. This is negligible relative to the execution time of even the fastest MCP tools (file reads and writes typically complete in 0.5–5 milliseconds on modern hardware). The overhead for large files is dominated by the time to read the file for snapshotting, not by any memplane-specific computation; future work on lazy snapshotting (computing the hash first and deferring full read to actual undo time) is expected to reduce this significantly.
| Session Size (calls) | Undo Set Size | Dep. Graph Build (ms) | Restore Execution (ms) | Total Undo Latency (ms) |
|---|---|---|---|---|
| 100 | 5 | 0.4 | 1.2 | 1.6 |
| 500 | 12 | 1.1 | 3.7 | 4.8 |
| 1,000 | 20 | 2.3 | 5.9 | 8.2 |
| 2,000 | 31 | 4.4 | 7.1 | 11.5 |
| 5,000 | 47 | 9.8 | 12.3 | 22.1 |
Undo latency scales sub-linearly with session size because the dependency graph traversal is bounded by the undo set size (which grows slowly as sessions grow, since most new calls are independent of prior ones), not by the total session size. For the practical range of sessions encountered in developer workflows (under 2,000 calls per session), total undo latency is comfortably below 12 milliseconds, which is imperceptible in interactive use.
| Workload | Raw MCP Traffic (MB) | Ledger Size (MB) | Snapshot Store (MB) | Total Overhead Ratio |
|---|---|---|---|---|
| Code generation (500 calls) | 4.2 | 5.1 | 1.8 | 1.64x |
| File refactoring (300 calls) | 18.7 | 19.4 | 7.3 | 1.43x |
| Database migrations (200 calls) | 1.1 | 1.4 | 0.4 | 1.64x |
| Mixed session (1,000 calls) | 31.5 | 33.2 | 11.6 | 1.42x |
The overall storage overhead of 1.4x is modest and comparable to the overhead of maintaining a git history for a project of similar scope. Content deduplication in the snapshot store is particularly effective for file-refactoring workloads, where the same file may be written multiple times in a session and intermediate snapshots that are superseded by later ones share content with adjacent versions. Automated ledger compaction (removing entries older than a configurable retention window and deduplicating snapshot content) further reduces long-term storage growth.
The principal trade-off in memplane's design is between the cost of pre-emptive snapshotting and the fidelity of undo. By snapshotting before every destructive call, we ensure that undo is always available without requiring a full session replay. The cost is the snapshot overhead documented in Table 1 and the storage overhead in Table 3. For workloads dominated by large-file mutations, this cost may be significant, and the lazy snapshotting optimization mentioned in Section 5.1 merits further investigation.
Partial undo is a fundamental limitation that cannot be eliminated through better design. Some tool effects, including outbound network requests, spawned processes that have already exited, and non-MVCC database writes in external systems, leave no snapshot-restorable state. memplane handles these cases by emitting clear warnings in the dry-run output and proceeding with the remaining restorable portion of the undo set. Developers should treat partial undo warnings as a signal to verify externally visible side effects manually. Future work could integrate with external systems' own audit logs (e.g., outbound request logs from a proxy, database binary logs) to provide higher-fidelity undo for these cases.
The dependency-graph approach assumes that resource identifiers are stable and that the resource access annotations provided at snapshot time are accurate. If an MCP tool writes to a resource under a name that differs from the name used by a subsequent tool to read it (for example, symlinks, database aliases, or path normalization differences), the dependency will be missed and the resulting undo set may be incomplete. memplane mitigates this by canonicalizing file paths and resolving symlinks at annotation time, but the general problem of resource identity aliasing remains an open research challenge.
The ledger's hash-chaining scheme provides tamper evidence but not confidentiality. In deployments where tool-call inputs and outputs may contain sensitive data (API keys passed as parameters, database query results containing PII), the ledger should be encrypted at rest. memplane supports optional AES-256-GCM encryption of ledger and snapshot content using a key stored in the system keychain. Redaction interceptors can also be stacked in the pipeline to strip known-sensitive fields from entries before they are written to the ledger.
The proxy itself occupies a privileged position in the communication path and must be deployed with appropriate access controls. A compromised proxy could suppress tool-call records or inject synthetic calls into the ledger. Defense against this requires attestation of the proxy binary (e.g., via code signing and process-level integrity monitoring) and periodic ledger verification by an independent process that checks the hash chain.
The current implementation handles multiple simultaneous MCP connections from a single LLM host process. A growing class of deployment scenarios involves multiple coordinating LLM agents, each with their own host process, operating on a shared file system or database. In such scenarios, the dependency graph must account for inter-session dependencies: a file written by agent A's tool call and subsequently read by agent B's tool call creates a cross-session dependency that would not be visible within either agent's individual call graph.
We plan to extend memplane with a shared ledger mode in which multiple proxy instances write to the same RocksDB ledger (using RocksDB's secondary instance feature for readers and a single writer process for serialization). The dependency-graph construction algorithm is unchanged; cross-session edges are simply edges whose endpoints belong to different session namespaces. Undo operations in shared-ledger mode require authorization from all affected sessions, implementing a simple multi-party consent model for collaborative rollback.
memplane is related to a broader body of work on data provenance: tracking the origins and transformations of data through a computation (Cheney et al., 2009; Buneman et al., 2001). The ledger can be understood as a provenance record for the file system and database state produced by an agent session, where each entry records both the transformation applied (the tool call) and the input and output states. Unlike general-purpose provenance systems, which must track data lineage through arbitrary computations, memplane operates at the coarser granularity of MCP tool calls, which are semantically meaningful units with declared resource effects. This coarser granularity makes the dependency graph more tractable to construct and query while still providing sufficient fidelity for developer-oriented undo operations.
We have presented memplane, a transparent MCP proxy that provides tamper-evident recording of LLM agent tool calls and surgical undo capability for AI-assisted development workflows. By operating at the protocol layer, memplane requires no modifications to existing MCP-compliant LLM hosts or tool servers, and its composable interceptor architecture allows additional behaviors to be layered on without disrupting the core recording and undo functionality.
Our evaluation demonstrates that the system's per-call overhead is negligible for typical development workloads, undo operations complete in well under 20 milliseconds for sessions of practical size, and storage overhead is a modest 1.4x relative to raw MCP traffic. The surgical undo algorithm, based on dependency-closure computation over the recorded call graph, correctly identifies the minimal set of calls that must be reversed to restore a desired prior state without disturbing unrelated work.
As LLM agents take on increasingly consequential roles in software development, not merely suggesting code but autonomously executing complex multi-step operations, the ability to observe, audit, and selectively reverse their actions becomes a prerequisite for safe deployment. memplane represents a step toward making AI-assisted development as recoverable and auditable as traditional human-driven development, while imposing minimal friction on the workflows it protects.
The source code for memplane is available under the MIT license at https://github.com/VMaroon95/memplane.