Skip to main content
Glama

Windows Automation MCP Server

close_window

Close a specific window on Windows by providing its title. This tool helps automate window management tasks for system control and workflow automation.

Instructions

关闭指定窗口

Input Schema

NameRequiredDescriptionDefault
titleYes窗口标题

Input Schema (JSON Schema)

{ "properties": { "title": { "description": "窗口标题", "type": "string" } }, "required": [ "title" ], "type": "object" }

Implementation Reference

  • The core handler function that implements the close_window tool logic. Uses PowerShell script to find processes matching the window title and gracefully closes their main window.
    async closeWindow(title) { try { // 使用 taskkill 通过窗口标题关闭 const script = ` $processes = Get-Process | Where-Object { $_.MainWindowTitle -like "*${title}*" } foreach ($proc in $processes) { $proc.CloseMainWindow() | Out-Null } `; await execAsync(`powershell -Command "${script}"`, { shell: 'powershell.exe' }); return { success: true, window: title, message: '窗口已关闭' }; } catch (error) { return { success: false, error: error.message }; } }
  • Schema definition for the close_window tool within getToolDefinitions(), specifying input requirements.
    { name: 'close_window', description: '关闭指定窗口', inputSchema: { type: 'object', properties: { title: { type: 'string', description: '窗口标题' }, }, required: ['title'], }, },
  • Registration of 'close_window' in the array of supported tools for the canHandle() method.
    const tools = ['list_windows', 'get_active_window', 'activate_window', 'close_window', 'minimize_window', 'maximize_window']; return tools.includes(toolName);
  • Routing case in the executeTool() switch statement that dispatches to the closeWindow handler.
    case 'close_window': return await this.closeWindow(args.title);

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