emulate_cpu
Simulate CPU throttling to test web page performance under constrained processing conditions by adjusting execution slowdown factors.
Instructions
Emulates CPU throttling by slowing down the selected page's execution.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| throttlingRate | Yes | The CPU throttling rate representing the slowdown factor 1-20x. Set the rate to 1 to disable throttling |
Implementation Reference
- src/tools/emulation.ts:81-87 (handler)The handler function for the 'emulate_cpu' tool. It retrieves the selected page, extracts the throttlingRate from params, calls page.emulateCPUThrottling(throttlingRate), and sets the CPU throttling rate in context.handler: async (request, _response, context) => { const page = context.getSelectedPage(); const {throttlingRate} = request.params; await page.emulateCPUThrottling(throttlingRate); context.setCpuThrottlingRate(throttlingRate); },
- src/tools/emulation.ts:72-80 (schema)Zod schema for the tool input, defining 'throttlingRate' as a number from 1 to 20, where 1 disables throttling.schema: { throttlingRate: z .number() .min(1) .max(20) .describe( 'The CPU throttling rate representing the slowdown factor 1-20x. Set the rate to 1 to disable throttling', ), },
- src/tools/emulation.ts:65-88 (registration)The tool is defined and exported using defineTool, including name, description, annotations, schema, and handler. This serves as the registration point for the MCP tool.export const emulateCpu = defineTool({ name: 'emulate_cpu', description: `Emulates CPU throttling by slowing down the selected page's execution.`, annotations: { category: ToolCategories.EMULATION, readOnlyHint: false, }, schema: { throttlingRate: z .number() .min(1) .max(20) .describe( 'The CPU throttling rate representing the slowdown factor 1-20x. Set the rate to 1 to disable throttling', ), }, handler: async (request, _response, context) => { const page = context.getSelectedPage(); const {throttlingRate} = request.params; await page.emulateCPUThrottling(throttlingRate); context.setCpuThrottlingRate(throttlingRate); }, });