Skip to main content
Glama

get_console_logs

Retrieve browser console logs with filtering by level and optional clearing. Designed for AI-assisted web automation on the AutoProbeMCP server using Playwright.

Instructions

Get console logs from the browser

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
clearNoClear console logs after retrieving
levelNoFilter logs by level

Implementation Reference

  • The handler for the get_console_logs tool. Parses parameters, filters console logs by optional level, optionally clears the log array, formats the logs with timestamps and levels, and returns them as text content.
    case 'get_console_logs': { if (!currentPage) { throw new Error('No browser page available. Launch a browser first.'); } const params = GetConsoleLogsSchema.parse(args); // Filter logs by level if specified const filteredLogs = params.level ? consoleLogs.filter(log => log.level === params.level) : consoleLogs; // Clear logs if requested if (params.clear) { consoleLogs = []; } const logText = filteredLogs.length > 0 ? filteredLogs.map(log => `[${log.timestamp.toISOString()}] ${log.level.toUpperCase()}: ${log.message}`).join('\n') : '(no console logs)'; return { content: [ { type: 'text', text: `Console Logs:\n${logText}` } ] }; }
  • Zod schema defining input parameters for get_console_logs tool: optional 'level' to filter logs, and 'clear' boolean to clear logs after retrieval.
    const GetConsoleLogsSchema = z.object({ level: z.enum(['log', 'info', 'warn', 'error', 'debug']).optional(), clear: z.boolean().default(false) });
  • src/index.ts:295-313 (registration)
    Registration of the get_console_logs tool in the listTools handler, including name, description, and input schema definition.
    { name: 'get_console_logs', description: 'Get console logs from the browser', inputSchema: { type: 'object', properties: { level: { type: 'string', enum: ['log', 'info', 'warn', 'error', 'debug'], description: 'Filter logs by level' }, clear: { type: 'boolean', default: false, description: 'Clear console logs after retrieving' } } } },
  • Global array storing captured console logs with level, message, and timestamp.
    let consoleLogs: Array<{level: string, message: string, timestamp: Date}> = [];
  • Playwright page event listener that captures console messages and stores them in the global consoleLogs array. Set up during browser launch.
    currentPage.on('console', (msg) => { consoleLogs.push({ level: msg.type(), message: msg.text(), timestamp: new Date() }); });

Other Tools

Related Tools

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/Wladastic/AutoProbeMCP'

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