Skip to main content
Glama
jomon003

PlayMCP Browser Automation Server

by jomon003

getConsoleMessages

Extract and retrieve console messages from a browser for debugging, monitoring, or logging purposes using Playwright-based automation on the PlayMCP server.

Instructions

Get console messages from the browser

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The core handler function that sets up a listener for console events on the Playwright page and collects formatted console messages.
    async getConsoleMessages(): Promise<string[]> { try { if (!this.isInitialized() || !this.state.page) { throw new Error('Browser not initialized'); } this.log('Getting console messages'); const messages: string[] = []; // Listen to console events this.state.page.on('console', msg => { messages.push(`[${msg.type().toUpperCase()}] ${msg.text()}`); }); // Return collected messages this.log('Console messages retrieved'); return messages; } catch (error: any) { console.error('Get console messages error:', error); throw new BrowserError('Failed to get console messages', 'Browser console monitoring error'); } }
  • Defines the tool's metadata including name, description, and input schema (no parameters required).
    const GET_CONSOLE_MESSAGES_TOOL: Tool = { name: "getConsoleMessages", description: "Get console messages from the browser", inputSchema: { type: "object", properties: {}, required: [] } };
  • src/server.ts:544-544 (registration)
    Registers the getConsoleMessages tool in the server's tools dictionary.
    getConsoleMessages: GET_CONSOLE_MESSAGES_TOOL,
  • src/server.ts:555-565 (registration)
    Registers the tools dictionary (including getConsoleMessages) with the MCP server via capabilities.
    const server = new Server( { name: "playmcp-browser", version: "1.0.0", }, { capabilities: { tools, }, } );
  • Dispatches incoming tool calls to the controller's getConsoleMessages method and formats the response.
    case 'getConsoleMessages': { const messages = await playwrightController.getConsoleMessages(); return { content: [{ type: "text", text: JSON.stringify(messages, null, 2) }] }; }

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/jomon003/PlayMCP'

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