Skip to main content
Glama

emulate_network

Simulate various network conditions like offline mode or throttled speeds (3G/4G) on a Chrome page to test performance and offline behavior.

Instructions

Emulates network conditions such as throttling or offline mode on the selected page.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
throttlingOptionYesThe network throttling option to emulate. Available throttling options are: No emulation, Offline, Slow 3G, Fast 3G, Slow 4G, Fast 4G. Set to "No emulation" to disable. Set to "Offline" to simulate offline network conditions.

Implementation Reference

  • The handler function that executes the network emulation logic by applying Puppeteer network conditions based on the selected throttling option.
    handler: async (request, _response, context) => { const page = context.getSelectedPage(); const conditions = request.params.throttlingOption; if (conditions === 'No emulation') { await page.emulateNetworkConditions(null); context.setNetworkConditions(null); return; } if (conditions === 'Offline') { await page.emulateNetworkConditions({ offline: true, download: 0, upload: 0, latency: 0, }); context.setNetworkConditions('Offline'); return; } if (conditions in PredefinedNetworkConditions) { const networkCondition = PredefinedNetworkConditions[ conditions as keyof typeof PredefinedNetworkConditions ]; await page.emulateNetworkConditions(networkCondition); context.setNetworkConditions(conditions); } },
  • Zod schema defining the input parameter 'throttlingOption' with available enum values.
    schema: { throttlingOption: z .enum(throttlingOptions) .describe( `The network throttling option to emulate. Available throttling options are: ${throttlingOptions.join(', ')}. Set to "No emulation" to disable. Set to "Offline" to simulate offline network conditions.`, ), },
  • The complete tool definition and registration using defineTool, specifying name, description, annotations, schema, and handler.
    export const emulateNetwork = defineTool({ name: 'emulate_network', description: `Emulates network conditions such as throttling or offline mode on the selected page.`, annotations: { category: ToolCategories.EMULATION, readOnlyHint: false, }, schema: { throttlingOption: z .enum(throttlingOptions) .describe( `The network throttling option to emulate. Available throttling options are: ${throttlingOptions.join(', ')}. Set to "No emulation" to disable. Set to "Offline" to simulate offline network conditions.`, ), }, handler: async (request, _response, context) => { const page = context.getSelectedPage(); const conditions = request.params.throttlingOption; if (conditions === 'No emulation') { await page.emulateNetworkConditions(null); context.setNetworkConditions(null); return; } if (conditions === 'Offline') { await page.emulateNetworkConditions({ offline: true, download: 0, upload: 0, latency: 0, }); context.setNetworkConditions('Offline'); return; } if (conditions in PredefinedNetworkConditions) { const networkCondition = PredefinedNetworkConditions[ conditions as keyof typeof PredefinedNetworkConditions ]; await page.emulateNetworkConditions(networkCondition); context.setNetworkConditions(conditions); } }, });
  • Helper constant defining the list of available network throttling options used in the schema enum.
    const throttlingOptions: [string, ...string[]] = [ 'No emulation', 'Offline', ...Object.keys(PredefinedNetworkConditions), ];

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/SHAY5555-gif/chrome-devtools-mcp'

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