Skip to main content
Glama
eva-wanxin-git

Windows Automation MCP Server

list_windows

Retrieve a list of all currently open windows on a Windows system. Filter results by window title to find specific applications or processes quickly.

Instructions

列出所有打开的窗口

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
filterNo过滤窗口标题(可选)

Implementation Reference

  • The main handler function that lists all visible windows using Win32 API via PowerShell script, filters by title if provided, and returns a structured response.
      async listWindows(filter = '') {
        try {
          // 使用 PowerShell 获取窗口列表
          const script = `
            Add-Type @"
              using System;
              using System.Runtime.InteropServices;
              using System.Text;
              public class Win32 {
                [DllImport("user32.dll")]
                public static extern bool EnumWindows(EnumWindowsProc enumProc, IntPtr lParam);
                [DllImport("user32.dll")]
                public static extern int GetWindowText(IntPtr hWnd, StringBuilder lpString, int nMaxCount);
                [DllImport("user32.dll")]
                public static extern bool IsWindowVisible(IntPtr hWnd);
                public delegate bool EnumWindowsProc(IntPtr hWnd, IntPtr lParam);
              }
    "@
            $windows = @()
            [Win32]::EnumWindows({
              param($hWnd, $lParam)
              if ([Win32]::IsWindowVisible($hWnd)) {
                $title = New-Object System.Text.StringBuilder 256
                [Win32]::GetWindowText($hWnd, $title, 256)
                if ($title.Length -gt 0) {
                  $windows += $title.ToString()
                }
              }
              return $true
            }, [IntPtr]::Zero)
            $windows | ConvertTo-Json
          `;
    
          const { stdout } = await execAsync(`powershell -Command "${script.replace(/"/g, '\\"')}"`, {
            shell: 'powershell.exe'
          });
    
          let windows = [];
          try {
            windows = JSON.parse(stdout);
            if (!Array.isArray(windows)) {
              windows = [windows];
            }
          } catch {
            windows = [];
          }
    
          const filtered = filter 
            ? windows.filter(w => w.toLowerCase().includes(filter.toLowerCase()))
            : windows;
    
          return { success: true, windows: filtered, count: filtered.length };
        } catch (error) {
          return { success: false, error: error.message };
        }
      }
  • Tool schema definition in getToolDefinitions(), specifying name, description, and optional filter input schema.
    {
      name: 'list_windows',
      description: '列出所有打开的窗口',
      inputSchema: {
        type: 'object',
        properties: {
          filter: { type: 'string', description: '过滤窗口标题(可选)' },
        },
      },
    },
  • Registration in the executeTool method's switch statement, dispatching calls to the listWindows handler.
    case 'list_windows':
      return await this.listWindows(args.filter);
  • Tool name listed in the canHandle method's supported tools array.
    const tools = ['list_windows', 'get_active_window', 'activate_window', 
                   'close_window', 'minimize_window', 'maximize_window'];
Behavior2/5

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

No annotations are provided, so the description carries the full burden. It states what the tool does but doesn't disclose behavioral traits such as whether it returns window IDs, titles, or other metadata; whether it includes minimized windows; what format the output is in; or any performance considerations. The description is minimal and lacks operational context.

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 a single, concise sentence '列出所有打开的窗口' (List all open windows) that directly states the tool's purpose with zero wasted words. It's appropriately sized and front-loaded for a simple tool.

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?

Given the tool's simplicity (one optional parameter, no output schema, no annotations), the description is incomplete. It doesn't explain what 'list' entails (e.g., returns window titles, IDs, or other properties), how results are structured, or any limitations. For a tool that interacts with system windows, more context on output behavior 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?

The input schema has 100% description coverage, with the single parameter 'filter' documented as '过滤窗口标题(可选)' (Filter window title, optional). The description doesn't add any meaning beyond this, but since schema coverage is high, the baseline score of 3 is appropriate as the schema adequately explains the parameter.

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

Purpose4/5

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

The description '列出所有打开的窗口' (List all open windows) clearly states the verb 'list' and resource 'open windows', making the purpose immediately understandable. It doesn't specifically differentiate from sibling tools like 'get_active_window' or 'activate_window', but the core action is unambiguous.

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?

The description provides no guidance on when to use this tool versus alternatives like 'get_active_window' (which gets only the active window) or 'activate_window' (which activates a specific window). There's no mention of prerequisites, context, or exclusions for usage.

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