-
Notifications
You must be signed in to change notification settings - Fork 962
feat: add default screenshot format configuration and update readme.md docs #591
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
e6fb135
be931d0
225694d
b5e211f
c231bad
dc92aac
3f65e76
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -383,6 +383,12 @@ The Chrome DevTools MCP server supports the following configuration option: | |
| - **Type:** boolean | ||
| - **Default:** `true` | ||
|
|
||
| - **`--screenshot-format`** | ||
| Default image format for screenshots. Options: png, jpeg, webp. Default is png. | ||
| - **Type:** string | ||
| - **Choices:** `png`, `jpeg`, `webp` | ||
| - **Default:** `png` | ||
|
|
||
| <!-- END AUTO GENERATED OPTIONS --> | ||
|
|
||
| Pass them via the `args` property in the JSON configuration. For example: | ||
|
|
@@ -424,6 +430,36 @@ You can connect directly to a Chrome WebSocket endpoint and include custom heade | |
|
|
||
| To get the WebSocket endpoint from a running Chrome instance, visit `http://127.0.0.1:9222/json/version` and look for the `webSocketDebuggerUrl` field. | ||
|
|
||
| ### Configuring default screenshot format | ||
|
|
||
| You can set a default image format for all screenshots using the `--screenshot-format` option. The default is PNG. You can change it to JPEG or WebP if needed: | ||
|
|
||
| ```json | ||
| { | ||
| "mcpServers": { | ||
| "chrome-devtools": { | ||
| "command": "npx", | ||
| "args": [ | ||
| "chrome-devtools-mcp@latest", | ||
| "--screenshot-format=jpeg" | ||
| ] | ||
| } | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| When configured, the `take_screenshot` tool will use this format by default unless explicitly overridden by passing a `format` parameter. Supported formats are `png`, `jpeg`, and `webp`. | ||
|
|
||
| > [!TIP] | ||
| > PNG is the default format as it provides lossless screenshots. JPEG typically produces smaller file sizes than PNG, which improves performance when working with screenshots. WebP offers the best compression while maintaining quality. | ||
|
|
||
| > [!NOTE] | ||
| > **Claude Code users**: If you experience issues with screenshots not displaying correctly, you can work around this by: | ||
|
||
| > 1. Setting the default format to JPEG in your configuration (recommended): Add `--screenshot-format=jpeg` to your MCP server args | ||
| > 2. Explicitly passing `jpeg` as the format parameter in all `take_screenshot()` calls: `take_screenshot(format="jpeg")` | ||
| > | ||
| > This workaround is needed until the issue is resolved on Claude Code's side. | ||
|
|
||
| You can also run `npx chrome-devtools-mcp@latest --help` to see all available configuration options. | ||
|
|
||
| ## Concepts | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -160,6 +160,13 @@ export const cliOptions = { | |
| default: true, | ||
| describe: 'Set to false to exclude tools related to network.', | ||
| }, | ||
| screenshotFormat: { | ||
| type: 'string', | ||
| describe: | ||
| 'Default image format for screenshots. Options: png, jpeg, webp. Default is png.', | ||
|
||
| choices: ['png', 'jpeg', 'webp'] as const, | ||
| default: 'png', | ||
| }, | ||
| } satisfies Record<string, YargsOptions>; | ||
|
|
||
| export function parseArguments(version: string, argv = process.argv) { | ||
|
|
@@ -212,6 +219,10 @@ export function parseArguments(version: string, argv = process.argv) { | |
| 'Disable tools in the performance category', | ||
| ], | ||
| ['$0 --no-category-network', 'Disable tools in the network category'], | ||
| [ | ||
| '$0 --screenshot-format jpeg', | ||
| 'Set default screenshot format to JPEG (overrides PNG default)', | ||
| ], | ||
| ]); | ||
|
|
||
| return yargsInstance | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we need an explicit example in the readme, let's remove it and rely on the CLI docs and
--helpexamples.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done