Skip to main content
Glama
eva-wanxin-git

Windows Automation MCP Server

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
NameRequiredDescriptionDefault
textYes要设置的文本内容

Implementation Reference

  • 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 };
      }
    }
  • 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'],
      },
    },
  • 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: {},
          },
        },
      ];
  • 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(),
    };

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/eva-wanxin-git/windows-automation-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server