Skip to content

Commit 44a7126

Browse files
authored
Merge branch 'main' into main
2 parents 978540f + 139ce60 commit 44a7126

File tree

7 files changed

+45
-20
lines changed

7 files changed

+45
-20
lines changed

.github/ISSUE_TEMPLATE/01-bug.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
name: Bug report
22
description: File a bug report for chrome-devtools-mcp
33
title: '<short description of the bug>'
4-
labels:
5-
- 'bug'
4+
type: 'Bug'
65
body:
76
- id: description
87
type: textarea

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -336,5 +336,5 @@ Some MCP clients allow sandboxing the MCP server using macOS Seatbelt or Linux
336336
containers. If sandboxes are enabled, `chrome-devtools-mcp` is not able to start
337337
Chrome that requires permissions to create its own sandboxes. As a workaround,
338338
either disable sandboxing for `chrome-devtools-mcp` in your MCP client or use
339-
`--connect-url` to connect to a Chrome instance that you start manually outside
339+
`--browser-url` to connect to a Chrome instance that you start manually outside
340340
of the MCP client sandbox.

docs/tool-reference.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -200,11 +200,11 @@
200200

201201
### `emulate_network`
202202

203-
**Description:** Emulates network conditions such as throttling on the selected page.
203+
**Description:** Emulates network conditions such as throttling or offline mode on the selected page.
204204

205205
**Parameters:**
206206

207-
- **throttlingOption** (enum: "No emulation", "Slow 3G", "Fast 3G", "Slow 4G", "Fast 4G") **(required)**: The network throttling option to emulate. Available throttling options are: No emulation, Slow 3G, Fast 3G, Slow 4G, Fast 4G. Set to "No emulation" to disable.
207+
- **throttlingOption** (enum: "No emulation", "Offline", "Slow 3G", "Fast 3G", "Slow 4G", "Fast 4G") **(required)**: The 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.
208208

209209
---
210210

package-lock.json

Lines changed: 9 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,9 @@
4040
"@modelcontextprotocol/sdk": "1.19.1",
4141
"core-js": "3.45.1",
4242
"debug": "4.4.3",
43-
"puppeteer-core": "24.23.0",
44-
"yargs": "18.0.0"
43+
"puppeteer-core": "^24.23.0",
44+
"yargs": "18.0.0",
45+
"zod": "^3.25.76"
4546
},
4647
"devDependencies": {
4748
"@eslint/js": "^9.35.0",

src/tools/emulation.ts

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,13 @@ import {defineTool} from './ToolDefinition.js';
1212

1313
const throttlingOptions: [string, ...string[]] = [
1414
'No emulation',
15+
'Offline',
1516
...Object.keys(PredefinedNetworkConditions),
1617
];
1718

1819
export const emulateNetwork = defineTool({
1920
name: 'emulate_network',
20-
description: `Emulates network conditions such as throttling on the selected page.`,
21+
description: `Emulates network conditions such as throttling or offline mode on the selected page.`,
2122
annotations: {
2223
category: ToolCategories.EMULATION,
2324
readOnlyHint: false,
@@ -26,7 +27,7 @@ export const emulateNetwork = defineTool({
2627
throttlingOption: z
2728
.enum(throttlingOptions)
2829
.describe(
29-
`The network throttling option to emulate. Available throttling options are: ${throttlingOptions.join(', ')}. Set to "No emulation" to disable.`,
30+
`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.`,
3031
),
3132
},
3233
handler: async (request, _response, context) => {
@@ -39,6 +40,17 @@ export const emulateNetwork = defineTool({
3940
return;
4041
}
4142

43+
if (conditions === 'Offline') {
44+
await page.emulateNetworkConditions({
45+
offline: true,
46+
download: 0,
47+
upload: 0,
48+
latency: 0,
49+
});
50+
context.setNetworkConditions('Offline');
51+
return;
52+
}
53+
4254
if (conditions in PredefinedNetworkConditions) {
4355
const networkCondition =
4456
PredefinedNetworkConditions[

tests/tools/emulation.test.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,21 @@ import {withBrowser} from '../utils.js';
1111

1212
describe('emulation', () => {
1313
describe('network', () => {
14+
it('emulates offline network conditions', async () => {
15+
await withBrowser(async (response, context) => {
16+
await emulateNetwork.handler(
17+
{
18+
params: {
19+
throttlingOption: 'Offline',
20+
},
21+
},
22+
response,
23+
context,
24+
);
25+
26+
assert.strictEqual(context.getNetworkConditions(), 'Offline');
27+
});
28+
});
1429
it('emulates network throttling when the throttling option is valid ', async () => {
1530
await withBrowser(async (response, context) => {
1631
await emulateNetwork.handler(

0 commit comments

Comments
 (0)