Skip to main content
Glama

get_electron_window_info

Retrieve details about running Electron applications and their windows, including child windows, by leveraging remote debugging on port 9222. Ideal for automation and debugging workflows.

Instructions

Get information about running Electron applications and their windows. Automatically detects any Electron app with remote debugging enabled (port 9222).

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
includeChildrenNoInclude child windows information

Implementation Reference

  • Core handler function that implements the tool logic: scans common DevTools ports for Electron apps, fetches window targets, filters DevTools windows optionally, gathers process info, and returns comprehensive window information.
    export async function getElectronWindowInfo(
      includeChildren: boolean = false,
    ): Promise<ElectronWindowResult> {
      try {
        const foundApps = await scanForElectronApps();
    
        if (foundApps.length === 0) {
          return {
            platform: process.platform,
            windows: [],
            totalTargets: 0,
            electronTargets: 0,
            message: 'No Electron applications found with remote debugging enabled',
            automationReady: false,
          };
        }
    
        // Use the first found app
        const app = foundApps[0];
        const windows: WindowInfo[] = app.targets.map((target: any) => ({
          id: target.id,
          title: target.title,
          url: target.url,
          type: target.type,
          description: target.description || '',
          webSocketDebuggerUrl: target.webSocketDebuggerUrl,
        }));
    
        // Get additional process information
        const processInfo = await getElectronProcessInfo();
    
        return {
          platform: process.platform,
          devToolsPort: app.port,
          windows: includeChildren
            ? windows
            : windows.filter((w: WindowInfo) => !w.title.includes('DevTools')),
          totalTargets: windows.length,
          electronTargets: windows.length,
          processInfo,
          message: `Found running Electron application with ${windows.length} windows on port ${app.port}`,
          automationReady: true,
        };
      } catch (error) {
        logger.error('Failed to scan for applications:', error);
        return {
          platform: process.platform,
          windows: [],
          totalTargets: 0,
          electronTargets: 0,
          message: `Failed to scan for Electron applications: ${
            error instanceof Error ? error.message : String(error)
          }`,
          automationReady: false,
        };
      }
    }
  • Zod schema defining the input parameters for the tool, specifically the optional 'includeChildren' boolean flag.
    export const GetElectronWindowInfoSchema = z.object({
      includeChildren: z.boolean().optional().describe('Include child windows information'),
    });
  • src/tools.ts:20-25 (registration)
    Tool registration in the exported tools array, specifying the tool name, description, and JSON schema for MCP protocol compliance.
    {
      name: ToolName.GET_ELECTRON_WINDOW_INFO,
      description:
        'Get information about running Electron applications and their windows. Automatically detects any Electron app with remote debugging enabled (port 9222).',
      inputSchema: zodToJsonSchema(GetElectronWindowInfoSchema) as ToolInput,
    },
  • src/handlers.ts:26-60 (registration)
    Dispatch handler in the main tool call switch statement that validates input, performs security checks, invokes the core handler, and formats the response for MCP.
    case ToolName.GET_ELECTRON_WINDOW_INFO: {
      // This is a low-risk read operation - basic validation only
      const { includeChildren } = GetElectronWindowInfoSchema.parse(args);
    
      const securityResult = await securityManager.executeSecurely({
        command: 'get_window_info',
        args,
        sourceIP,
        userAgent,
        operationType: 'window_info',
      });
    
      if (securityResult.blocked) {
        return {
          content: [
            {
              type: 'text',
              text: `Operation blocked: ${securityResult.error}`,
            },
          ],
          isError: true,
        };
      }
    
      const result = await getElectronWindowInfo(includeChildren);
      return {
        content: [
          {
            type: 'text',
            text: `Window Information:\n\n${JSON.stringify(result, null, 2)}`,
          },
        ],
        isError: false,
      };
    }
  • Supporting helper function that scans common DevTools ports (9222+) for running Electron apps by fetching /json endpoints.
    export async function scanForElectronApps(): Promise<ElectronAppInfo[]> {
      logger.debug('Scanning for running Electron applications...');
    
      // Extended port range to include test apps and common custom ports
      const commonPorts = [
        9222,
        9223,
        9224,
        9225, // Default ports
        9200,
        9201,
        9202,
        9203,
        9204,
        9205, // Security test range
        9300,
        9301,
        9302,
        9303,
        9304,
        9305, // Integration test range
        9400,
        9401,
        9402,
        9403,
        9404,
        9405, // Additional range
      ];
      const foundApps: ElectronAppInfo[] = [];
    
      for (const port of commonPorts) {
        try {
          const response = await fetch(`http://localhost:${port}/json`, {
            signal: AbortSignal.timeout(1000),
          });
    
          if (response.ok) {
            const targets = await response.json();
            const pageTargets = targets.filter((target: any) => target.type === 'page');
    
            if (pageTargets.length > 0) {
              foundApps.push({
                port,
                targets: pageTargets,
              });
              logger.debug(`Found Electron app on port ${port} with ${pageTargets.length} windows`);
            }
          }
        } catch {
          // Continue to next port
        }
      }
    
      return foundApps;
    }
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 discloses that the tool automatically detects apps with remote debugging on port 9222, which is useful behavioral context. However, it lacks details on permissions needed, rate limits, error handling, or what specific information is returned (e.g., window titles, IDs, states). For a tool with no annotations, this leaves significant gaps in understanding its behavior.

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 appropriately sized and front-loaded: the first sentence states the core purpose, and the second adds crucial context about automatic detection. Both sentences earn their place by providing essential information without redundancy or fluff, making it efficient and well-structured.

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

Completeness3/5

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

Given the tool's complexity (detecting apps and retrieving window info), no annotations, no output schema, and 1 parameter with full schema coverage, the description is moderately complete. It covers the what and how (automatic detection on port 9222) but lacks details on return values, error cases, or integration with sibling tools. It's adequate as a starting point but has clear gaps for effective agent use.

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 1 parameter with 100% description coverage, so the schema already documents 'includeChildren' as a boolean to include child windows. The description does not add any parameter-specific details beyond what the schema provides, such as examples or implications of setting it true/false. With high schema coverage, the baseline is 3, and the description does not compensate with extra semantic value.

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 clearly states the tool's purpose: 'Get information about running Electron applications and their windows.' It specifies the verb ('Get information') and resource ('running Electron applications and their windows'), and distinguishes from sibling tools like read_electron_logs or send_command_to_electron by focusing on window info rather than logs or commands. However, it doesn't explicitly differentiate from take_screenshot, which might also involve window info, keeping it from a perfect score.

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

Usage Guidelines3/5

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

The description implies usage by stating it 'Automatically detects any Electron app with remote debugging enabled (port 9222),' which suggests when to use it (when such apps are running). However, it lacks explicit guidance on when to use this tool vs. alternatives like read_electron_logs for logs or take_screenshot for visual data, and does not mention any exclusions or prerequisites beyond the debugging requirement.

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

Related 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/halilural/electron-mcp-server'

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