Skip to content

feat: support saving snapshots to file#463

Merged
OrKoN merged 2 commits into
mainfrom
orkon/snapshot-to-file
Oct 24, 2025
Merged

feat: support saving snapshots to file#463
OrKoN merged 2 commits into
mainfrom
orkon/snapshot-to-file

Conversation

@OrKoN

@OrKoN OrKoN commented Oct 23, 2025

Copy link
Copy Markdown
Collaborator

Refs #153

@OrKoN OrKoN force-pushed the orkon/snapshot-to-file branch from 0dc113d to f121016 Compare October 23, 2025 19:49
Comment thread src/McpResponse.ts Outdated
@OrKoN OrKoN enabled auto-merge (squash) October 24, 2025 08:55
@OrKoN OrKoN force-pushed the orkon/snapshot-to-file branch from 2014ec9 to aa8bcc0 Compare October 24, 2025 09:12
OrKoN and others added 2 commits October 24, 2025 11:16
Co-authored-by: Nikolay Vitkov <34244704+Lightning00Blade@users.noreply.github.com>
@OrKoN OrKoN force-pushed the orkon/snapshot-to-file branch from aa8bcc0 to f04d13a Compare October 24, 2025 09:16
@OrKoN OrKoN merged commit b0ce08a into main Oct 24, 2025
20 checks passed
@OrKoN OrKoN deleted the orkon/snapshot-to-file branch October 24, 2025 09:20
OrKoN pushed a commit that referenced this pull request Nov 5, 2025
🤖 I have created a release *beep* *boop*
---


##
[0.10.0](chrome-devtools-mcp-v0.9.0...chrome-devtools-mcp-v0.10.0)
(2025-11-05)


### 🎉 Features

* add a press_key tool
([#458](#458))
([b427392](b427392))
* add insightSetId to performance_analyze_insight
([#518](#518))
([36504d2](36504d2))
* an option to ignore cache on reload
([#485](#485))
([8e56307](8e56307))
* detect network requests inspected in DevTools UI
([#477](#477))
([796aed7](796aed7))
* fetch DOM node selected in the DevTools Elements panel
([#486](#486))
([4a83574](4a83574))
* support page reload
([#462](#462))
([d177087](d177087))
* support saving snapshots to file
([#463](#463))
([b0ce08a](b0ce08a))


### 🛠️ Fixes

* Augment fix to prevent stray OGS frames in NTP from causing hangs.
([#521](#521))
([d90abd4](d90abd4))
* improve get_network_request description
([#500](#500))
([2f448e8](2f448e8))
* work around NTP iframes causing hangs
([#504](#504))
([cca5ff4](cca5ff4))


### 📄 Documentation

* add Windsurf to the editor config README
([#493](#493))
([63a5d82](63a5d82))
* fix typos in README.md exlcude -&gt; exclude
([#513](#513))
([8854a34](8854a34))
* remove unnecessary replace
([#475](#475))
([40e1753](40e1753))


### ♻️ Chores

* connect to DevTools targets by default
([#466](#466))
([a41e440](a41e440))
* detect DevTools page for each page
([#467](#467))
([1560ff2](1560ff2))
* merge emulate tools into one
([#494](#494))
([c06f452](c06f452))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).
franco-bianco pushed a commit to franco-bianco/ghostframe-mcp that referenced this pull request May 2, 2026
🤖 I have created a release *beep* *boop*
---


##
[0.10.0](ChromeDevTools/chrome-devtools-mcp@chrome-devtools-mcp-v0.9.0...chrome-devtools-mcp-v0.10.0)
(2025-11-05)


### 🎉 Features

* add a press_key tool
([#458](ChromeDevTools/chrome-devtools-mcp#458))
([d3cfa71](ChromeDevTools/chrome-devtools-mcp@d3cfa71))
* add insightSetId to performance_analyze_insight
([#518](ChromeDevTools/chrome-devtools-mcp#518))
([d5d48f4](ChromeDevTools/chrome-devtools-mcp@d5d48f4))
* an option to ignore cache on reload
([#485](ChromeDevTools/chrome-devtools-mcp#485))
([69948dc](ChromeDevTools/chrome-devtools-mcp@69948dc))
* detect network requests inspected in DevTools UI
([#477](ChromeDevTools/chrome-devtools-mcp#477))
([d387517](ChromeDevTools/chrome-devtools-mcp@d387517))
* fetch DOM node selected in the DevTools Elements panel
([#486](ChromeDevTools/chrome-devtools-mcp#486))
([246b513](ChromeDevTools/chrome-devtools-mcp@246b513))
* support page reload
([#462](ChromeDevTools/chrome-devtools-mcp#462))
([60f4039](ChromeDevTools/chrome-devtools-mcp@60f4039))
* support saving snapshots to file
([#463](ChromeDevTools/chrome-devtools-mcp#463))
([a89dd2b](ChromeDevTools/chrome-devtools-mcp@a89dd2b))


### 🛠️ Fixes

* Augment fix to prevent stray OGS frames in NTP from causing hangs.
([#521](ChromeDevTools/chrome-devtools-mcp#521))
([d0f212a](ChromeDevTools/chrome-devtools-mcp@d0f212a))
* improve get_network_request description
([#500](ChromeDevTools/chrome-devtools-mcp#500))
([fa27910](ChromeDevTools/chrome-devtools-mcp@fa27910))
* work around NTP iframes causing hangs
([#504](ChromeDevTools/chrome-devtools-mcp#504))
([0813338](ChromeDevTools/chrome-devtools-mcp@0813338))


### 📄 Documentation

* add Windsurf to the editor config README
([#493](ChromeDevTools/chrome-devtools-mcp#493))
([58af5d8](ChromeDevTools/chrome-devtools-mcp@58af5d8))
* fix typos in README.md exlcude -&gt; exclude
([#513](ChromeDevTools/chrome-devtools-mcp#513))
([1ac6745](ChromeDevTools/chrome-devtools-mcp@1ac6745))
* remove unnecessary replace
([#475](ChromeDevTools/chrome-devtools-mcp#475))
([62d0b19](ChromeDevTools/chrome-devtools-mcp@62d0b19))


### ♻️ Chores

* connect to DevTools targets by default
([#466](ChromeDevTools/chrome-devtools-mcp#466))
([9779c2d](ChromeDevTools/chrome-devtools-mcp@9779c2d))
* detect DevTools page for each page
([#467](ChromeDevTools/chrome-devtools-mcp#467))
([2bd33b9](ChromeDevTools/chrome-devtools-mcp@2bd33b9))
* merge emulate tools into one
([#494](ChromeDevTools/chrome-devtools-mcp#494))
([08852c1](ChromeDevTools/chrome-devtools-mcp@08852c1))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).
pull Bot pushed a commit to Mu-L/chrome-devtools-mcp that referenced this pull request May 14, 2026
## Summary

Adds an optional `filePath` parameter to `evaluate_script` that saves
the script output to a file instead of returning it inline.

Refs #153

## Motivation

Issue #153 requested `filePath` support for `take_snapshot` and
`evaluate_script`. `take_snapshot` was addressed in ChromeDevTools#463. PR ChromeDevTools#248
previously attempted this but was closed due to conflicts. This PR
implements the same feature on the current codebase, completing the
remaining piece.

## Changes

- Add optional `filePath` parameter to the `evaluate_script` schema
- Add `context.validatePath(filePath)` call for path validation
- Pass `{filePath, context}` options to `performEvaluation()`
- In `performEvaluation()`: when `filePath` is provided, save output via
`context.saveFile()` with `.json` extension; otherwise return inline as
before
- Update `docs/tool-reference.md` via `npm run docs:generate`
- Add unit test for file output

## Key design decisions

- **Same pattern as existing tools**: Follows the `context.saveFile()`
pattern established by `take_snapshot` (ChromeDevTools#463), `take_screenshot`,
`get_network_request` (ChromeDevTools#795), and performance tools (ChromeDevTools#686).
- **Minimal change surface**: Only `performEvaluation()` gains an
optional `options` parameter. No new interfaces or abstractions.
- **Backwards compatible**: `filePath` is optional. When omitted,
behavior is identical to before.

## Testing

**Unit test added** (`tests/tools/script.test.ts`):
- Call `evaluate_script` with `filePath` set to a temp file
- Assert response contains "Output saved to"
- Assert file content matches the JSON-serialized return value
- Clean up temp file in `finally` block

**Manual testing performed**:
- `() => document.title` with `filePath: /tmp/test.json` → file contains
`"Example Domain"`
- `() => document.title` without `filePath` → inline ```json block
returned (no regression)
- `() => Array.from({length: 100}, ...)` with `filePath` → 100-item
array saved correctly
- `filePath` pointing to non-existent directory → directory
auto-created, file saved
- Relative path (`test.json`) → resolved to CWD, absolute path shown in
response
- Function that throws → error returned, no partial file created
- Existing file as `filePath` → file overwritten completely

---------

Co-authored-by: Alex Rudenko <alexrudenko@chromium.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants