Skip to content

fill/type_text turn a lone - into an empty string and reject other non-numeric values that start with - #2984

Description

@coygeek

Description of the bug

The chrome-devtools CLI cannot pass a text value that starts with a hyphen to fill, type_text, or press_key. A lone - is silently converted to an empty string: fill 1 <uid> - reports Successfully filled out the element and clears the field, type_text 1 - reports Typed text "", and press_key 1 - fails with Key could not be parsed. Any other value beginning with - that is not a number (--weird, -abc, - item) is rejected with Not enough non-option arguments, and neither -- nor --value=... gets it through. The MCP tools accept all of these values. A Markdown list item, a command-line flag string, or a minus key cannot be entered through the CLI, and the - case corrupts input while reporting success. Both tested builds behave the same.

Actual behavior

Observed on both builds, identical output (one fresh run per build in this session, matching an earlier run):

$ chrome-devtools fill 1 1_1 -                  => exit 0   Successfully filled out the element
$ chrome-devtools evaluate_script '...' --pageId 1  => "\"\""   (field value is now empty; it was "x")
$ chrome-devtools type_text 1 -                 => exit 0   Typed text ""
$ chrome-devtools press_key 1 -                 => exit 0   Error: Key  could not be parsed.
$ chrome-devtools fill 1 1_1 --weird            => exit 1   Error: Not enough non-option arguments: got 2, need at least 3
$ chrome-devtools fill 1 1_1 "- item"           => exit 1   Error: Not enough non-option arguments: got 2, need at least 3
$ chrome-devtools fill 1 1_1 -- --weird         => exit 1   Error: Not enough non-option arguments: got 2, need at least 3
$ chrome-devtools fill 1 1_1 --value=--weird    => exit 1   Error: Not enough non-option arguments: got 2, need at least 3
$ chrome-devtools type_text 1 -abc              => exit 1   Error: Not enough non-option arguments: got 1, need at least 2
$ chrome-devtools fill 1 1_1 a-b                => exit 0   (field value "a-b")

Negative numbers such as -5 pass through as text (fill 1 1_1 -5 set the field to "-5"). The MCP control on both builds set the field to "-" and then "--weird", and press_key with "-" returned Successfully pressed key: - and appended - to the field.

Reproduction

In a fresh session (so the first snapshot assigns uid 1_1 to the textarea):

chrome-devtools start --headless --isolated --no-usage-statistics --no-performance-crux
chrome-devtools navigate_page 1 --url 'data:text/html,<textarea id="t">x</textarea>'
chrome-devtools take_snapshot 1                     # uid=1_1 textbox multiline value="x"
chrome-devtools fill 1 1_1 -
chrome-devtools evaluate_script '() => JSON.stringify(document.querySelector("#t").value)' --pageId 1
chrome-devtools type_text 1 -
chrome-devtools press_key 1 -
chrome-devtools fill 1 1_1 --weird
chrome-devtools fill 1 1_1 "- item"
chrome-devtools fill 1 1_1 -- --weird
chrome-devtools fill 1 1_1 --value=--weird
chrome-devtools type_text 1 -abc
chrome-devtools fill 1 1_1 a-b                      # control
chrome-devtools stop

MCP control (either build): with the same page, tools/call fill with {"pageId":1,"uid":"1_1","value":"-"}, then {"pageId":1,"uid":"1_1","value":"--weird"}, then press_key with {"pageId":1,"key":"-"}, reading the value with evaluate_script after each.

Expectation

fill takes value (string, required): "The value to fill in." (docs/tool-reference.md:112), type_text takes text (string, required): "The text to type" (docs/tool-reference.md:172), and press_key takes key (string, required): "A key or a combination" (docs/tool-reference.md:159). The CLI exposes these required parameters as positional arguments, and its own error tip says "Required parameters MUST be passed as positional arguments (without flags)" (src/bin/chrome-devtools.ts:95 on the main build). The CLI should deliver the given string to the tool unchanged, as the MCP server does, or at least offer a documented way to pass such a value; it should never substitute a different value and report success.

MCP configuration

--headless --isolated --no-usage-statistics --no-performance-crux unless the reproduction states otherwise (update checks disabled with CHROME_DEVTOOLS_MCP_NO_UPDATE_CHECKS=1).

Chrome DevTools MCP version

1.10.1 (npm) and main 5ddb0a3 (local build)

Chrome version

154.0.8037.98 (stable)

Node version

v22.23.2

Operating system

macOS 27.0

Environment details

  • chrome-devtools-mcp 1.10.1 from npm (the release build).
  • chrome-devtools-mcp built from main at commit 5ddb0a3 (the main build; its --version still prints 1.10.1).
  • Google Chrome 154.0.8037.98 stable, headless; Node v22.23.2; macOS 27; zsh/bash quoting as shown.
  • CHROME_DEVTOOLS_MCP_NO_UPDATE_CHECKS=1; each build ran in its own fresh --sessionId.

Evidence

  • Expected source: fill, type_text, and press_key parameter docs at docs/tool-reference.md:112, :172, and :159 on the main build (same at tag chrome-devtools-mcp-v1.10.1); the MCP control result for the same values.
  • Failure source: CLI output quoted under Actual behavior, on both builds. Required tool parameters are registered as yargs positionals (src/bin/chrome-devtools.ts:211-222 on the main build).
  • Evidence provenance: observed
  • Local verification: reproduced
  • Reproduction completeness: complete

The full open and closed issue and PR corpus was screened as of 2026-10-06. Closed #2406 concerned hyphenated --chromeArg values lost in daemon argument serialization, a different path. Closed #1896 was about agents misquoting evaluate_script code. Open PR #2897 (CLI @uid and URL shorthands) does not change how dash-leading values are parsed.

Fix check

Failing now: on the fixture page, chrome-devtools fill 1 1_1 - reports success and leaves the textarea value "", and chrome-devtools fill 1 1_1 --weird exits 1 with Not enough non-option arguments. Restored: fill 1 1_1 - sets the value to "-", type_text 1 - types -, press_key 1 - presses the minus key, and a value such as --weird or - item can be filled through a supported CLI form (for example after --) and is read back unchanged with evaluate_script. Controls: fill 1 1_1 a-b and fill 1 1_1 -5 keep setting "a-b" and "-5", unknown option flags such as --pageid are still rejected, and optional flags such as evaluate_script ... --pageId 1 keep working.

Activity

  1. added theissue type on Oct 12, 2026
  2. self-assigned this
    on Oct 13, 2026
  3. added 5 commits that reference this issue on Oct 14, 2026
    3c7c5d6
    0150ac2
    3feb176
    8174523
    e2676c9
  4. added a commit that references this issue on Oct 14, 2026
    9de05ae
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions