Skip to content

Commit bebd8b1

Browse files
semikolonclaude
andcommitted
docs: regenerate tool reference with new parameters
- maxWidth, maxHeight for take_screenshot - maxLength, selector for take_snapshot - Format fixes from prettier Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 03652e3 commit bebd8b1

7 files changed

Lines changed: 68 additions & 47 deletions

File tree

README.md

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -335,11 +335,13 @@ This fork includes token optimization features inspired by [fast-playwright-mcp]
335335
Use the following parameters with `take_snapshot` to reduce token usage:
336336

337337
**Truncation** - Limit output to a maximum number of characters:
338+
338339
```
339340
Take a snapshot with maxLength of 5000 characters
340341
```
341342

342343
**CSS Selector Filtering** - Focus on a specific part of the page:
344+
343345
```
344346
Take a snapshot with selector "#main-content"
345347
```
@@ -358,15 +360,15 @@ Images are resized maintaining aspect ratio (using sharp library). This reduces
358360

359361
### Additional Parameters
360362

361-
| Tool | Parameter | Description |
362-
|------|-----------|-------------|
363-
| `take_snapshot` | `maxLength` | Maximum characters (truncates with notice) |
364-
| `take_snapshot` | `selector` | CSS selector to limit scope |
365-
| `take_snapshot` | `verbose` | Include all a11y tree info (default: false) |
366-
| `take_screenshot` | `maxWidth` | Maximum width in pixels |
367-
| `take_screenshot` | `maxHeight` | Maximum height in pixels |
368-
| `take_screenshot` | `quality` | JPEG/WebP quality 0-100 |
369-
| `take_screenshot` | `format` | png, jpeg, or webp |
363+
| Tool | Parameter | Description |
364+
| ----------------- | ----------- | ------------------------------------------- |
365+
| `take_snapshot` | `maxLength` | Maximum characters (truncates with notice) |
366+
| `take_snapshot` | `selector` | CSS selector to limit scope |
367+
| `take_snapshot` | `verbose` | Include all a11y tree info (default: false) |
368+
| `take_screenshot` | `maxWidth` | Maximum width in pixels |
369+
| `take_screenshot` | `maxHeight` | Maximum height in pixels |
370+
| `take_screenshot` | `quality` | JPEG/WebP quality 0-100 |
371+
| `take_screenshot` | `format` | png, jpeg, or webp |
370372

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

docs/tool-reference.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -340,6 +340,8 @@ so returned values have to JSON-serializable.
340340
- **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.
341341
- **format** (enum: "png", "jpeg", "webp") _(optional)_: Type of format to save the screenshot as. Default is "png"
342342
- **fullPage** (boolean) _(optional)_: If set to true takes a screenshot of the full page instead of the currently visible viewport. Incompatible with uid.
343+
- **maxHeight** (number) _(optional)_: Maximum height in pixels. Image will be resized (maintaining aspect ratio) if larger. Useful for token efficiency.
344+
- **maxWidth** (number) _(optional)_: Maximum width in pixels. Image will be resized (maintaining aspect ratio) if larger. Useful for token efficiency.
343345
- **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.
344346
- **uid** (string) _(optional)_: The uid of an element on the page from the page content snapshot. If omitted takes a pages screenshot.
345347

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

356358
- **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.
359+
- **maxLength** (number) _(optional)_: Maximum characters for snapshot output. If exceeded, output is truncated with a notice. Useful for token efficiency.
360+
- **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.
357361
- **verbose** (boolean) _(optional)_: Whether to include all possible information available in the full a11y tree. Default is false.
358362

359363
---

src/expectation.ts

Lines changed: 33 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@ export const snapshotOptionsSchema = zod
1818
selector: zod
1919
.string()
2020
.optional()
21-
.describe('CSS selector to limit snapshot scope (e.g., ".main-content", "form")'),
21+
.describe(
22+
'CSS selector to limit snapshot scope (e.g., ".main-content", "form")',
23+
),
2224
maxLength: zod
2325
.number()
2426
.optional()
@@ -61,30 +63,34 @@ export const imageOptionsSchema = zod
6163
* Schema for expectation configuration that controls response content.
6264
* All options default to false for maximum token efficiency.
6365
*/
64-
export const expectationSchema = zod.object({
65-
includeSnapshot: zod
66-
.boolean()
67-
.optional()
68-
.default(false)
69-
.describe('Include accessibility tree snapshot (false saves ~40% tokens)'),
70-
includeConsole: zod
71-
.boolean()
72-
.optional()
73-
.default(false)
74-
.describe('Include console messages'),
75-
includeNetwork: zod
76-
.boolean()
77-
.optional()
78-
.default(false)
79-
.describe('Include network requests'),
80-
includeTabs: zod
81-
.boolean()
82-
.optional()
83-
.default(false)
84-
.describe('Include tab/page information'),
85-
snapshotOptions: snapshotOptionsSchema,
86-
imageOptions: imageOptionsSchema,
87-
}).optional();
66+
export const expectationSchema = zod
67+
.object({
68+
includeSnapshot: zod
69+
.boolean()
70+
.optional()
71+
.default(false)
72+
.describe(
73+
'Include accessibility tree snapshot (false saves ~40% tokens)',
74+
),
75+
includeConsole: zod
76+
.boolean()
77+
.optional()
78+
.default(false)
79+
.describe('Include console messages'),
80+
includeNetwork: zod
81+
.boolean()
82+
.optional()
83+
.default(false)
84+
.describe('Include network requests'),
85+
includeTabs: zod
86+
.boolean()
87+
.optional()
88+
.default(false)
89+
.describe('Include tab/page information'),
90+
snapshotOptions: snapshotOptionsSchema,
91+
imageOptions: imageOptionsSchema,
92+
})
93+
.optional();
8894

8995
export type ExpectationOptions = zod.infer<typeof expectationSchema>;
9096
export type SnapshotOptions = zod.infer<typeof snapshotOptionsSchema>;
@@ -328,7 +334,8 @@ export function mergeExpectations(
328334
return defaults;
329335
}
330336
return {
331-
includeSnapshot: userExpectation.includeSnapshot ?? defaults.includeSnapshot,
337+
includeSnapshot:
338+
userExpectation.includeSnapshot ?? defaults.includeSnapshot,
332339
includeConsole: userExpectation.includeConsole ?? defaults.includeConsole,
333340
includeNetwork: userExpectation.includeNetwork ?? defaults.includeNetwork,
334341
includeTabs: userExpectation.includeTabs ?? defaults.includeTabs,

src/tools/screenshot.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,10 @@ export const screenshot = defineTool({
120120
}
121121

122122
if (request.params.filePath) {
123-
const file = await context.saveFile(screenshotData, request.params.filePath);
123+
const file = await context.saveFile(
124+
screenshotData,
125+
request.params.filePath,
126+
);
124127
response.appendResponseLine(`Saved screenshot to ${file.filename}.`);
125128
} else if (screenshotData.length >= 2_000_000) {
126129
const {filename} = await context.saveTemporaryFile(

src/utils/image-processor.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,11 @@ export async function processImage(
6161
// Apply format and quality options
6262
let outputMimeType = mimeType;
6363
if (options.format) {
64-
const result = applyFormatConversion(image, options.format, options.quality);
64+
const result = applyFormatConversion(
65+
image,
66+
options.format,
67+
options.quality,
68+
);
6569
image = result.image;
6670
outputMimeType = result.mimeType;
6771
} else if (options.quality) {

tests/formatters/snapshotFormatter.test.ts

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -318,10 +318,9 @@ describe('snapshotFormatter', () => {
318318
elementHandle: async () => null,
319319
};
320320

321-
const formatter = new SnapshotFormatter(
322-
{root: node} as TextSnapshot,
323-
{maxLength: 50},
324-
);
321+
const formatter = new SnapshotFormatter({root: node} as TextSnapshot, {
322+
maxLength: 50,
323+
});
325324
const formatted = formatter.toString();
326325

327326
assert.ok(formatted.length <= 50);
@@ -337,10 +336,9 @@ describe('snapshotFormatter', () => {
337336
elementHandle: async () => null,
338337
};
339338

340-
const formatter = new SnapshotFormatter(
341-
{root: node} as TextSnapshot,
342-
{maxLength: 1000},
343-
);
339+
const formatter = new SnapshotFormatter({root: node} as TextSnapshot, {
340+
maxLength: 1000,
341+
});
344342
const formatted = formatter.toString();
345343

346344
assert.ok(!formatted.includes('[truncated'));

tests/utils/image-processor.test.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
*/
66

77
import assert from 'node:assert';
8-
import {describe, it, before} from 'node:test';
8+
import {describe, it} from 'node:test';
99

1010
import sharp from 'sharp';
1111

@@ -44,7 +44,10 @@ describe('image-processor', () => {
4444
assert.strictEqual(result.mimeType, 'image/png');
4545
assert.strictEqual(result.compressionRatio, 1.0);
4646
assert.strictEqual(result.originalSize.width, result.processedSize.width);
47-
assert.strictEqual(result.originalSize.height, result.processedSize.height);
47+
assert.strictEqual(
48+
result.originalSize.height,
49+
result.processedSize.height,
50+
);
4851
});
4952

5053
it('returns original image when empty options provided', async () => {

0 commit comments

Comments
 (0)