Skip to main content
Glama

analyze_network_requests

Analyze network requests from web pages to identify API calls, track resource loading, and monitor data transfers for development and debugging purposes.

Instructions

Analyze all network requests made by a web page

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
urlYesURL to analyze
timeoutNoAnalysis timeout in milliseconds

Implementation Reference

  • Handler logic for the 'analyze_network_requests' tool: extracts URL and timeout parameters, invokes APIScraper.analyzeNetworkRequests, formats and returns the list of network requests with key details.
    case 'analyze_network_requests': { const url = params.url as string; const timeout = params.timeout as number; const requests = await apiScraper.analyzeNetworkRequests(url, { timeout }); return { total: requests.length, requests: requests.map((r) => ({ url: r.url, method: r.method, status: r.status, type: r.type, responseTime: r.responseTime, })), }; }
  • Input schema definition specifying required 'url' parameter and optional 'timeout' for the analyze_network_requests tool.
    inputSchema: { type: 'object', properties: { url: { type: 'string', description: 'URL to analyze', }, timeout: { type: 'number', description: 'Analysis timeout in milliseconds', default: 30000, }, }, required: ['url'], },
  • Registration of the 'analyze_network_requests' tool in the apiDiscoveryTools array, including name, description, and input schema.
    { name: 'analyze_network_requests', description: 'Analyze all network requests made by a web page', inputSchema: { type: 'object', properties: { url: { type: 'string', description: 'URL to analyze', }, timeout: { type: 'number', description: 'Analysis timeout in milliseconds', default: 30000, }, }, required: ['url'], }, },
  • Core helper method in APIScraper class that uses Playwright to launch a browser, navigate to the URL, monitor all network requests and responses, capture details like URL, method, status, type, and response time.
    async analyzeNetworkRequests(url: string, options?: { timeout?: number }): Promise<NetworkRequest[]> { if (!Validators.isValidUrl(url)) { throw new Error('Invalid URL'); } const browser = await this.getBrowser(); const page = await browser.newPage(); const requests: NetworkRequest[] = []; const startTime = Date.now(); try { page.on('request', (request) => { requests.push({ url: request.url(), method: request.method(), status: 0, statusText: '', headers: request.headers(), requestHeaders: request.headers(), }); }); page.on('response', (response) => { const request = requests.find((r) => r.url === response.url()); if (request) { request.status = response.status(); request.statusText = response.statusText(); request.type = response.headers()['content-type'] || ''; request.responseTime = Date.now() - startTime; } }); await page.goto(url, { waitUntil: 'networkidle', timeout: options?.timeout || 30000, }); await page.waitForTimeout(2000); return requests; } finally { await page.close(); } }

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/code-alchemist01/development-tools-mcp-Server'

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