Skip to main content
Glama

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
NameRequiredDescriptionDefault
limitNoMax number of logs to return
sinceNoTimestamp to filter logs since
tabIdNo
typesNoFilter by log types

Implementation Reference

  • 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) }] }; }
  • 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' } } } },
  • Dispatch case in the CallToolRequest handler that routes calls to the getConsoleLogs method.
    case 'get_console_logs': return await this.getConsoleLogs(args);
  • 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); });
  • Declaration of the consoleLogs Map that stores log events per tabId, used by getConsoleLogs.
    this.consoleLogs = new Map(); // tabId -> array of log events

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/JediLuke/firefox-mcp-server'

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