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);
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries full burden for behavioral disclosure. It states the action (close) but doesn't describe what 'close' means behaviorally - whether it terminates applications, closes GUI windows, requires specific permissions, has side effects on unsaved data, or provides any confirmation/feedback. For a potentially destructive operation with zero annotation coverage, this is inadequate.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is maximally concise with a single four-character phrase that directly states the tool's purpose. There's zero waste or unnecessary elaboration, making it efficiently front-loaded despite its simplicity.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a potentially destructive window management tool with no annotations and no output schema, the description is incomplete. It doesn't address behavioral implications, success/failure conditions, error handling, or what constitutes a 'window' in this context. Given the complexity of window management operations and lack of structured metadata, more context is needed.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100% with the single parameter 'title' documented as '窗口标题' (window title). The description doesn't add any meaningful parameter semantics beyond what the schema already provides - no examples of valid titles, format requirements, or matching behavior. Baseline 3 is appropriate when schema does the heavy lifting.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose3/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description '关闭指定窗口' (Close specified window) clearly states the action (close) and target (window), but it's vague about what constitutes a 'specified window' and doesn't differentiate from sibling tools like 'browser_close' or 'activate_window'. It provides basic purpose but lacks specificity about window identification method or scope.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance is provided on when to use this tool versus alternatives like 'browser_close', 'minimize_window', 'maximize_window', or 'kill_process'. The description doesn't mention prerequisites, exclusions, or appropriate contexts for window closure versus other window management operations.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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