Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 51 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ Chrome DevTools for reliable automation, in-depth debugging, and performance ana
- **Reliable automation**. Uses
[puppeteer](https://github.com/puppeteer/puppeteer) to automate actions in
Chrome and automatically wait for action results.
- **Token-efficient responses** (fork enhancement): Minimize token usage with
snapshot truncation (`maxLength`), CSS selector filtering (`selector`), and
image resizing (`maxWidth`/`maxHeight`). Inspired by
[fast-playwright-mcp](https://github.com/nicobailon/fast-playwright-mcp).

## Disclaimers

Expand Down Expand Up @@ -319,9 +323,55 @@ Check the performance of https://developers.chrome.com

Your MCP client should open the browser and record a performance trace.

> [!NOTE]
> [!NOTE]
> The MCP server will start the browser automatically once the MCP client uses a tool that requires a running browser instance. Connecting to the Chrome DevTools MCP server on its own will not automatically start the browser.

## Token Optimization (Fork Enhancement)

This fork includes token optimization features inspired by [fast-playwright-mcp](https://github.com/nicobailon/fast-playwright-mcp).

### Snapshot Optimization

Use the following parameters with `take_snapshot` to reduce token usage:

**Truncation** - Limit output to a maximum number of characters:

```
Take a snapshot with maxLength of 5000 characters
```

**CSS Selector Filtering** - Focus on a specific part of the page:

```
Take a snapshot with selector "#main-content"
```

The `selector` parameter limits the snapshot to only the subtree rooted at the matching element. This dramatically reduces output size when you only need to inspect a specific component.

### Screenshot Optimization

Use `maxWidth` and `maxHeight` with `take_screenshot` to resize images:

```
Take a screenshot with maxWidth 800 and maxHeight 600
```

Images are resized maintaining aspect ratio (using sharp library). This reduces the base64 payload size significantly, saving tokens when including screenshots in context.

### Additional Parameters

| Tool | Parameter | Description |
| ----------------- | ----------- | ------------------------------------------- |
| `take_snapshot` | `maxLength` | Maximum characters (truncates with notice) |
| `take_snapshot` | `selector` | CSS selector to limit scope |
| `take_snapshot` | `verbose` | Include all a11y tree info (default: false) |
| `take_screenshot` | `maxWidth` | Maximum width in pixels |
| `take_screenshot` | `maxHeight` | Maximum height in pixels |
| `take_screenshot` | `quality` | JPEG/WebP quality 0-100 |
| `take_screenshot` | `format` | png, jpeg, or webp |

See `src/expectation.ts` for the full expectation schema and tool defaults.

## Tools

If you run into any issues, checkout our [troubleshooting guide](./docs/troubleshooting.md).
Expand Down
4 changes: 4 additions & 0 deletions docs/tool-reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,8 @@ so returned values have to JSON-serializable.
- **filePath** (string) _(optional)_: The absolute path, or a path relative to the current working directory, to save the screenshot to instead of attaching it to the response.
- **format** (enum: "png", "jpeg", "webp") _(optional)_: Type of format to save the screenshot as. Default is "png"
- **fullPage** (boolean) _(optional)_: If set to true takes a screenshot of the full page instead of the currently visible viewport. Incompatible with uid.
- **maxHeight** (number) _(optional)_: Maximum height in pixels. Image will be resized (maintaining aspect ratio) if larger. Useful for token efficiency.
- **maxWidth** (number) _(optional)_: Maximum width in pixels. Image will be resized (maintaining aspect ratio) if larger. Useful for token efficiency.
- **quality** (number) _(optional)_: Compression quality for JPEG and WebP formats (0-100). Higher values mean better quality but larger file sizes. Ignored for PNG format.
- **uid** (string) _(optional)_: The uid of an element on the page from the page content snapshot. If omitted takes a pages screenshot.

Expand All @@ -354,6 +356,8 @@ in the DevTools Elements panel (if any).
**Parameters:**

- **filePath** (string) _(optional)_: The absolute path, or a path relative to the current working directory, to save the snapshot to instead of attaching it to the response.
- **maxLength** (number) _(optional)_: Maximum characters for snapshot output. If exceeded, output is truncated with a notice. Useful for token efficiency.
- **selector** (string) _(optional)_: CSS selector to limit snapshot scope. Only the subtree rooted at the matching element will be included. Useful for focusing on specific page sections.
- **verbose** (boolean) _(optional)_: Whether to include all possible information available in the full a11y tree. Default is false.

---
Loading