Skip to main content
Glama

clear_debug_buffers

Remove stored debug event data such as console logs, errors, network activity, or WebSocket messages for a specific Firefox tab to manage debugging efficiently.

Instructions

Clear debug event buffers for a tab

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
tabIdNo
typesNo

Implementation Reference

  • The main handler function that clears the debug buffers (console logs, JS errors, network activity, WebSocket messages) for a specific tab or all types. Resets the internal Maps/arrays to empty and clears injected page variables.
    async clearDebugBuffers(args = {}) {
      const { tabId, types } = args;
      const effectiveTabId = tabId || this.activeTabId;
      
      if (!types || types.length === 0) {
        // Clear all buffers
        this.consoleLogs.set(effectiveTabId, []);
        this.jsErrors.set(effectiveTabId, []);
        this.networkActivity.set(effectiveTabId, []);
        
        // Clear WebSocket messages
        if (this.pages.has(effectiveTabId)) {
          const page = this.pages.get(effectiveTabId);
          await page.evaluate(() => { window._wsMessages = []; });
        }
      } else {
        // Clear specific buffers
        if (types.includes('console')) this.consoleLogs.set(effectiveTabId, []);
        if (types.includes('errors')) this.jsErrors.set(effectiveTabId, []);
        if (types.includes('network')) this.networkActivity.set(effectiveTabId, []);
        if (types.includes('websocket') && this.pages.has(effectiveTabId)) {
          const page = this.pages.get(effectiveTabId);
          await page.evaluate(() => { window._wsMessages = []; });
        }
      }
    
      return {
        content: [{
          type: 'text',
          text: `Debug buffers cleared for tab '${effectiveTabId}': ${types ? types.join(', ') : 'all'}`
        }]
      };
    }
  • The tool definition including input schema for tabId (optional) and types array to specify which buffers to clear.
    {
      name: 'clear_debug_buffers',
      description: 'Clear debug event buffers for a tab',
      inputSchema: {
        type: 'object',
        properties: {
          tabId: { type: 'string' },
          types: {
            type: 'array',
            items: { type: 'string', enum: ['console', 'errors', 'network', 'websocket'] }
          }
        }
      }
    },
  • Dispatch case in the CallToolRequestSchema handler that routes the tool call to the clearDebugBuffers method.
    case 'clear_debug_buffers':
      return await this.clearDebugBuffers(args);
  • Registration of the tool list including clear_debug_buffers in the ListToolsRequestSchema response.
    this.server.setRequestHandler(ListToolsRequestSchema, async () => {
      return {
        tools: [
          // Original tools (abbreviated for space)
          {
            name: 'launch_firefox_multi',
            description: 'Launch Firefox browser with multi-tab support and debugging',
            inputSchema: {
              type: 'object',
              properties: {
                headless: { type: 'boolean', default: false },
                enableDebugLogging: { type: 'boolean', default: true }
              }
            }
          },
          {
            name: 'create_tab',
            description: 'Create a new tab with isolated session and debugging',
            inputSchema: {
              type: 'object',
              properties: {
                tabId: { type: 'string' },
                url: { type: 'string', default: 'about:blank' },
                contextId: { type: 'string' },
                enableMonitoring: { type: 'boolean', default: true }
              },
              required: ['tabId']
            }
          },
          {
            name: 'list_tabs',
            description: 'List all active tabs',
            inputSchema: { type: 'object', properties: {} }
          },
          {
            name: 'close_tab',
            description: 'Close a specific tab',
            inputSchema: {
              type: 'object',
              properties: { tabId: { type: 'string' } },
              required: ['tabId']
            }
          },
          {
            name: 'navigate',
            description: 'Navigate to a URL',
            inputSchema: {
              type: 'object',
              properties: {
                url: { type: 'string' },
                tabId: { type: 'string' }
              },
              required: ['url']
            }
          },
          {
            name: 'click',
            description: 'Click on an element',
            inputSchema: {
              type: 'object',
              properties: {
                selector: { type: 'string' },
                coordinates: {
                  type: 'object',
                  properties: { x: { type: 'number' }, y: { type: 'number' } }
                },
                tabId: { type: 'string' }
              }
            }
          },
          {
            name: 'type_text',
            description: 'Type text into an input field',
            inputSchema: {
              type: 'object',
              properties: {
                selector: { type: 'string' },
                text: { type: 'string' },
                tabId: { type: 'string' }
              },
              required: ['selector', 'text']
            }
          },
          {
            name: 'send_key',
            description: 'Send keyboard events',
            inputSchema: {
              type: 'object',
              properties: {
                key: { type: 'string' },
                selector: { type: 'string' },
                modifiers: { type: 'array', items: { type: 'string' } },
                repeat: { type: 'number', default: 1 },
                tabId: { type: 'string' }
              },
              required: ['key']
            }
          },
          {
            name: 'drag',
            description: 'Perform drag operation',
            inputSchema: {
              type: 'object',
              properties: {
                selector: { type: 'string' },
                fromCoordinates: {
                  type: 'object',
                  properties: { x: { type: 'number' }, y: { type: 'number' } }
                },
                toCoordinates: {
                  type: 'object',
                  properties: { x: { type: 'number' }, y: { type: 'number' } }
                },
                offsetX: { type: 'number' },
                offsetY: { type: 'number' },
                duration: { type: 'number', default: 0 },
                steps: { type: 'number', default: 1 },
                tabId: { type: 'string' }
              }
            }
          },
          {
            name: 'execute_script',
            description: 'Execute JavaScript in the browser',
            inputSchema: {
              type: 'object',
              properties: {
                script: { type: 'string' },
                tabId: { type: 'string' }
              },
              required: ['script']
            }
          },
          {
            name: 'screenshot',
            description: 'Take a screenshot',
            inputSchema: {
              type: 'object',
              properties: {
                path: { type: 'string', default: 'screenshot.png' },
                fullPage: { type: 'boolean', default: false },
                tabId: { type: 'string' }
              }
            }
          },
          {
            name: 'get_page_content',
            description: 'Get HTML content',
            inputSchema: {
              type: 'object',
              properties: {
                selector: { type: 'string' },
                tabId: { type: 'string' }
              }
            }
          },
          {
            name: 'get_page_text',
            description: 'Get visible text content',
            inputSchema: {
              type: 'object',
              properties: {
                selector: { type: 'string' },
                tabId: { type: 'string' }
              }
            }
          },
          {
            name: 'wait_for_element',
            description: 'Wait for element to appear',
            inputSchema: {
              type: 'object',
              properties: {
                selector: { type: 'string' },
                timeout: { type: 'number', default: 30000 },
                tabId: { type: 'string' }
              },
              required: ['selector']
            }
          },
          {
            name: 'close_browser',
            description: 'Close browser and all tabs',
            inputSchema: { type: 'object', properties: {} }
          },
          {
            name: 'get_current_url',
            description: 'Get current page URL',
            inputSchema: {
              type: 'object',
              properties: { tabId: { type: 'string' } }
            }
          },
          {
            name: 'back',
            description: 'Navigate back',
            inputSchema: {
              type: 'object',
              properties: { tabId: { type: 'string' } }
            }
          },
          {
            name: 'forward',
            description: 'Navigate forward',
            inputSchema: {
              type: 'object',
              properties: { tabId: { type: 'string' } }
            }
          },
          {
            name: 'reload',
            description: 'Reload page',
            inputSchema: {
              type: 'object',
              properties: { tabId: { type: 'string' } }
            }
          },
          {
            name: 'set_active_tab',
            description: 'Set active tab',
            inputSchema: {
              type: 'object',
              properties: { tabId: { type: 'string' } },
              required: ['tabId']
            }
          },
    
          // NEW DEBUG TOOLS
          {
            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' }
              }
            }
          },
          {
            name: 'get_javascript_errors',
            description: 'Get captured JavaScript errors',
            inputSchema: {
              type: 'object',
              properties: {
                tabId: { type: 'string' },
                since: { type: 'number' },
                limit: { type: 'number', default: 20 }
              }
            }
          },
          {
            name: 'get_network_activity',
            description: 'Get captured network requests and responses',
            inputSchema: {
              type: 'object',
              properties: {
                tabId: { type: 'string' },
                since: { type: 'number' },
                filter: { type: 'string', enum: ['all', 'xhr', 'websocket', 'fetch'], default: 'all' },
                limit: { type: 'number', default: 30 }
              }
            }
          },
          {
            name: 'get_websocket_messages',
            description: 'Get captured WebSocket messages (for LiveView debugging)',
            inputSchema: {
              type: 'object',
              properties: {
                tabId: { type: 'string' },
                since: { type: 'number' },
                limit: { type: 'number', default: 50 }
              }
            }
          },
          {
            name: 'get_performance_metrics',
            description: 'Get performance metrics (timing, memory usage)',
            inputSchema: {
              type: 'object',
              properties: {
                tabId: { type: 'string' }
              }
            }
          },
          {
            name: 'start_monitoring',
            description: 'Start/restart monitoring for a tab',
            inputSchema: {
              type: 'object',
              properties: {
                tabId: { type: 'string' },
                types: {
                  type: 'array',
                  items: { type: 'string', enum: ['console', 'errors', 'network', 'websocket', 'performance'] },
                  default: ['console', 'errors', 'network', 'websocket']
                }
              }
            }
          },
          {
            name: 'clear_debug_buffers',
            description: 'Clear debug event buffers for a tab',
            inputSchema: {
              type: 'object',
              properties: {
                tabId: { type: 'string' },
                types: {
                  type: 'array',
                  items: { type: 'string', enum: ['console', 'errors', 'network', 'websocket'] }
                }
              }
            }
          },
          {
            name: 'get_all_debug_activity',
            description: 'Get combined feed of all debug events',
            inputSchema: {
              type: 'object',
              properties: {
                tabId: { type: 'string' },
                since: { type: 'number' },
                limit: { type: 'number', default: 100 }
              }
            }
          },
          {
            name: 'inject_debugging_helpers',
            description: 'Inject debugging helper functions into the page',
            inputSchema: {
              type: 'object',
              properties: {
                tabId: { type: 'string' },
                includeWebSocketMonitoring: { type: 'boolean', default: true }
              }
            }
          }
        ],
      };
    });
  • Helper method to completely delete (not just clear) debug buffers for a tab, used when closing tabs.
    clearTabDebugBuffers(tabId) {
      this.consoleLogs.delete(tabId);
      this.jsErrors.delete(tabId);
      this.networkActivity.delete(tabId);
      this.wsMessages.delete(tabId);
      this.performanceMetrics.delete(tabId);
    }

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