Skip to main content
Glama

get_network_activity

Retrieve captured network requests and responses for a Firefox tab, filtered by type (XHR, WebSocket, Fetch) and limited by count. Use this tool to monitor and debug network activity during browser automation.

Instructions

Get captured network requests and responses

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
filterNoall
limitNo
sinceNo
tabIdNo

Implementation Reference

  • The core handler function for the 'get_network_activity' tool. It retrieves network activity from the tab's buffer, applies filters for time (since), type (filter), and limit, then returns a JSON-formatted summary of recent requests and responses.
    async getNetworkActivity(args = {}) { const { tabId, since, filter = 'all', limit = 30 } = args; const effectiveTabId = tabId || this.activeTabId; if (!effectiveTabId || !this.networkActivity.has(effectiveTabId)) { return { content: [{ type: 'text', text: 'No network activity captured for this tab' }] }; } let activity = this.networkActivity.get(effectiveTabId); if (since) { activity = activity.filter(item => item.timestamp >= since); } if (filter !== 'all') { switch (filter) { case 'xhr': activity = activity.filter(item => item.resourceType === 'xhr'); break; case 'websocket': activity = activity.filter(item => item.resourceType === 'websocket'); break; case 'fetch': activity = activity.filter(item => item.resourceType === 'fetch'); break; } } activity = activity.slice(-limit); return { content: [{ type: 'text', text: `Network Activity (${activity.length}):\n` + JSON.stringify(activity, null, 2) }] }; }
  • The input schema defining parameters for the tool: tabId (specific tab), since (timestamp filter), filter (by request type), and limit (max results).
    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 } } }
  • Registration of the 'get_network_activity' tool in the ListToolsRequestSchema response, including name, description, and input schema.
    { 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 } } } },
  • Helper code in setupPageMonitoring that sets up Playwright listeners for 'request' and 'response' events to capture network activity data into the this.networkActivity Map buffer per tab, which the handler then queries.
    // 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); });
  • Dispatch/registration case in the CallToolRequestSchema handler that calls the getNetworkActivity method when the tool is invoked.
    case 'get_network_activity': return await this.getNetworkActivity(args);

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