Skip to main content
Glama

inspect_network_requests

Analyze network traffic and API calls for a specific URL to monitor requests, identify issues, and examine headers.

Instructions

network|API calls|check requests|network|API calls|check requests|network traffic - Inspect network requests

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
urlYesURL to inspect
filterTypeNoRequest type filter
includeHeadersNoInclude request/response headers

Implementation Reference

  • The core handler function that uses Puppeteer to launch a headless browser, navigate to the specified URL, intercept network requests and responses, filter by type, compute statistics, and return a compact summary of network activity including failures and timings.
    export async function inspectNetworkRequests(args: { url: string; filterType?: string; includeHeaders?: boolean }): Promise<ToolResult> {
      const { url: inspectUrl, filterType = 'all', includeHeaders = false } = args;
      
      try {
        // Get browser launch options with proper executable path
        const launchOptions = getBrowserLaunchOptions();
        const browser = await puppeteer.launch(launchOptions);
        const page = await browser.newPage();
        
        const networkRequests: Array<{
          id: string;
          url: string;
          method: string;
          type: string;
          status?: number;
          statusText?: string;
          responseTime: number;
          size: number;
          timestamp: string;
          failed?: boolean;
          headers?: {
            request?: Record<string, string>;
            response?: Record<string, string>;
          };
        }> = [];
        
        let requestId = 0;
        const requestTimings = new Map<string, number>();
        
        // Capture network requests
        page.on('request', request => {
          const startTime = Date.now();
          const id = `req_${String(requestId++).padStart(3, '0')}`;
          const requestUrl = request.url();
          
          requestTimings.set(requestUrl, startTime);
          
          networkRequests.push({
            id,
            url: requestUrl,
            method: request.method(),
            type: request.resourceType(),
            responseTime: 0,
            size: 0,
            timestamp: new Date().toISOString(),
            headers: includeHeaders ? {
              request: request.headers()
            } : undefined
          });
        });
        
        page.on('response', async response => {
          const requestUrl = response.url();
          const request = networkRequests.find(req => req.url === requestUrl);
          const startTime = requestTimings.get(requestUrl);
          
          if (request) {
            request.status = response.status();
            request.statusText = response.statusText();
            request.responseTime = startTime ? Date.now() - startTime : 0;
            request.failed = !response.ok();
            
            if (includeHeaders && request.headers) {
              request.headers.response = response.headers();
            }
            
            // Estimate response size
            try {
              const buffer = await response.buffer();
              request.size = buffer.length;
            } catch {
              request.size = 0;
            }
          }
        });
        
        page.on('requestfailed', request => {
          const requestUrl = request.url();
          const failedRequest = networkRequests.find(req => req.url === requestUrl);
          if (failedRequest) {
            failedRequest.failed = true;
            failedRequest.status = 0;
            failedRequest.statusText = request.failure()?.errorText || 'Failed';
          }
        });
        
        // Navigate to URL and wait for network to be idle
        await page.goto(inspectUrl, { waitUntil: 'networkidle0', timeout: 30000 });
        
        // Wait a bit for any remaining requests
        await new Promise(resolve => setTimeout(resolve, 2000));
        
        await browser.close();
      
      const filteredRequests = networkRequests.filter(req => {
        switch (filterType) {
          case 'xhr':
            return req.type === 'xhr';
          case 'fetch':
            return req.type === 'fetch';
          case 'websocket':
            return req.type === 'websocket';
          case 'failed':
            return req.failed || (req.status !== undefined && req.status >= 400);
          default:
            return true;
        }
      });
      
      const networkInspectionResult = {
        action: 'inspect_network_requests',
        url: inspectUrl,
        filterType,
        includeHeaders,
        requests: filteredRequests,
        summary: {
          totalRequests: filteredRequests.length,
          successful: filteredRequests.filter(r => r.status !== undefined && r.status >= 200 && r.status < 300).length,
          failed: filteredRequests.filter(r => r.failed || (r.status !== undefined && r.status >= 400)).length,
          averageResponseTime: filteredRequests.reduce((sum, r) => sum + r.responseTime, 0) / filteredRequests.length,
          totalDataTransferred: filteredRequests.reduce((sum, r) => sum + r.size, 0),
          requestTypes: {
            xhr: filteredRequests.filter(r => r.type === 'xhr').length,
            fetch: filteredRequests.filter(r => r.type === 'fetch').length,
            websocket: filteredRequests.filter(r => r.type === 'websocket').length
          }
        },
        status: 'success'
      };
      
      // Compact summary format
      const failed = filteredRequests.filter(r => r.failed || (r.status !== undefined && r.status >= 400));
      const errorSummary = failed.length > 0
        ? `\nErrors: ${failed.slice(0, 3).map(r => `${r.method} ${new URL(r.url).pathname} (${r.status})`).join(', ')}${failed.length > 3 ? ` +${failed.length - 3}` : ''}`
        : '';
    
      return {
        content: [{
          type: 'text',
          text: `${networkInspectionResult.summary.totalRequests} reqs | ${networkInspectionResult.summary.successful} OK, ${networkInspectionResult.summary.failed} fail | Avg: ${networkInspectionResult.summary.averageResponseTime.toFixed(0)}ms | ${(networkInspectionResult.summary.totalDataTransferred / 1024).toFixed(1)}KB${errorSummary}`
        }]
      };
      } catch (error) {
        const errorMessage = error instanceof Error ? error.message : 'Unknown error';
        const helpMessage = errorMessage.includes('Chrome') ? 
          '\n\nTroubleshooting:\n1. Install Chrome: https://www.google.com/chrome/\n2. Or set CHROME_PATH environment variable\n3. Or install puppeteer instead of puppeteer-core' : '';
        return {
          content: [{ type: 'text', text: `Error inspecting network requests: ${errorMessage}${helpMessage}` }]
        };
      }
    }
  • The ToolDefinition schema specifying the tool name, description, input schema with url (required), optional filterType and includeHeaders, and annotations.
    export const inspectNetworkRequestsDefinition: ToolDefinition = {
      name: 'inspect_network_requests',
      description: 'network|API calls|check requests|network|API calls|check requests|network traffic - Inspect network requests',
      inputSchema: {
        type: 'object',
        properties: {
          url: { type: 'string', description: 'URL to inspect' },
          filterType: { type: 'string', description: 'Request type filter', enum: ['all', 'xhr', 'fetch', 'websocket', 'failed'] },
          includeHeaders: { type: 'boolean', description: 'Include request/response headers' }
        },
        required: ['url']
      },
      annotations: {
        title: 'Inspect Network Requests',
        audience: ['user', 'assistant']
      }
    };
  • src/index.ts:632-633 (registration)
    Registration in the main tool dispatch switch statement within executeToolCall function, mapping the tool name to its handler execution.
    case 'inspect_network_requests':
      return await inspectNetworkRequests(args as any) as CallToolResult;
  • src/index.ts:122-122 (registration)
    Added to the tools array for MCP listTools capability, making the tool discoverable.
    inspectNetworkRequestsDefinition,
  • src/index.ts:51-51 (registration)
    Import statement bringing in the handler and definition for use in the server.
    import { inspectNetworkRequests, inspectNetworkRequestsDefinition } from './tools/browser/inspectNetworkRequests.js';
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Annotations only provide a title, so the description carries full burden. It fails to disclose key behavioral traits: whether this is a read-only operation, if it requires specific permissions, what the output looks like (e.g., real-time monitoring vs. historical analysis), or any side effects. The vague 'inspect' doesn't clarify if it passively observes or actively intercepts requests. No contradictions with annotations exist, but the description adds minimal value beyond the title.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness2/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is poorly structured and repetitive ('network|API calls|check requests' appears multiple times), wasting space without adding clarity. It's not front-loaded with key information; instead, it's a jumbled list of synonyms. While brief, it fails to be concise in a useful way—each repetition doesn't earn its place, making it inefficient rather than succinct.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's complexity (3 parameters, no output schema, minimal annotations), the description is inadequate. It doesn't explain what 'inspect' entails operationally, what the tool returns, or how it integrates with the broader context of sibling tools. Without output schema or rich annotations, the description should provide more context on behavior and results, but it falls short, leaving significant gaps for an AI agent.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema fully documents parameters (url, filterType, includeHeaders). The description adds no meaning beyond this—it doesn't explain how parameters interact (e.g., how filterType applies to the URL) or provide usage examples. Baseline 3 is appropriate as the schema does the heavy lifting, but the description doesn't compensate with any additional insights.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose2/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description is tautological, essentially repeating the tool name with slight variations ('network|API calls|check requests|network traffic - Inspect network requests'). It doesn't specify what 'inspect' means operationally (e.g., monitoring, logging, analyzing) or what resource is being inspected beyond the vague 'network requests'. While it mentions 'network traffic', it doesn't clearly distinguish this from sibling tools like 'monitor_console_logs'.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines1/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention any context, prerequisites, or exclusions. Given sibling tools like 'monitor_console_logs' that might overlap in monitoring functionality, the lack of differentiation is a significant gap. There's no indication of when this tool is appropriate or what problems it solves.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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/ssdeanx/ssd-ai'

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