set_clipboard
Copies text to the Windows clipboard for pasting into other applications. Use this tool to set clipboard content programmatically.
Instructions
设置剪贴板内容
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| text | Yes | 要设置的文本内容 |
Implementation Reference
- src/tools/clipboard.js:71-82 (handler)The setClipboard method that executes the tool logic: escapes text and runs PowerShell Set-Clipboard command.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 (schema)Tool schema definition including name, description, and inputSchema requiring 'text' string.{ name: 'set_clipboard', description: '设置剪贴板内容', inputSchema: { type: 'object', properties: { text: { type: 'string', description: '要设置的文本内容' }, }, required: ['text'], }, },
- src/tools/clipboard.js:10-39 (registration)getToolDefinitions() method registers the set_clipboard tool schema by including it in the returned array.getToolDefinitions() { return [ { name: 'get_clipboard', description: '获取剪贴板内容', inputSchema: { type: 'object', properties: {}, }, }, { name: 'set_clipboard', description: '设置剪贴板内容', inputSchema: { type: 'object', properties: { text: { type: 'string', description: '要设置的文本内容' }, }, required: ['text'], }, }, { name: 'clear_clipboard', description: '清空剪贴板', inputSchema: { type: 'object', properties: {}, }, }, ];
- src/tools/clipboard.js:42-58 (registration)canHandle checks if tool is set_clipboard; executeTool dispatches set_clipboard calls to setClipboard handler.canHandle(toolName) { const tools = ['get_clipboard', 'set_clipboard', 'clear_clipboard']; return tools.includes(toolName); } async executeTool(name, args) { switch (name) { case 'get_clipboard': return await this.getClipboard(); case 'set_clipboard': return await this.setClipboard(args.text); case 'clear_clipboard': return await this.clearClipboard(); default: throw new Error(`未知工具: ${name}`); } }
- src/server.js:49-52 (registration)Server instantiates ClipboardTools instance, which provides set_clipboard via getToolDefinitions and executeTool.clipboard: new ClipboardTools(), powershell: new PowerShellTools(), browser: new BrowserTools(), };