Repository navigation
Conversation
This was referenced Oct 6, 2026
zyzyzyryxy
reviewed
Oct 14, 2026
OrKoN
force-pushed
the
cli-uid-url-shorthands
branch
2 times, most recently
from
October 15, 2026 06:56
ea18215 to
64cee66
Compare
zyzyzyryxy
approved these changes
Oct 15, 2026
zyzyzyryxy
left a comment
Contributor
There was a problem hiding this comment.
LGTM codewise, I sent you the eval links to review.
OrKoN
force-pushed
the
cli-uid-url-shorthands
branch
from
October 23, 2026 13:20
64cee66 to
a7aa85f
Compare
Collaborator
Author
|
Closing for now (might revisit later). |
zjdCander
pushed a commit
to zjdCander/chrome-devtools-mcp
that referenced
this pull request
Nov 16, 2026
…romeDevTools#3437) `--browserUrl localhost:9222` (no `http://`) passes validation, so the server starts normally. The first tool call then fails: ``` Could not connect to Chrome. … Cause: Failed to fetch browser webSocket URL from localhost:9222: fetch failed Cause: unknown scheme ``` The equivalent `--browserUrl 127.0.0.1:9222` is rejected at startup with `Provided browserUrl 127.0.0.1:9222 is not valid URL.` The two inputs are equally wrong but fail at different times and in different ways. ## Root cause `src/config/browser-options.ts`, `browserUrl.coerce`, only checks that the value parses as a URL: ```ts try { new URL(url); } catch { throw new Error(`Provided browserUrl ${url} is not valid URL.`); } return url; ``` `new URL('localhost:9222')` succeeds with `protocol === 'localhost:'`. `127.0.0.1:9222` throws only because a scheme can't start with a digit. The browser URL is fetched over HTTP (`<browserUrl>/json/version`) to discover the WebSocket endpoint, so only `http:` and `https:` can ever work. ## Reproduction (1.12.0, Node 24.22.2) Coerce results before the fix: ``` localhost:9222 => localhost:9222 127.0.0.1:9222 ERR Provided browserUrl 127.0.0.1:9222 is not valid URL. http://localhost:9222 => http://localhost:9222 new URL(localhost:9222).protocol = localhost: ``` ## Fix After parsing, require `http:` or `https:`. This mirrors the `ws:`/`wss:` check that `--wsEndpoint` already has a few lines below. With the fix, the server rejects the value at startup and exits 1: ``` $ node out/Default/gen/src/bin/chrome-devtools-mcp.js --browserUrl localhost:9222 Provided browserUrl localhost:9222 must use http:// or https:// protocol. ``` | `--browserUrl` value | Before | After | |---|---|---| | unset / `''` | `undefined` | `undefined` | | `http://127.0.0.1:9222`, `https://example.com:9222`, `http://localhost:9222/` | accepted | accepted | | `localhost:9222` | accepted, fails at first tool call | rejected: must use http(s) | | `ws://127.0.0.1:9222`, `file:///tmp/chrome`, `chrome://inspect` | accepted, fail at first tool call | rejected: must use http(s) | | `127.0.0.1:9222` | rejected: not valid URL | rejected: not valid URL (unchanged) | ## Tests - Added `rejects browser urls without an http or https scheme` to `tests/cli.test.ts`, next to the existing `browserUrl` tests. It calls the option's `coerce` directly, like the viewport test does. - It fails on `main` with `AssertionError: Missing expected exception` (for `localhost:9222`) and passes with the fix. On macOS (Node 24.22.2, `.nvmrc`): - `npm run check-format` passes. - `npm run test:no-build`: 1804 passed, 0 failed, 3 skipped. On `main` it was 1800 passed, 0 failed, 3 skipped. - The difference is the new test plus the 3-test `McpPage logpoints` suite, which ran in this run but not in the `main` run. The change doesn't touch the import block, and it merges cleanly onto ChromeDevTools#2897, which also edits `tests/cli.test.ts`. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Natasha Gorshunova <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds CLI-only shorthands for element uids and URLs. The MCP server, tool schemas, pageId handling, and snapshot output are unchanged.
@<uid>is accepted for uid params:@is stripped:click 1 @1_5is the same asclick 1 1_5.@<uid>fills the first optional uid param that is not set yet:take_screenshot 1 @1_5becomestake_screenshot 1 --uid 1_5.evaluate_script, extra@<uid>args are appended to the element--args.--uid @1_5also works.urlparam:navigate_page 1 https://web.devbecomesnavigate_page 1 --url https://web.dev. Only absolute URLs withhttp,https,file,chrome,chrome-extension,about, ordataschemes count;example.comdoes not.Implementation:
expandShorthandArgs()insrc/config/cli-commands.tsrewrites argv before yargs parses it, so yargs config and strict mode are unchanged. It:take_screenshot 1 --uid 1_4 @1_5still fails with "Unknown argument".@in uid slots, sofill 1 @1_5 @handlekeeps the value@handle.Usage lines show the shorthands (e.g.
take_screenshot <pageId> ... [@uid],navigate_page <pageId> ... [url]), anddocs/cli.mdhas a new "Shorthands" section.The agent tip printed on argument errors now asks for exact command names from
--help, usesclick 1 @1_2as the correct example, and lists the@<uid>and URL shorthands for optional parameters. Unknown commands are not rerouted or auto-corrected.The
chrome-devtools-cliskill (skills/chrome-devtools-cli/SKILL.md) now uses the shorthands in its workflow, usage notes, and examples (e.g.click 1 @1_4,take_screenshot 1 @1_4,navigate_page 1 "https://example.com"). I ran each changed example throughexpandShorthandArgsto check it expands to the expected flags.Manually verified with the built CLI on wikipedia.org:
navigate_page 1 <url>,take_screenshot 1 @uid,evaluate_script ... @uid,fill 1 @uid "@devtools", andclick 1 @uid.