set_clipboard
Copies text to Windows clipboard for easy pasting across applications, enabling quick data transfer between programs and automated workflows.
Instructions
设置剪贴板内容
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| text | Yes | 要设置的文本内容 |
Input Schema (JSON Schema)
{
"properties": {
"text": {
"description": "要设置的文本内容",
"type": "string"
}
},
"required": [
"text"
],
"type": "object"
}
Implementation Reference
- src/tools/clipboard.js:71-82 (handler)Executes the core logic for setting clipboard content using PowerShell's Set-Clipboard command, with text escaping for special characters.async setClipboard(text) { try { // 转义特殊字符 const escapedText = text.replace(/"/g, '`"').replace(/\$/g, '`$'); await execAsync(`powershell -Command "Set-Clipboard -Value '${escapedText}'"`, { shell: 'powershell.exe' }); return { success: true, message: '剪贴板已设置', length: text.length }; } catch (error) { return { success: false, error: error.message }; } }
- src/tools/clipboard.js:20-30 (registration)Registers the 'set_clipboard' tool in getToolDefinitions(), providing name, description, and input schema.{ name: 'set_clipboard', description: '设置剪贴板内容', inputSchema: { type: 'object', properties: { text: { type: 'string', description: '要设置的文本内容' }, }, required: ['text'], }, },
- src/tools/clipboard.js:51-52 (handler)Dispatches 'set_clipboard' calls to the setClipboard handler in executeTool method.case 'set_clipboard': return await this.setClipboard(args.text);
- src/server.js:43-52 (registration)Instantiates ClipboardTools as part of the tools collection, enabling registration and handling of its tools including set_clipboard.this.tools = { filesystem: new FileSystemTools(), process: new ProcessTools(), mouseKeyboard: new MouseKeyboardTools(), window: new WindowTools(), screen: new ScreenTools(), clipboard: new ClipboardTools(), powershell: new PowerShellTools(), browser: new BrowserTools(), };
- src/server.js:21-21 (registration)Imports the ClipboardTools class which implements the set_clipboard tool.import { ClipboardTools } from './tools/clipboard.js';