Skip to main content
Glama
devskido

Playwright MCP Server

by devskido

playwright_console_logs

Retrieve and filter browser console logs for debugging web applications. Capture errors, warnings, and other console messages with search and limit options.

Instructions

Retrieve console logs from the browser with filtering options

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
typeNoType of logs to retrieve (all, error, warning, log, info, debug, exception)
searchNoText to search for in logs (handles text with square brackets)
limitNoMaximum number of logs to return
clearNoWhether to clear logs after retrieval (default: false)

Implementation Reference

  • ConsoleLogsTool class containing the handler logic for 'playwright_console_logs'. The 'execute' method filters console logs by type, search term, limit, and optionally clears them.
    export class ConsoleLogsTool extends BrowserToolBase { private consoleLogs: string[] = []; /** * Register a console message * @param type The type of console message * @param text The text content of the message */ registerConsoleMessage(type: string, text: string): void { const logEntry = `[${type}] ${text}`; this.consoleLogs.push(logEntry); } /** * Execute the console logs tool */ async execute(args: any, context: ToolContext): Promise<ToolResponse> { // No need to use safeExecute here as we don't need to interact with the page // We're just filtering and returning logs that are already stored let logs = [...this.consoleLogs]; // Filter by type if specified if (args.type && args.type !== 'all') { logs = logs.filter(log => log.startsWith(`[${args.type}]`)); } // Filter by search text if specified if (args.search) { logs = logs.filter(log => log.includes(args.search)); } // Limit the number of logs if specified if (args.limit && args.limit > 0) { logs = logs.slice(-args.limit); } // Clear logs if requested if (args.clear) { this.consoleLogs = []; } // Format the response if (logs.length === 0) { return createSuccessResponse("No console logs matching the criteria"); } else { return createSuccessResponse([ `Retrieved ${logs.length} console log(s):`, ...logs ]); } } /** * Get all console logs */ getConsoleLogs(): string[] { return this.consoleLogs; } /** * Clear all console logs */ clearConsoleLogs(): void { this.consoleLogs = []; } }
  • Input schema definition for the 'playwright_console_logs' tool in createToolDefinitions().
    { name: "playwright_console_logs", description: "Retrieve console logs from the browser with filtering options", inputSchema: { type: "object", properties: { type: { type: "string", description: "Type of logs to retrieve (all, error, warning, log, info, debug, exception)", enum: ["all", "error", "warning", "log", "info", "debug", "exception"] }, search: { type: "string", description: "Text to search for in logs (handles text with square brackets)" }, limit: { type: "number", description: "Maximum number of logs to return" }, clear: { type: "boolean", description: "Whether to clear logs after retrieval (default: false)" } }, required: [], }, },
  • Switch case in handleToolCall that dispatches to ConsoleLogsTool.execute for 'playwright_console_logs'.
    case "playwright_console_logs": return await consoleLogsTool.execute(args, context);
  • Instantiation of ConsoleLogsTool instance in initializeTools.
    if (!consoleLogsTool) consoleLogsTool = new ConsoleLogsTool(server);
  • Import of ConsoleLogsTool from './tools/browser/index.js'.
    ConsoleLogsTool,

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/devskido/customed-playwright'

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