Clipboard Tool
Peekaboo ships one clipboard domain in the CLI and MCP server for text, images, files, and raw pasteboard data. Both surfaces call the shared ClipboardService in PeekabooAutomationKit.
#User-facing behaviors
- CLI subcommands and MCP actions:
get,set,clear,save,restore. - Text: read and write UTF-8 text;
--also-textadds a plain-text companion to binary data. - Files and images: infer the UTI from the file extension and write the file bytes to the pasteboard.
- Raw data: accept base64 plus an explicit UTI.
- Slots:
saveandrestoresnapshot all available pasteboard representations. The default slot is0; named slots use dedicated macOS pasteboards so separate CLI invocations can restore them. - Size guard: block writes over 10 MB unless
--allow-largeis set. The limit includes all representations and companion text. - Verification: CLI
setsupports--verify, which reads each supported representation back and compares it with the requested payload.
#CLI syntax (peekaboo clipboard …)
get [--prefer <uti>] [--output <path|->] [--json-output]- Text prints to stdout. Binary data is written with
--output;--output -streams bytes in text mode and returns base64 in JSON mode. set (--text <string> | --file-path <path> | --data-base64 <b64> --uti <uti>) [--also-text <string>] [--allow-large] [--verify]clearsave [--slot <name>]restore [--slot <name>]
#MCP schema
- Tool name:
clipboard - Required parameter:
actionwithget | set | clear | save | restore. - Optional parameters:
text,file_path,data_base64,uti,prefer,outputPath,slot,alsoText, andallowLarge. - Results use normal MCP text responses plus metadata such as
uti,size,textPreview,filePath, andslotwhen available. - MCP
outputPathaccepts a filesystem path only.outputPath: "-"is rejected because MCP stdout is the JSON-RPC transport; omitoutputPathto receive UTF-8 text in the tool response, or provide a path for binary data. Peekaboo does not put arbitrary clipboard bytes on the protocol stream.
The MCP surface does not expose the CLI-only --verify readback option.
#Implementation
ClipboardServicewrapsNSPasteboard, applies the size limit, and owns slot save/restore.ClipboardCommandmaps CLI flags toClipboardWriteRequestand emits text or structured JSON.ClipboardToolmaps MCP arguments to the same request and service.PasteCommandandPasteToolpreserve and restore the current clipboard around Cmd+V when a payload is supplied.
#Tests and fixtures
- Service coverage lives with
PeekabooAutomationKitclipboard tests. - CLI coverage lives in
Apps/CLI/Tests. docs/testing/fixtures/clipboard-smoke.peekaboo.jsonexercises the scripted command flow.