get_console_logs
Retrieve captured browser console logs from Firefox MCP Server, filtered by type, timestamp, and quantity, for efficient debugging and automation tasks.
Instructions
Get captured console logs from browser
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| limit | No | Max number of logs to return | |
| since | No | Timestamp to filter logs since | |
| tabId | No | ||
| types | No | Filter by log types |
Implementation Reference
- index-multi-debug.js:662-691 (handler)The core handler function for the 'get_console_logs' tool. Retrieves console logs from the tab's buffer, applies filters (tabId, since timestamp, log types, limit), and returns formatted JSON output.async getConsoleLogs(args = {}) { const { tabId, since, types, limit = 50 } = args; const effectiveTabId = tabId || this.activeTabId; if (!effectiveTabId || !this.consoleLogs.has(effectiveTabId)) { return { content: [{ type: 'text', text: 'No console logs available for this tab' }] }; } let logs = this.consoleLogs.get(effectiveTabId); // Filter by timestamp if (since) { logs = logs.filter(log => log.timestamp >= since); } // Filter by types if (types && types.length > 0) { logs = logs.filter(log => types.includes(log.type)); } // Limit results logs = logs.slice(-limit); return { content: [{ type: 'text', text: `Console Logs (${logs.length}):\n` + JSON.stringify(logs, null, 2) }] }; }
- index-multi-debug.js:272-287 (registration)Tool registration in the ListTools response, defining the name, description, and input schema for validation.name: 'get_console_logs', description: 'Get captured console logs from browser', inputSchema: { type: 'object', properties: { tabId: { type: 'string' }, since: { type: 'number', description: 'Timestamp to filter logs since' }, types: { type: 'array', items: { type: 'string', enum: ['log', 'error', 'warn', 'info', 'debug'] }, description: 'Filter by log types' }, limit: { type: 'number', default: 50, description: 'Max number of logs to return' } } } },
- index-multi-debug.js:439-440 (registration)Dispatch case in the CallToolRequest handler that routes calls to the getConsoleLogs method.case 'get_console_logs': return await this.getConsoleLogs(args);
- index-multi-debug.js:490-499 (helper)Event listener setup in setupPageMonitoring that captures Playwright 'console' events and populates the consoleLogs Map for each tab.page.on('console', (msg) => { const logs = this.consoleLogs.get(tabId) || []; logs.push({ type: msg.type(), text: msg.text(), location: msg.location(), timestamp: Date.now() }); this.consoleLogs.set(tabId, logs); });
- index-multi-debug.js:33-33 (helper)Declaration of the consoleLogs Map that stores log events per tabId, used by getConsoleLogs.this.consoleLogs = new Map(); // tabId -> array of log events