inject_debugging_helpers
Inject debugging helper functions into Firefox tabs to enable advanced debugging and WebSocket monitoring, enhancing testing and automation workflows.
Instructions
Inject debugging helper functions into the page
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| includeWebSocketMonitoring | No | ||
| tabId | No |
Implementation Reference
- index-multi-debug.js:892-962 (handler)The primary handler function for the 'inject_debugging_helpers' tool. It injects JavaScript code into the browser page to override console methods for logging capture, add global error and promise rejection handlers, and expose helper functions like getDebugLogs() and getWSMessages() for debugging.async injectDebuggingHelpers(args = {}) { const { tabId, includeWebSocketMonitoring = true } = args; const effectiveTabId = tabId || this.activeTabId; const page = this.getPage(effectiveTabId); // Inject comprehensive debugging helpers await page.evaluate(() => { // Enhanced console capture window._debugLogs = window._debugLogs || []; if (!window._originalConsole) { window._originalConsole = { log: console.log, error: console.error, warn: console.warn, info: console.info, debug: console.debug }; ['log', 'error', 'warn', 'info', 'debug'].forEach(method => { console[method] = function(...args) { window._debugLogs.push({ type: method, args: args, timestamp: Date.now(), stack: new Error().stack }); window._originalConsole[method].apply(console, args); }; }); } // Helper functions window.getDebugLogs = () => JSON.stringify(window._debugLogs, null, 2); window.clearDebugLogs = () => window._debugLogs = []; window.getWSMessages = () => JSON.stringify(window._wsMessages || [], null, 2); window.clearWSMessages = () => window._wsMessages = []; // Global error handler if (!window._errorHandlerInstalled) { window.addEventListener('error', (event) => { window._debugLogs.push({ type: 'uncaught-error', message: event.message, filename: event.filename, lineno: event.lineno, colno: event.colno, error: event.error ? event.error.toString() : null, timestamp: Date.now() }); }); window.addEventListener('unhandledrejection', (event) => { window._debugLogs.push({ type: 'unhandled-promise-rejection', reason: event.reason ? event.reason.toString() : 'Unknown', timestamp: Date.now() }); }); window._errorHandlerInstalled = true; } }); return { content: [{ type: 'text', text: `Debugging helpers injected into tab '${effectiveTabId}'. Use window.getDebugLogs(), window.getWSMessages(), etc.` }] }; }
- index-multi-debug.js:377-386 (registration)Registration of the 'inject_debugging_helpers' tool in the MCP server's listTools response, defining its name, description, and input schema.name: 'inject_debugging_helpers', description: 'Inject debugging helper functions into the page', inputSchema: { type: 'object', properties: { tabId: { type: 'string' }, includeWebSocketMonitoring: { type: 'boolean', default: true } } } }
- index-multi-debug.js:379-384 (schema)Input schema for the 'inject_debugging_helpers' tool, specifying parameters tabId (string) and includeWebSocketMonitoring (boolean, default true).inputSchema: { type: 'object', properties: { tabId: { type: 'string' }, includeWebSocketMonitoring: { type: 'boolean', default: true } }
- index-multi-debug.js:455-456 (registration)Dispatch case in the CallToolRequestSchema handler that routes calls to the injectDebuggingHelpers method.case 'inject_debugging_helpers': return await this.injectDebuggingHelpers(args);