Description of the bug
Agent can misunderstand how to use CLI interface properly and struggle with finding a working solution.
In one session I encountered 6 consecutive failed attempts to properly call the tool:
-
Attempt 1 (Bash Syntax Error):
- Tool Call: chrome-devtools evaluate_script --expression '''const mainElement = document.querySelector('main'); ... return oldestDate.toLocaleDateString(...);'''
- Error: /usr/bin/bash: line 2: span)).filter(span => { ... No such file or directory
- Reason: The shell tried to execute the JavaScript code as a bash script because of unescaped parentheses and line breaks.
-
Attempt 2 (Missing Positional Argument):
- Tool Call: chrome-devtools evaluate_script --expression '''const mainElement = document.querySelector('main'); ... return oldestDate.toLocaleDateString(...);'''
- Error: Not enough non-option arguments: got 0, need at least 1
- Reason: The CLI parser expected the script as a positional argument; it treated the code following --expression as a value for an unrecognized flag.
-
Attempt 3 (Missing Positional Argument):
- Tool Call: chrome-devtools evaluate_script --expression "(() => { const dates = []; ... return oldestDate.toLocaleDateString(...); })();"
- Error: Not enough non-option arguments: got 0, need at least 1
- Reason: Similar to Attempt 2, but using double quotes. The parser still failed to identify the required positional argument.
-
Attempt 4 (Unknown CLI Flag):
- Tool Call: chrome-devtools evaluate_script --expression '''(() => { ... })();'''
- Error: Unknown arguments: expression, found.;
- Reason: The CLI explicitly rejected the invented --expression flag.
-
Attempt 5 (JavaScript Syntax Error via Shell):
- Tool Call: chrome-devtools evaluate_script "(() => { const dates = []; ... return oldestDate.getTime(); } else { return -1; } })();"
- Error: Unexpected token ';'
- Reason: The flag was removed, but the shell stripped or misinterpreted characters within the double-quoted string, resulting in invalid JavaScript being delivered to the browser.
-
Attempt 6 (JavaScript Syntax Error via Shell):
- Tool Call: chrome-devtools evaluate_script "(() => { const dateStrings = []; ... return dateStrings; })();"
- Error: Unexpected token ';'
- Reason: Final attempt to pass a complex anonymous function. The shell interpretation again corrupted the JavaScript syntax.
Reproduction
Give the agent access to chrome-devtools CLI. Prompt to run some complex script on the page.
Expectation
Improve CLI error messages or related skill to better instruct agent how to formulate CLI commands. Some ideas:
- Adjust error messages from CLI tool to better inform the agent why it is facing the error, prioritizing "unrecognized flag" error over "missing positional arguments could help. Maybe both issues should be reported at once if possible.
- Provide concrete example of
evaluate_script use in the skill, as this is one of the most commonly used tools.
MCP configuration
No response
Chrome DevTools MCP version
v0.20.1
Chrome version
No response
Coding agent version
gemini-cli
Model version
gemini-2.5-flash
Chat log
No response
Node version
No response
Operating system
None
Extra checklist
Description of the bug
Agent can misunderstand how to use CLI interface properly and struggle with finding a working solution.
In one session I encountered 6 consecutive failed attempts to properly call the tool:
Attempt 1 (Bash Syntax Error):
Attempt 2 (Missing Positional Argument):
Attempt 3 (Missing Positional Argument):
Attempt 4 (Unknown CLI Flag):
Attempt 5 (JavaScript Syntax Error via Shell):
Attempt 6 (JavaScript Syntax Error via Shell):
Reproduction
Give the agent access to chrome-devtools CLI. Prompt to run some complex script on the page.
Expectation
Improve CLI error messages or related skill to better instruct agent how to formulate CLI commands. Some ideas:
evaluate_scriptuse in the skill, as this is one of the most commonly used tools.MCP configuration
No response
Chrome DevTools MCP version
v0.20.1
Chrome version
No response
Coding agent version
gemini-cli
Model version
gemini-2.5-flash
Chat log
No response
Node version
No response
Operating system
None
Extra checklist