|
<< 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 |
MiniRobot Language (MRL) - MCP FileTools Commands
MCP.DiffEditClipboard
Diff Edit Clipboard Content
Purpose
The MCP.DiffEditClipboard command applies a unified diff (patch) directly to the current clipboard content, modifying the clipboard in-place. This command is useful for automated clipboard transformations, allowing programmatic edits to copied content before pasting.
Syntax
MCP.DiffEditClipboard|$$DIFF
Parameters
$$DIFF - The unified diff content (patch) to apply to the clipboard. Must be in standard unified diff format.
Return Value
The command returns a success message on completion, or an error message if the diff could not be applied. The clipboard is updated in-place with the modified content.
Examples
' Example 1: Simple clipboard text replacement
' User has copied: "Hello World"
VAR.Patch = "--- clipboard\n+++ clipboard\n@@ -1 +1 @@\n-Hello World\n+Hello Universe"
MCP.DiffEditClipboard|$$Patch
' Clipboard now contains: "Hello Universe"
' Example 2: Multi-line code modification
' Clipboard contains code block
VAR.CodePatch = "--- a\n+++ b\n@@ -1,3 +1,4 @@\n function test() {\n+ // Added comment\n return true;\n }"
MCP.DiffEditClipboard|$$CodePatch
' Example 3: Load patch from file and apply to clipboard
MCP.GetContent|file:C:\Patches\clipboard.patch|$$PatchData
MCP.DiffEditClipboard|$$PatchData
' Example 4: Workflow with clipboard modification
' 1. Get clipboard content
CBV.Get|$$OriginalText
' 2. Create patch based on analysis
MCP.AnalyzeFile|$$TempFile|$$Info
' 3. Apply patch directly to clipboard
VAR.MyPatch = "--- orig\n+++ mod\n@@ -1 +1 @@\n-" + $$OriginalText + "\n+Modified: " + $$OriginalText
MCP.DiffEditClipboard|$$MyPatch
Remarks
The MCP.DiffEditClipboard command modifies the system clipboard directly. The original clipboard content is used as the base for applying the diff. If the clipboard contains non-text data (images, formatted content, etc.), the command will attempt to work with the text representation if available.
The command uses fuzzy matching for the diff application, allowing minor context variations. However, if the clipboard content has changed significantly from what the patch expects, the operation may fail.
This command is particularly useful in automation workflows where content needs to be transformed between copy and paste operations, such as code formatting, variable renaming, or template substitution.
Error Conditions
The command will fail with an error if:
• The diff parameter is missing or malformed
• The clipboard is empty or contains no text data
• The diff context does not match the clipboard content
• Clipboard access is denied or unavailable
See also:
• MCP.DiffEditFile - Diff Edit File
• MCP.DiffEditMemory - Diff Edit Memory
• CBV.Get - Get Clipboard Text