Skip to main content
Glama
BrowserGenie

BrowserGenie MCP Server

by BrowserGenie

get_console_logs

Retrieve console logs from web pages to debug JavaScript errors, inspect warnings, and verify code execution. Filter by log level and clear logs after reading.

Instructions

Get all console messages from the page (console.log, console.error, warnings, etc.). Use this to debug JavaScript errors, see what the page is logging, or verify your code is running.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
levelNoFilter logs: "error" for errors only, "warn" for warnings, "all" for everything (default)
clearNoClear all logs after reading so you only get new messages next time
tabIdNoTarget tab ID (defaults to active tab)
apiKeyNoAPI key for authentication if enabled

Implementation Reference

  • The handler function for the 'get_console_logs' tool. Sends a command via WebSocket bridge to the Chrome extension to retrieve console messages, with optional filtering by level and clearing after read.
    async ({ level, clear, tabId, apiKey }) => {
      const result = await bridge.sendCommand({
        command: 'get_console_logs',
        params: { level, clear },
        tabId,
        apiKey,
      });
      if (!result.success) {
        return { content: [{ type: 'text', text: `Error: ${result.error?.message}` }], isError: true };
      }
      return { content: [{ type: 'text', text: JSON.stringify(result.data, null, 2) }] };
    }
  • Zod schema defining the input parameters for 'get_console_logs': level (enum filter), clear (boolean flag), tabId, and apiKey (all optional).
    {
      level: z.enum(['log', 'warn', 'error', 'info', 'debug', 'all']).optional()
        .describe('Filter logs: "error" for errors only, "warn" for warnings, "all" for everything (default)'),
      clear: z.boolean().optional().describe('Clear all logs after reading so you only get new messages next time'),
      tabId: z.number().optional().describe('Target tab ID (defaults to active tab)'),
      apiKey: z.string().optional().describe('API key for authentication if enabled'),
    },
  • Registration of the 'get_console_logs' tool via server.tool() in the registerDevtoolsConsoleTools function. Called from registerAllTools in tools/index.ts.
    server.tool(
      'get_console_logs',
      'Get all console messages from the page (console.log, console.error, warnings, etc.). Use this to debug JavaScript errors, see what the page is logging, or verify your code is running.',
      {
        level: z.enum(['log', 'warn', 'error', 'info', 'debug', 'all']).optional()
          .describe('Filter logs: "error" for errors only, "warn" for warnings, "all" for everything (default)'),
        clear: z.boolean().optional().describe('Clear all logs after reading so you only get new messages next time'),
        tabId: z.number().optional().describe('Target tab ID (defaults to active tab)'),
        apiKey: z.string().optional().describe('API key for authentication if enabled'),
      },
      async ({ level, clear, tabId, apiKey }) => {
        const result = await bridge.sendCommand({
          command: 'get_console_logs',
          params: { level, clear },
          tabId,
          apiKey,
        });
        if (!result.success) {
          return { content: [{ type: 'text', text: `Error: ${result.error?.message}` }], isError: true };
        }
        return { content: [{ type: 'text', text: JSON.stringify(result.data, null, 2) }] };
      }
    );
  • The sendCommand method on WebSocketBridge that the handler calls. Sends the 'get_console_logs' command over WebSocket to the Chrome extension and returns the response.
    async sendCommand(cmd: BridgeCommand): Promise<BridgeResponse> {
      if (!this.isConnected()) {
        return {
          success: false,
          error: {
            code: 'NOT_CONNECTED',
            message: 'Chrome extension is not connected. Ensure the extension is installed, enabled, and the browser is running.',
          },
        };
      }
    
      const id = crypto.randomUUID();
      const timeout = cmd.timeout ?? DEFAULT_TIMEOUT;
    
      return new Promise<BridgeResponse>((resolve, reject) => {
        const timer = setTimeout(() => {
          this.pending.delete(id);
          resolve({
            success: false,
            error: {
              code: 'TIMEOUT',
              message: `Command '${cmd.command}' timed out after ${timeout}ms`,
            },
          });
        }, timeout);
    
        this.pending.set(id, { resolve, reject, timer });
    
        const message = {
          id,
          type: 'request',
          command: cmd.command,
          params: cmd.params,
          tabId: cmd.tabId,
          apiKey: cmd.apiKey,
          timestamp: Date.now(),
        };
    
        this.client!.send(JSON.stringify(message));
      });
    }
Behavior3/5

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

With no annotations, the description bears full transparency burden. It correctly indicates the tool gets console messages but does not disclose whether reading is destructive or if logs persist. The 'clear' parameter hints at one behavior, but the description itself is minimal on side effects.

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 two sentences with zero wasted words. The first sentence states the core functionality, the second provides usage context. Front-loading is optimal.

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

Completeness4/5

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

For a simple retrieval tool with well-documented schema and no output schema, the description is largely complete. It explains what is retrieved and common use cases. Minor gap: it does not specify the return format (e.g., array of objects with fields), but this is acceptable.

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?

Input schema has 100% coverage with detailed descriptions for all parameters. The description adds no new meaning beyond the schema, e.g., it does not elaborate on the 'level' enum values or 'clear' behavior. Baseline 3 is appropriate given high schema coverage.

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

Purpose5/5

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

The description clearly states the tool retrieves console messages, using specific verbs and resource. It distinguishes from sibling tools like get_network_logs and assert_no_console_errors by focusing on console messages.

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

Usage Guidelines4/5

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

The description lists several use cases (debugging JS errors, seeing logs, verifying code) but does not explicitly mention when not to use this tool or provide alternatives. However, the context is clear enough for an agent to infer typical 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/BrowserGenie/mcp'

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