Skip to content

Chrome DevTools for coding agents

fix: disable set_logpoints when --no-javascript-evaluation is set (#3415)

Alex Rudenko11fcc596290e
diff --git a/docs/configuration.md b/docs/configuration.md
index 712cb60f..ff7a4400 100644
--- a/docs/configuration.md
+++ b/docs/configuration.md
@@ -210,7 +210,7 @@ The Chrome DevTools MCP server supports the following configuration option:
- **Default:** `true`
- **`--javascriptEvaluation`/ `--javascript-evaluation`**
- Set to false to disable the server entry points for evaluating caller-provided JavaScript: evaluation tools (evaluate_script and slim evaluate) are disabled, the initScript parameter in navigate_page is turned off, and navigating to javascript:, data:, or vbscript: URLs is disallowed. This is not a JavaScript sandbox: page scripts and JavaScript triggered through other permitted browser interactions (e.g. clicks or typing) still run. If --experimentalDevtools is also enabled, the DevTools UI, including the Console that evaluates code in the inspected page, can be automated and is not restricted by this option. The client remains responsible for validating tool calls and parameters.
+ Set to false to disable the server entry points for evaluating caller-provided JavaScript: evaluation tools (evaluate_script, set_logpoints, and slim evaluate) are disabled, the initScript parameter in navigate_page is turned off, and navigating to javascript:, data:, or vbscript: URLs is disallowed. This is not a JavaScript sandbox: page scripts and JavaScript triggered through other permitted browser interactions (e.g. clicks or typing) still run. If --experimentalDevtools is also enabled, the DevTools UI, including the Console that evaluates code in the inspected page, can be automated and is not restricted by this option. The client remains responsible for validating tool calls and parameters.
- **Type:** boolean
- **Default:** `true`
diff --git a/src/config/mcp-options.ts b/src/config/mcp-options.ts
index 16ccb8ef..b116aebd 100644
--- a/src/config/mcp-options.ts
+++ b/src/config/mcp-options.ts
@@ -201,7 +201,7 @@ export const mcpOptions: McpOptions = {
type: 'boolean',
default: true,
describe:
- 'Set to false to disable the server entry points for evaluating caller-provided JavaScript: evaluation tools (evaluate_script and slim evaluate) are disabled, the initScript parameter in navigate_page is turned off, and navigating to javascript:, data:, or vbscript: URLs is disallowed. This is not a JavaScript sandbox: page scripts and JavaScript triggered through other permitted browser interactions (e.g. clicks or typing) still run. If --experimentalDevtools is also enabled, the DevTools UI, including the Console that evaluates code in the inspected page, can be automated and is not restricted by this option. The client remains responsible for validating tool calls and parameters.',
+ 'Set to false to disable the server entry points for evaluating caller-provided JavaScript: evaluation tools (evaluate_script, set_logpoints, and slim evaluate) are disabled, the initScript parameter in navigate_page is turned off, and navigating to javascript:, data:, or vbscript: URLs is disallowed. This is not a JavaScript sandbox: page scripts and JavaScript triggered through other permitted browser interactions (e.g. clicks or typing) still run. If --experimentalDevtools is also enabled, the DevTools UI, including the Console that evaluates code in the inspected page, can be automated and is not restricted by this option. The client remains responsible for validating tool calls and parameters.',
reloadable: true,
},
fileNavigations: {
diff --git a/src/tools/logpoints.ts b/src/tools/logpoints.ts
index 4e03c829..c781fbdc 100644
--- a/src/tools/logpoints.ts
+++ b/src/tools/logpoints.ts
@@ -27,6 +27,7 @@ export const setLogpoints: PageToolFactory = definePageTool(() => ({
annotations: {
category: ToolCategory.DEBUGGING,
readOnlyHint: false,
+ conditions: ['javascriptEvaluation'],
},
schema: {
logpoints: zod
diff --git a/tests/ToolHandler.test.ts b/tests/ToolHandler.test.ts
index e1dd7442..aa35802e 100644
--- a/tests/ToolHandler.test.ts
+++ b/tests/ToolHandler.test.ts
@@ -997,6 +997,48 @@ describe('ToolHandler', () => {
assert.strictEqual(disabledHandler.disabled, true);
});
+ it('disables set_logpoints when javascriptEvaluation is false', async () => {
+ const mockContext = createMockMcpContext();
+
+ const defaultConfig = parseConfig();
+ const defaultTool = createTools(defaultConfig.resolved).find(
+ t => t.name === 'set_logpoints',
+ );
+ if (!defaultTool) {
+ assert.fail('set_logpoints not found');
+ }
+ const defaultHandler = new ToolHandler(
+ defaultTool,
+ defaultConfig,
+ async () => mockContext,
+ sinon.spy(),
+ );
+ assert.strictEqual(defaultHandler.disabled, false);
+
+ const disabledConfig = parseConfig(['--no-javascript-evaluation']);
+ const disabledTool = createTools(disabledConfig.resolved).find(
+ t => t.name === 'set_logpoints',
+ );
+ if (!disabledTool) {
+ assert.fail('set_logpoints not found');
+ }
+ const disabledHandler = new ToolHandler(
+ disabledTool,
+ disabledConfig,
+ async () => mockContext,
+ sinon.spy(),
+ );
+ assert.strictEqual(disabledHandler.disabled, true);
+ const disabledResult = await disabledHandler.handle({logpoints: []});
+ assert.strictEqual(disabledResult.isError, true);
+ assert.match(
+ disabledResult.content[0].type === 'text'
+ ? disabledResult.content[0].text
+ : '',
+ /Tool set_logpoints requires flag --javascriptEvaluation and is currently disabled/,
+ );
+ });
+
describe('slim mode', () => {
function createHandler(toolName: string, argv: string[]) {
const config = parseConfig(argv);