browser_console_messages
Retrieve and analyze console messages from web pages using Playwright MCP, enabling structured monitoring and debugging of browser interactions without visual dependencies.
Instructions
Returns all console messages
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/tools/console.ts:29-42 (handler)The handler function that retrieves all console messages from the current browser tab, formats them with type prefixes, and returns a tool result with an action to display 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, }; },
- src/tools/console.ts:22-28 (schema)Defines the tool schema including the name 'browser_console_messages', 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/console.ts:46-47 (registration)Registers the tool by exporting it in a default array, which is imported and spread into the main tool lists in src/tools.ts.console, ];