Skip to main content
Glama
cloudflare

Cloudflare Playwright MCP

Official
by cloudflare

browser_console_messages

Read-only

Capture and retrieve console messages for automated browser testing using Playwright. Integrates with Cloudflare Workers for streamlined web navigation and interaction.

Instructions

Returns all console messages

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The handler function that executes the tool logic: retrieves console messages from the current browser tab using context.currentTabOrDie().consoleMessages(), formats them into a newline-separated log string with type prefixes, and returns an action object to display 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,
      };
    },
  • Input/output schema definition for the tool, specifying 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',
    },
  • src/tools.ts:18-37 (registration)
    Imports the console tool module (which exports the browser_console_messages tool) and spreads it into the snapshotTools array for registration.
    import console from './tools/console.js';
    import dialogs from './tools/dialogs.js';
    import files from './tools/files.js';
    import install from './tools/install.js';
    import keyboard from './tools/keyboard.js';
    import navigate from './tools/navigate.js';
    import network from './tools/network.js';
    import pdf from './tools/pdf.js';
    import snapshot from './tools/snapshot.js';
    import tabs from './tools/tabs.js';
    import screenshot from './tools/screenshot.js';
    import testing from './tools/testing.js';
    import vision from './tools/vision.js';
    import wait from './tools/wait.js';
    
    import type { Tool } from './tools/tool.js';
    
    export const snapshotTools: Tool<any>[] = [
      ...common(true),
      ...console,
  • src/tools.ts:54-54 (registration)
    Spreads the console tool (containing browser_console_messages) into the visionTools array for registration.
    ...console,
Behavior3/5

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

Annotations already indicate readOnlyHint=true, destructiveHint=false, and openWorldHint=true, covering safety and scope. The description adds minimal behavioral context beyond this—it implies a retrieval operation but doesn't specify if it returns real-time messages, historical logs, or requires specific browser state. No contradiction with annotations exists, but the description could enhance understanding with details like format or timing.

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, efficient sentence ('Returns all console messages') that directly conveys the core function without unnecessary words. It's front-loaded and wastes no space, making it easy for an agent to parse 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 simplicity (0 parameters, annotations covering safety), the description is adequate but minimal. It lacks output details (no schema provided) and doesn't explain return format or behavior, which could help an agent use it effectively. For a read-only tool with no parameters, it meets basic needs but leaves room for more context.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The input schema has 0 parameters with 100% coverage, so no parameter documentation is needed. The description doesn't add parameter details, which is appropriate here. A baseline of 4 is applied since the schema fully handles parameters, and the description avoids redundancy.

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 differentiate from sibling tools like browser_network_requests or browser_snapshot that also return browser data, missing the specific distinction that this tool focuses on console logs rather than network traffic or visual snapshots.

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 (e.g., not for error handling), or related tools like browser_evaluate for executing scripts that might generate console messages, leaving the agent with minimal context for selection.

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

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