Skip to main content
Glama
jomon003

PlayMCP Browser Automation Server

by jomon003

getNetworkRequests

Retrieve all network requests made by a web page during automation, enabling monitoring of API calls, resource loading, and traffic analysis for web scraping and testing workflows.

Instructions

Get network requests made by the page

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The core handler function in PlaywrightController that initializes empty requests array and sets up 'request' and 'response' event listeners on the page to capture URL, method, and status of network requests.
    async getNetworkRequests(): Promise<Array<{url: string, method: string, status?: number}>> { try { if (!this.isInitialized() || !this.state.page) { throw new Error('Browser not initialized'); } this.log('Getting network requests'); const requests: Array<{url: string, method: string, status?: number}> = []; // Listen to request events this.state.page.on('request', request => { requests.push({ url: request.url(), method: request.method() }); }); this.state.page.on('response', response => { const request = requests.find(req => req.url === response.url()); if (request) { request.status = response.status(); } }); this.log('Network requests retrieved'); return requests; } catch (error: any) { console.error('Get network requests error:', error); throw new BrowserError('Failed to get network requests', 'Network monitoring error'); } }
  • Defines the MCP tool schema: name, description, and input schema (empty object, no required parameters).
    const GET_NETWORK_REQUESTS_TOOL: Tool = { name: "getNetworkRequests", description: "Get network requests made by the page", inputSchema: { type: "object", properties: {}, required: [] } };
  • src/server.ts:545-545 (registration)
    Registers the getNetworkRequests tool in the tools dictionary, which is provided to the MCP server's capabilities.
    getNetworkRequests: GET_NETWORK_REQUESTS_TOOL,
  • src/server.ts:906-911 (registration)
    In the callTool request handler, the switch case that calls playwrightController.getNetworkRequests() and returns the result as JSON text content.
    case 'getNetworkRequests': { const requests = await playwrightController.getNetworkRequests(); return { content: [{ type: "text", text: JSON.stringify(requests, null, 2) }] }; }

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/jomon003/PlayMCP'

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