MCP Commands - FileTools

<< Click to Display Table of Contents >>

Navigation:  3. Script Language > Internet and Network > MCP. - MCP (Model-Context Protocol) server operations > File Tools - File and content operations >

MCP Commands - FileTools

MCP.DiffEditMemory - Diff Edit Memory

PreviousTopNext


MiniRobot Language (MRL) - MCP FileTools Commands

 

MCP.DiffEditMemory

Diff Edit Memory

 

Purpose

 

The MCP.DiffEditMemory command applies a unified diff (patch) to content stored in the MCP memory bank, modifying the stored value in-place. This command is useful for editing cached data, updating session information, and performing structured modifications on memory-stored content without needing to extract and re-store it manually.

 

Syntax

 

MCP.DiffEditMemory|$$MEMORY_KEY|$$DIFF

 

Parameters

 

$$MEMORY_KEY - The key of the memory entry to patch. The key must exist in the MCP memory bank.

 

$$DIFF - The unified diff content (patch) to apply. Must be in standard unified diff format.

 

Return Value

 

The command returns a success message on completion, including statistics about the changes made, or an error message if the diff could not be applied. The memory entry is updated in-place with the patched content.

 

Examples

 

' Example 1: Patch content in memory

' First store some content

MCP.SetContent|memory:myData|Hello World

' Apply a patch to modify it

VAR.Patch = "--- a\n+++ b\n@@ -1 +1 @@\n-Hello World\n+Hello Universe"

MCP.DiffEditMemory|myData|$$Patch

' Memory now contains: "Hello Universe"

 

' Example 2: Edit configuration in memory

MCP.SetContent|memory:config|timeout=30\ndebug=true\nlevel=info

VAR.ConfigPatch = "--- a\n+++ b\n@@ -1,3 +1,3 @@\n-timeout=30\n+timeout=60\n debug=true\n-level=info\n+level=debug"

MCP.DiffEditMemory|config|$$ConfigPatch

 

' Example 3: Workflow with memory patching

' Load file, cache it, modify in memory, then save

MCP.GetContent|file:C:\Source\template.txt|$$Template

MCP.SetContent|memory:workingCopy|$$Template

' Apply modifications

VAR.ModPatch = "--- a\n+++ b\n@@ -1 +1 @@\n-{{NAME}}\n+John Doe"

MCP.DiffEditMemory|workingCopy|$$ModPatch

' Save modified content

MCP.GetContent|memory:workingCopy|$$Final

MCP.SetContent|file:C:\Output\result.txt|$$Final

 

Remarks

 

The MCP.DiffEditMemory command modifies memory entries in-place without requiring explicit recall and store operations. This provides a more efficient way to update stored data when only small changes are needed.

 

The command uses the same diff matching algorithm as MCP.DiffEditFile, supporting fuzzy matching for minor context variations. The memory key must exist before applying the patch; use MCP.SetContent first if the key does not exist.

 

Memory entries modified with this command retain their persistence settings (TEMP or PERM). The modified content replaces the original entirely, preserving only the key and persistence type.

 

Error Conditions

 

The command will fail with an error if:

• The memory key does not exist

• The diff parameter is missing or malformed

• The diff context does not match the memory content

• The memory bank is disabled or unavailable

 

See also:

 

MCP.DiffEditFile - Diff Edit File

MCP.DiffEditClipboard - Diff Edit Clipboard

MEM.RCL - Recall Value from Memory

MEM.STO - Store Value in Memory

FileTools Overview