Skip to main content
Glama

read_electron_logs

Retrieve and monitor Electron application logs for debugging and behavior analysis. Specify log types, line count, and continuous tailing for real-time insights.

Instructions

Read console logs and output from running Electron applications. Useful for debugging and monitoring app behavior.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
followNoWhether to follow/tail the logs
linesNoNumber of recent lines to read (default: 100)
logTypeNoType of logs to read

Implementation Reference

  • Primary handler function implementing the read_electron_logs tool logic. Connects to Electron via DevTools Protocol for console logs or falls back to system process logs.
    export async function readElectronLogs(
      logType: LogType = 'all',
      lines: number = 100,
      follow: boolean = false,
    ): Promise<string> {
      try {
        logger.info('[MCP] Looking for running Electron applications for log access...');
    
        try {
          const target = await findElectronTarget();
    
          // Connect via WebSocket to get console logs
          if (logType === 'console' || logType === 'all') {
            return await getConsoleLogsViaDevTools(target, lines, follow);
          }
        } catch {
          logger.info('[MCP] No DevTools connection found, checking system logs...');
        }
    
        // Fallback to system logs if DevTools not available
        return await getSystemElectronLogs(lines);
      } catch (error) {
        throw new Error(
          `Failed to read logs: ${error instanceof Error ? error.message : String(error)}`,
        );
      }
    }
  • Zod schema defining the input parameters (logType, lines, follow) for the read_electron_logs tool.
    export const ReadElectronLogsSchema = z.object({
      logType: z
        .enum(['console', 'main', 'renderer', 'all'])
        .optional()
        .describe('Type of logs to read'),
      lines: z.number().optional().describe('Number of recent lines to read (default: 100)'),
      follow: z.boolean().optional().describe('Whether to follow/tail the logs'),
    });
  • src/tools.ts:63-68 (registration)
    Tool registration entry in the tools array, specifying name, description, and input schema for read_electron_logs.
    {
      name: ToolName.READ_ELECTRON_LOGS,
      description:
        'Read console logs and output from running Electron applications. Useful for debugging and monitoring app behavior.',
      inputSchema: zodToJsonSchema(ReadElectronLogsSchema) as ToolInput,
    },
  • Dispatch handler in the main tool switch statement that parses inputs, calls the readElectronLogs function, and formats the MCP response.
    case ToolName.READ_ELECTRON_LOGS: {
      const { logType, lines, follow } = ReadElectronLogsSchema.parse(args);
      const logs = await readElectronLogs(logType, lines);
    
      if (follow) {
        return {
          content: [
            {
              type: 'text',
              text: `Following logs (${logType}). This is a snapshot of recent logs:\n\n${logs}`,
            },
          ],
          isError: false,
        };
      }
    
      return {
        content: [
          {
            type: 'text',
            text: `Electron logs (${logType}):\n\n${logs}`,
          },
        ],
        isError: false,
      };
    }
  • Helper function to retrieve console logs via Chrome DevTools Protocol WebSocket connection.
    async function getConsoleLogsViaDevTools(
      target: any,
      lines: number,
      follow: boolean,
    ): Promise<string> {
      const logs: string[] = [];
    
      return new Promise((resolve, reject) => {
        (async () => {
          try {
            const ws = await connectForLogs(target, (log: string) => {
              logs.push(log);
              if (logs.length >= lines && !follow) {
                ws.close();
                resolve(logs.slice(-lines).join('\n'));
              }
            });
    
            // For non-follow mode, try to get console history first
            if (!follow) {
              // Request console API calls from Runtime
              ws.send(
                JSON.stringify({
                  id: 99,
                  method: 'Runtime.evaluate',
                  params: {
                    expression: `console.log("Reading console history for MCP test"); "History checked"`,
                    includeCommandLineAPI: true,
                  },
                }),
              );
    
              // Wait longer for logs to be captured and history to be available
              setTimeout(() => {
                ws.close();
                resolve(logs.length > 0 ? logs.slice(-lines).join('\n') : 'No console logs available');
              }, 7000); // Increased timeout to 7 seconds
            }
          } catch (error) {
            reject(error);
          }
        })();
      });
    }
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 of behavioral disclosure. It mentions the tool is for 'debugging and monitoring,' which suggests read-only behavior, but doesn't explicitly state whether it's safe, requires permissions, has rate limits, or details the output format. For a tool with no annotations, this leaves significant gaps in understanding its operational traits.

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 concise and well-structured, consisting of two sentences that directly address purpose and usage without any wasted words. It is front-loaded with the core function and efficiently adds context, making it easy to parse and understand quickly.

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 moderate complexity (3 parameters, no output schema, no annotations), the description is minimally adequate. It covers the purpose and hints at usage but lacks details on behavioral aspects like safety, permissions, or output format. Without annotations or an output schema, more context would be beneficial, but it meets a basic threshold for completeness.

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 clear documentation for all parameters ('follow', 'lines', 'logType'), including an enum for 'logType'. The description adds no additional parameter information beyond what the schema provides. According to the rules, with high schema coverage (>80%), the baseline score is 3 when no param info is added in the description.

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: 'Read console logs and output from running Electron applications.' It specifies the verb ('Read') and resource ('console logs and output from running Electron applications'), making the function evident. However, it doesn't explicitly distinguish this tool from its siblings (e.g., 'get_electron_window_info' or 'send_command_to_electron'), which would be needed for a score of 5.

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 provides some usage context by stating it's 'Useful for debugging and monitoring app behavior,' which implies when to use it. However, it doesn't offer explicit guidance on when to choose this tool over alternatives (e.g., vs. 'get_electron_window_info' for window info or 'send_command_to_electron' for commands), nor does it mention any exclusions or prerequisites, keeping it at an implied level.

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