Skip to main content
Glama

start_monitoring

Initiate or resume monitoring of browser tabs in Firefox, capturing data types like console logs, errors, network activity, websocket messages, and performance metrics for debugging.

Instructions

Start/restart monitoring for a tab

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
tabIdNo
typesNo

Implementation Reference

  • The handler function that implements the start_monitoring tool. It sets up page monitoring listeners for console, errors, network based on types, injects WebSocket monitoring if requested, and returns a confirmation message.
    async startMonitoring(args) { const { tabId, types = ['console', 'errors', 'network', 'websocket'] } = args; const effectiveTabId = tabId || this.activeTabId; const page = this.getPage(effectiveTabId); if (types.includes('console') || types.includes('errors') || types.includes('network')) { await this.setupPageMonitoring(page, effectiveTabId); } if (types.includes('websocket')) { await this.injectWebSocketMonitoring(page, effectiveTabId); } return { content: [{ type: 'text', text: `Monitoring started for tab '${effectiveTabId}': ${types.join(', ')}` }] }; }
  • Input schema for validating arguments to the start_monitoring tool, defining tabId and optional types array.
    inputSchema: { type: 'object', properties: { tabId: { type: 'string' }, types: { type: 'array', items: { type: 'string', enum: ['console', 'errors', 'network', 'websocket', 'performance'] }, default: ['console', 'errors', 'network', 'websocket'] } } }
  • Registration in the tool dispatch switch statement within the CallToolRequestSchema handler, routing calls to start_monitoring to the startMonitoring method.
    case 'start_monitoring': return await this.startMonitoring(args);
  • Tool registration object in the ListToolsRequestSchema response, defining name, description, and schema for start_monitoring.
    { 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'] } } } },
  • Helper function called by start_monitoring to set up console, JS error, network, and WebSocket monitoring event listeners on the page.
    // Setup monitoring listeners for a page async setupPageMonitoring(page, tabId) { console.error(`Setting up monitoring for tab: ${tabId}`); // Console monitoring 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); }); // JavaScript error monitoring page.on('pageerror', (error) => { const errors = this.jsErrors.get(tabId) || []; errors.push({ message: error.message, stack: error.stack, timestamp: Date.now() }); this.jsErrors.set(tabId, errors); }); // Network monitoring page.on('request', (request) => { const activity = this.networkActivity.get(tabId) || []; activity.push({ type: 'request', url: request.url(), method: request.method(), headers: request.headers(), resourceType: request.resourceType(), timestamp: Date.now() }); this.networkActivity.set(tabId, activity); }); page.on('response', (response) => { const activity = this.networkActivity.get(tabId) || []; activity.push({ type: 'response', url: response.url(), status: response.status(), headers: response.headers(), timestamp: Date.now() }); this.networkActivity.set(tabId, activity); }); // Inject WebSocket monitoring await this.injectWebSocketMonitoring(page, 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