Skip to main content
Glama

browser_console_messages

Retrieve all console messages from a web page using Playwright MCP, enabling monitoring and debugging of browser activity for automation tasks.

Instructions

Returns all console messages

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The handler function that executes the tool logic: fetches all console messages from the current browser tab, formats them as '[TYPE] message' lines, and returns an action providing the formatted 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, no input parameters (empty Zod schema), and read-only access type.
    schema: { name: 'browser_console_messages', title: 'Get console messages', description: 'Returns all console messages', inputSchema: z.object({}), type: 'readOnly', },
  • Tool registration using defineTool, which combines schema and handler, and default export as an array for inclusion in main tools lists.
    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, }; }, }); export default [ console, ];
  • src/tools.ts:36-52 (registration)
    Main registration where the console tool (imported as 'console') is included in the snapshotTools export array for browser automation tools.
    export const snapshotTools: Tool<any>[] = [ ...common(true), ...console, ...dialogs(true), ...files(true), ...install, ...keyboard(true), ...navigate(true), ...network, ...pdf, ...screenshot, ...snapshot, ...tabs(true), ...testing, ...video, ...wait(true), ];
  • src/tools.ts:54-69 (registration)
    Additional registration including the console tool in the visionTools export array.
    export const visionTools: Tool<any>[] = [ ...common(false), ...console, ...dialogs(false), ...files(false), ...install, ...keyboard(false), ...navigate(false), ...network, ...pdf, ...tabs(false), ...testing, ...video, ...vision, ...wait(false), ];

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