Skip to main content
Glama
cloudflare

Cloudflare Playwright MCP

Official
by cloudflare

browser_console_messages

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,

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