Skip to content

upload_file always fails from the CLI: Expected array, received string at filePaths #2741

Closed

Description

@u9g

Problem

chrome-devtools upload_file <pageId> <uid> <path> always fails, no matter how the paths are passed:

MCP error -32602: Input validation error: Invalid arguments for tool upload_file: Expected array, received string at filePaths

Every form fails — a single path, several paths, --filePaths=x, and repeated --filePaths flags. Reproduced on v1.8.0 and on current main.

Cause

In src/bin/chrome-devtools.ts the yargs command string appends each optional arg as a [--flag] token after the required positionals:

upload_file <pageId> <uid> <filePaths> [--includeSnapshot]

yargs parses each [--flag] token as another optional positional. Since a variadic positional has to be the last one, filePaths can never be variadic, so yargs always hands the daemon a plain string and the tool's z.array(z.string()) schema rejects it. Setting type: 'array' on the positional does not change this.

upload_file is currently the only tool with a required array argument, so it is the only command affected.

Expected

$ chrome-devtools upload_file 2 1_1 /tmp/a.txt /tmp/b.txt
File uploaded from /tmp/a.txt, /tmp/b.txt.

Fix

PR #2668 marks array-typed required args as variadic (<filePaths..>) and moves the [--flag] tokens into the command's usage() line, which is all they were for. --help output is unchanged apart from the .. marker on upload_file.

Activity

  1. added theissue type on Sep 14, 2026
  2. added a commit that references this issue on Sep 17, 2026
    9ab482a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions