Skip to main content
Glama

get_network_request

Retrieve detailed network request information by ID or URL for debugging web applications. Provides request headers, response data, and timing metrics to analyze HTTP traffic during browser automation.

Instructions

Get detailed information about a network request by id (recommended). URL lookup is available as a fallback but may match multiple requests.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
formatNoOutput format: text (default) or json (structured data)
idNoThe request ID from list_network_requests (recommended)
urlNoThe URL of the request (fallback, may match multiple requests)

Implementation Reference

  • The handler function that implements the core logic for the 'get_network_request' tool. It retrieves detailed network request information by ID (primary) or URL (fallback), handles errors for missing requests or duplicates, formats output as text or JSON, and applies header truncation.
    export async function handleGetNetworkRequest(args: unknown): Promise<McpToolResponse> { try { const { id, url, format = 'text', } = args as { id?: string; url?: string; format?: 'text' | 'json' }; if (!id && !url) { return errorResponse('id or url required'); } const { getFirefox } = await import('../index.js'); const firefox = await getFirefox(); const requests = await firefox.getNetworkRequests(); let request = null; // Primary path: lookup by ID if (id) { request = requests.find((req) => req.id === id); if (!request) { return errorResponse(`ID ${id} not found`); } } else if (url) { // Fallback: lookup by URL (with collision detection) const matches = requests.filter((req) => req.url === url); if (matches.length === 0) { return errorResponse(`URL not found: ${url}`); } if (matches.length > 1) { const ids = matches.map((req) => req.id).join(', '); return errorResponse(`Multiple matches, use id: ${ids}`); } request = matches[0]; } if (!request) { return errorResponse('Request not found'); } // Format request details - apply header truncation to prevent token overflow const details = { id: request.id, url: request.url, method: request.method, status: request.status ?? null, statusText: request.statusText ?? null, resourceType: request.resourceType ?? null, isXHR: request.isXHR ?? false, timestamp: request.timestamp ?? null, timings: request.timings ?? null, requestHeaders: truncateHeaders(request.requestHeaders), responseHeaders: truncateHeaders(request.responseHeaders), }; if (format === 'json') { return jsonResponse(details); } return successResponse(JSON.stringify(details, null, 2)); } catch (error) { return errorResponse(error instanceof Error ? error : new Error(String(error))); } }
  • The tool schema definition for 'get_network_request', including name, description, and inputSchema for validation of parameters: id (string), url (string fallback), format (text/json).
    export const getNetworkRequestTool = { name: 'get_network_request', description: 'Get request details by ID. URL lookup as fallback.', inputSchema: { type: 'object' as const, properties: { id: { type: 'string', description: 'Request ID from list_network_requests', }, url: { type: 'string', description: 'URL fallback (may match multiple)', }, format: { type: 'string', enum: ['text', 'json'], description: 'Output format (default: text)', }, }, }, };
  • src/index.ts:123-123 (registration)
    Registration of the 'get_network_request' tool handler in the central toolHandlers Map used by the MCP server.
    ['get_network_request', tools.handleGetNetworkRequest],
  • src/index.ts:167-167 (registration)
    Inclusion of the 'get_network_request' tool definition in the allTools array returned by listTools.
    tools.getNetworkRequestTool,

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/freema/firefox-devtools-mcp'

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