Skip to content

take_screenshot cannot return screenshots inline when the client requires an empty filePath #2825

Description

@danpiths

Description of the bug

take_screenshot supports returning an image directly in the tool response when filePath is omitted. However, the tool schema exposed to my MCP client marks filePath as required, even though it is optional in chrome-devtools-mcp.

Because the client cannot omit the argument, it sends an empty string:

{
  "pageId": 2,
  "format": "png",
  "fullPage": false,
  "quality": 100,
  "uid": "",
  "filePath": ""
}

Before the screenshot handler can interpret the empty value as “return the screenshot inline,” filesystem validation treats the present empty string as a path. It canonicalizes to the process working directory and fails workspace-root validation:

Access denied: path  (canonical: /Users/dan/code/<...>)
is not within any of the configured workspace roots.

This prevents the inline screenshot path from being used through clients whose generated tool contract requires all parameters.

The upstream source for v1.10.1 declares filePath as optional and the screenshot implementation supports inline attachment when it is absent or empty. The failure appears to happen in file-path validation before the screenshot handler runs.

A possibly related report is #2808, which also concerns workspace-root path validation, but it does not describe this empty optional-path case.

Reproduction

  1. Configure chrome-devtools-mcp and connect it to an existing Chromium-based browser.
  2. Open any page and obtain its pageId with list_pages.
  3. Use a client whose generated take_screenshot tool schema requires filePath.
  4. Call take_screenshot without wanting to save the image, using an empty string because the client does not permit omission:
{
  "pageId": 2,
  "format": "png",
  "fullPage": false,
  "quality": 100,
  "uid": "",
  "filePath": ""
}
  1. Observe that the call fails before taking or returning the screenshot:
Access denied: path  (canonical: /Users/dan/code/<...>)
is not within any of the configured workspace roots.

The same direct-return workflow worked previously: no output path was supplied, and the PNG was attached directly to the tool response.

Expectation

One or both of the following should hold:

  1. filePath remains optional in the tool schema exposed to MCP clients, allowing clients to omit it; and
  2. a present but empty filePath is treated as absent before filesystem-path validation.

When no non-empty filePath is provided, take_screenshot should return the image directly in the MCP tool response.

Filesystem validation should continue to apply when a real output path is supplied.

MCP configuration

Client: Forge Code on macOS.

The active MCP server configuration is:

{
  "mcpServers": {
    "chrome-devtools-2": {
      "command": "sh",
      "args": [
        "-c",
        "f=\"$HOME/Library/Application Support/net.imput.helium/DevToolsActivePort\"; port=$(sed -n 1p \"$f\"); path=$(sed -n 2p \"$f\"); exec npx chrome-devtools-mcp@latest --wsEndpoint \"ws://127.0.0.1:$port$path\""
      ],
      "disable": false
    }
  }
}

The server connects to an already-running Helium browser through the browser's DevToolsActivePort WebSocket endpoint.

Chrome DevTools MCP version

chrome-devtools-mcp 1.10.1

Chrome version

No response

Coding agent version

No response

Model version

No response

Chat log

No response

Node version

No response

Operating system

macOS

Extra checklist

  • I want to provide a PR to fix this bug

Activity

  1. added theissue type on Sep 24, 2026
  2. bickov commented on Sep 25, 2026

    @bickov

    This isn't really a filesystem bug, it's a JSON schema optionality problem. Most tool-calling clients that build args from a strict schema, generated from Zod or OpenAPI rather than hand written, can't omit a declared property, they'll always send something for it, and empty string is the natural default for a string type. So any server that treats an empty string as a real path instead of as absent breaks for every strict client, not just this one. The fix has to happen before path resolution, something like checking filePath && filePath.trim().length > 0 and falling through to the inline-return branch otherwise, same as you'd handle a missing optional param anywhere else. Worth checking if the same canonicalize-then-validate order bites any other optional path param in this server, since it would be the identical failure mode.

  3. added a commit that references this issue on Sep 25, 2026
    adfc1ff
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions