Skip to main content
Glama
ztobs

Browser Use Server

by ztobs

get_console_logs

Retrieve browser console logs from webpages to debug JavaScript errors, monitor network activity, and analyze client-side performance issues.

Instructions

Get the console logs of a webpage

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
urlYesThe URL to navigate to
stepsNoComma-separated actions or sentences describing steps to take after page load (e.g., "click #submit, scroll down" or "Fill the login form and submit")

Implementation Reference

  • Main execution logic for get_console_logs: validates URL, runs AI agent for navigation and steps, injects JavaScript to override console methods and capture logs in window._consoleLogs, retrieves and returns the logs.
    elif command == 'get_console_logs':
        if not args.get('url'):
            return {
                'success': False,
                'error': 'URL is required for get_console_logs command'
            }
    
        console_messages = []
        def on_console_message(msg):
            console_messages.append(f"type: {msg.type}, text: {msg.text}, location: {msg.location}")
    
        task = f"1. Go to {args['url']}"
        if args.get('steps'):
            steps = args['steps'].split(',')
            for i, step in enumerate(steps, 2):
                task += f"\n{i}. {step.strip()}"
            task += f"\n{len(steps) + 2}. Get the console logs"
        else:
            task += f"\n2. Get the console logs"
        use_vision = os.getenv('USE_VISION', 'false').lower() == 'true'
        agent = Agent(task=task, llm=llm, use_vision=use_vision, browser_context=context)
        await agent.run()
    
        try:
            # Execute JavaScript to get console logs
            await context.execute_javascript("""
                window._consoleLogs = [];
                const originalConsole = window.console;
                ['log', 'info', 'warn', 'error'].forEach(level => {
                    window.console[level] = (...args) => {
                        window._consoleLogs.push({type: level, text: args.join(' ')});
                        originalConsole[level](...args);
                    };
                });
            """)
            
            # Wait a bit for any console logs to be captured
            await asyncio.sleep(1)
            
            # Get the captured logs
            logs = await context.execute_javascript("window._consoleLogs")
            return {
                'success': True,
                'logs': logs
            }
        finally:
            await context.close()
  • Defines the tool schema for 'get_console_logs', including input schema with required 'url' and optional 'steps'.
    {
      name: 'get_console_logs',
      description: 'Get the console logs of a webpage',
      inputSchema: {
        type: 'object',
        properties: {
          url: {
            type: 'string',
            description: 'The URL to navigate to',
          },
          steps: {
            type: 'string',
            description: 'Comma-separated actions or sentences describing steps to take after page load (e.g., "click #submit, scroll down" or "Fill the login form and submit")',
          },
        },
        required: ['url'],
      },
    },
  • src/index.ts:149-233 (registration)
    Registers the 'get_console_logs' tool (among others) in the MCP server's ListTools response, making it discoverable.
    this.server.setRequestHandler(ListToolsRequestSchema, async () => ({
      tools: [
        {
          name: 'screenshot',
          description: 'Take a screenshot of a webpage',
          inputSchema: {
            type: 'object',
            properties: {
              url: {
                type: 'string',
                description: 'The URL to navigate to',
              },
              full_page: {
                type: 'boolean',
                description: 'Whether to capture the full page or just the viewport',
                default: false,
              },
              steps: {
                type: 'string',
                description: 'Comma-separated actions or sentences describing steps to take after page load (e.g., "click #submit, scroll down" or "Fill the login form and submit")',
              },
            },
            required: ['url'],
          },
        },
        {
          name: 'get_html',
          description: 'Get the HTML content of a webpage',
          inputSchema: {
            type: 'object',
            properties: {
              url: {
                type: 'string',
                description: 'The URL to navigate to',
              },
              steps: {
                type: 'string',
                description: 'Comma-separated actions or sentences describing steps to take after page load (e.g., "click #submit, scroll down" or "Fill the login form and submit")',
              },
            },
            required: ['url'],
          },
        },
        {
          name: 'execute_js',
          description: 'Execute JavaScript code on a webpage',
          inputSchema: {
            type: 'object',
            properties: {
              url: {
                type: 'string',
                description: 'The URL to navigate to',
              },
              script: {
                type: 'string',
                description: 'The JavaScript code to execute',
              },
              steps: {
                type: 'string',
                description: 'Comma-separated actions or sentences describing steps to take after page load (e.g., "click #submit, scroll down" or "Fill the login form and submit")',
              },
            },
            required: ['url', 'script'],
          },
        },
        {
          name: 'get_console_logs',
          description: 'Get the console logs of a webpage',
          inputSchema: {
            type: 'object',
            properties: {
              url: {
                type: 'string',
                description: 'The URL to navigate to',
              },
              steps: {
                type: 'string',
                description: 'Comma-separated actions or sentences describing steps to take after page load (e.g., "click #submit, scroll down" or "Fill the login form and submit")',
              },
            },
            required: ['url'],
          },
        },
      ],
    }));
  • MCP CallTool request handler formats and returns the console logs result from the Python backend as text content.
    } else if (request.params.name === 'get_console_logs') {
      return {
        content: [
          {
            type: 'text',
            text: JSON.stringify(result.logs, null, 2),
          },
        ],
      };
    } else {
  • src/index.ts:236-236 (registration)
    Validates that 'get_console_logs' is an allowed tool name in the CallTool handler.
    const validCommands = ['screenshot', 'get_html', 'execute_js', 'get_console_logs'];
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It states what the tool does but lacks critical details: it doesn't specify if this requires browser automation, what types of console logs are captured (e.g., errors, warnings), whether it's a read-only operation, or any limitations like timeouts or authentication needs. This leaves significant gaps in understanding how the tool behaves.

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, clear sentence with zero waste—it directly states the tool's purpose without unnecessary words. It's appropriately sized and front-loaded, making it easy to grasp immediately.

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 complexity of interacting with webpages and the lack of annotations and output schema, the description is incomplete. It doesn't address key contextual aspects like what the tool returns (e.g., log format, error handling), behavioral constraints, or how it differs from siblings. For a tool with two parameters and no structured safety hints, more detail is needed to be fully helpful.

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, clearly documenting both parameters ('url' and 'steps'). The description adds no additional meaning beyond what the schema provides, such as explaining the format of console logs or how steps interact with log capture. Since the schema does the heavy lifting, the baseline score of 3 is appropriate.

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 with a specific verb ('Get') and resource ('console logs of a webpage'), making it immediately understandable. However, it doesn't differentiate from sibling tools like 'execute_js' or 'get_html', which might also interact with webpage content, so it doesn't reach the highest score.

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 'execute_js' (which might execute JavaScript and potentially capture logs) or 'get_html' (which retrieves HTML content). There's no mention of prerequisites, such as whether the webpage needs to be loaded first, or any exclusions.

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/ztobs/cline-browser-use-mcp'

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