Skip to content

feat: support allowedUrlPattern & blockedUrlPattern Options#2037

Open
nattallius wants to merge 11 commits into
mainfrom
add-blocklist-and-allowlist-options
Open

feat: support allowedUrlPattern & blockedUrlPattern Options#2037
nattallius wants to merge 11 commits into
mainfrom
add-blocklist-and-allowlist-options

Conversation

@nattallius
Copy link
Copy Markdown
Contributor

No description provided.

@nattallius nattallius requested a review from OrKoN May 11, 2026 19:10
@nattallius nattallius force-pushed the add-blocklist-and-allowlist-options branch from b5eca0f to 788efce Compare May 11, 2026 19:16
Comment thread src/bin/chrome-devtools-mcp-cli-options.ts Outdated
Comment thread src/bin/chrome-devtools-mcp-cli-options.ts Outdated
Comment thread src/bin/chrome-devtools-mcp-cli-options.ts
@nattallius nattallius force-pushed the add-blocklist-and-allowlist-options branch from f537e11 to 998d4be Compare May 18, 2026 11:04
Comment thread tests/security_policies.test.ts Outdated
},
{
blockedUrlPattern: [server.getRoute('/blocked.html')],
executablePath: process.env.CHROME_M149_EXECUTABLE_PATH,
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

block list should not need M149, right?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, it also fails if runs against stable

@nattallius nattallius force-pushed the add-blocklist-and-allowlist-options branch from 703ef62 to eab8536 Compare May 18, 2026 12:36
Comment thread tests/network_blocking.test.ts Outdated
},
{
blockedUrlPattern: [server.getRoute('/blocked.html')],
executablePath: process.env.CHROME_M149_EXECUTABLE_PATH,
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

blocklist should not need M149?

@nattallius nattallius changed the title feat: Implement url allowlist and blocklist feat: Support allowedUrlPattern & blockedUrlPattern Options May 18, 2026
@OrKoN OrKoN force-pushed the add-blocklist-and-allowlist-options branch from b90f3a7 to 57c0f95 Compare May 19, 2026 09:41
@nattallius nattallius changed the title feat: Support allowedUrlPattern & blockedUrlPattern Options feat: support allowedUrlPattern & blockedUrlPattern Options May 19, 2026
@nattallius nattallius force-pushed the add-blocklist-and-allowlist-options branch from 57c0f95 to 6f1034f Compare June 2, 2026 07:33
Copy link
Copy Markdown
Collaborator

@Lightning00Blade Lightning00Blade left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM with some small comment and questions.

Comment thread scripts/test.mjs
});
}

const chromePath = _installChrome('149.0.7827.14');
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need this this is already stable https://chromestatus.com/roadmap
And that is the version pinned by Puppeteer.

Comment thread src/McpContext.ts
await page.emulateNetworkConditions(networkCondition);
newSettings.networkConditions = options.networkConditions;
// Skip network emulation if blocklist/allowlist is configured, as it is rejected by Puppeteer.
if (!this.#options.hasNetworkBlockOrAllowlist) {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we throw if we try to set emulation? Reason is I try to emulate network conditions and this just silently ignores it, an LLM most likely will be confused.

Comment thread tests/browser.test.ts
await fetch(url);
return 'SUCCESS';
} catch (err) {
return err instanceof Error ? err.message : String(err);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: We can just return true or false as the message may change.

Comment thread tests/browser.test.ts

it(
'blocks URLs not in allowlist',
{skip: 'Requires Chrome 149 or greater'},
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this also still needed?

Comment thread tests/cli.test.ts
[
'node',
'main.js',
'--blocked-url-pattern=https://a.com/*',
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you double check if '--blocked-url-pattern', '<pattern-1>', <pattern-2> works? I think that is also valid CLI args.

function: `async () => {
try {
await fetch("${blockedUrl}");
return 'SUCCESS';
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here. we can use true/false.

);
},
{
blockedUrlPattern: [server.getRoute('/blocked.html')],
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was confusingly at the end we should move it to the start, some where easier to find.

},
{
allowedUrlPattern: [server.getRoute('/allowed.html')],
executablePath: process.env.CHROME_M149_EXECUTABLE_PATH,
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants