Skip to main content
Glama
lewisvoncken

Playwright MCP

by lewisvoncken

browser_console_messages

Read-only

Retrieve console messages from web pages to debug JavaScript errors, warnings, and logs during browser automation with Playwright.

Instructions

Returns all console messages

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
levelNoLevel of the console messages to return. Each level includes the messages of more severe levels. Defaults to "info".info

Implementation Reference

  • Executes the tool logic: retrieves console messages from the current browser tab, formats them as a log string, and prepares an action to return the log as text content.
    handle: async context => {
      const messages = context.currentTabOrDie().consoleMessages();
      const log = messages.map(message => `[${message.type().toUpperCase()}] ${message.text()}`).join('\n');
      return {
        code: [`// <internal code to get console messages>`],
        action: async () => {
          return {
            content: [{ type: 'text', text: log }]
          };
        },
        captureSnapshot: false,
        waitForNetwork: false,
      };
    },
  • Defines the tool's schema including name, title, description, empty input schema (no parameters), and readOnly type.
    schema: {
      name: 'browser_console_messages',
      title: 'Get console messages',
      description: 'Returns all console messages',
      inputSchema: z.object({}),
      type: 'readOnly',
    },
  • Exports the defined tool for registration in the MCP tools system.
    export default [
      console,
    ];
  • Defines the tool using defineTool, which likely handles the registration with name 'browser_console_messages'.
    const console = defineTool({
      capability: 'core',
      schema: {
        name: 'browser_console_messages',
        title: 'Get console messages',
        description: 'Returns all console messages',
        inputSchema: z.object({}),
        type: 'readOnly',
      },
      handle: async context => {
        const messages = context.currentTabOrDie().consoleMessages();
        const log = messages.map(message => `[${message.type().toUpperCase()}] ${message.text()}`).join('\n');
        return {
          code: [`// <internal code to get console messages>`],
          action: async () => {
            return {
              content: [{ type: 'text', text: log }]
            };
          },
          captureSnapshot: false,
          waitForNetwork: false,
        };
      },
    });
Behavior3/5

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

Annotations provide readOnlyHint=true, destructiveHint=false, and openWorldHint=true, indicating a safe, read-only operation with potential for varied data. The description adds minimal behavioral context beyond this—it specifies 'all console messages' but doesn't detail format, pagination, or real-time vs. cached retrieval. Since annotations cover safety, the description earns a baseline score for not contradicting them, though it could offer more operational insight.

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 'Returns all console messages' is a single, front-loaded sentence with zero waste—it directly states the core function without fluff. It's appropriately sized for a simple tool, making it easy for an agent to parse quickly and efficiently.

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 low complexity (1 optional parameter), high schema coverage (100%), and annotations covering safety, the description is minimally adequate. However, without an output schema, it doesn't explain return values (e.g., message format, timestamps), leaving a gap. For a read-only tool with good annotations, it's passable but could be more informative about results.

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?

Schema description coverage is 100%, with the 'level' parameter fully documented in the schema (enum, default, description). The description adds no parameter-specific information beyond implying retrieval of messages, which the schema already covers. This meets the baseline of 3, as the schema handles parameter semantics adequately without extra description input.

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 'Returns all console messages' clearly states the verb ('Returns') and resource ('console messages'), making the purpose understandable. However, it doesn't explicitly differentiate from sibling tools like browser_network_requests or browser_run_code, which also retrieve browser data but different types. The title annotation 'Get console messages' reinforces this, but the description itself lacks sibling distinction.

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. It doesn't mention prerequisites (e.g., needing an active browser session), exclusions, or comparisons to siblings like browser_network_requests for network logs. Without such context, an agent might struggle to choose appropriately among the many browser-related tools.

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/lewisvoncken/playwright-mcp'

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