Skip to main content
Glama
eva-wanxin-git

Windows Automation MCP Server

close_window

Close a specific window by its title to manage desktop applications and free up system resources.

Instructions

关闭指定窗口

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
titleYes窗口标题

Implementation Reference

  • The main handler function that executes the close_window tool logic: finds processes matching the window title using PowerShell and 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, including name, description, and input schema requiring a 'title' string.
    { name: 'close_window', description: '关闭指定窗口', inputSchema: { type: 'object', properties: { title: { type: 'string', description: '窗口标题' }, }, required: ['title'], }, },
  • Tool registration in the executeTool switch statement, dispatching close_window calls to the closeWindow handler.
    case 'close_window': return await this.closeWindow(args.title);
  • Includes 'close_window' in the list of supported tools checked by canHandle method.
    const tools = ['list_windows', 'get_active_window', 'activate_window', 'close_window', 'minimize_window', 'maximize_window']; return tools.includes(toolName);

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