feat: support filePath in evaluate_script#2054
Merged
OrKoN merged 4 commits intoMay 14, 2026
Merged
Conversation
Adds an optional filePath parameter to evaluate_script that saves the script output to a file instead of returning it inline. This reduces token usage for large outputs and enables offline analysis. Follows the same context.saveFile() pattern used by take_snapshot, take_screenshot, and performance tools. Refs ChromeDevTools#153
OrKoN
reviewed
May 13, 2026
context is always provided when filePath is set, so it should not be optional.
OrKoN
approved these changes
May 14, 2026
Collaborator
|
LGTM thanks! |
Contributor
Author
|
Thank you for the review! |
Merged
via the queue into
ChromeDevTools:main
with commit May 14, 2026
90d368d
28 of 30 checks passed
This was referenced May 14, 2026
pull Bot
pushed a commit
to Spencerx/chrome-devtools-mcp
that referenced
this pull request
May 18, 2026
🤖 I have created a release *beep* *boop* --- ## [1.0.0](ChromeDevTools/chrome-devtools-mcp@chrome-devtools-mcp-v0.26.0...chrome-devtools-mcp-v1.0.0) (2026-05-18) ### 🎉 Features * report new URL after actions that trigger navigation ([ChromeDevTools#1853](ChromeDevTools#1853)) ([b594858](ChromeDevTools@b594858)) * support filePath in evaluate_script ([ChromeDevTools#2054](ChromeDevTools#2054)) ([90d368d](ChromeDevTools@90d368d)) ### 🛠️ Fixes * disable NetworkManager in DevTools ([ChromeDevTools#1834](ChromeDevTools#1834)) ([d0e6539](ChromeDevTools@d0e6539)) * do not use getSelectedMcpPage ([85f935b](ChromeDevTools@85f935b)) * improve geolocation emulation ([ChromeDevTools#2036](ChromeDevTools#2036)) ([213720b](ChromeDevTools@213720b)) * report unknown tool arguments ([ChromeDevTools#2064](ChromeDevTools#2064)) ([041b208](ChromeDevTools@041b208)) * respect user's npm registry configuration in update check ([ChromeDevTools#2038](ChromeDevTools#2038)) ([83a299f](ChromeDevTools@83a299f)) ### 📄 Documentation * explain concurrent session options ([ChromeDevTools#2062](ChromeDevTools#2062)) ([41944b3](ChromeDevTools@41944b3)) * fix typo ([ChromeDevTools#2075](ChromeDevTools#2075)) ([1deb4f8](ChromeDevTools@1deb4f8)) * remove windows workaround and document Node LTS support ([ChromeDevTools#2074](ChromeDevTools#2074)) ([30dcd0b](ChromeDevTools@30dcd0b)) * unhide various experimental flags ([ChromeDevTools#2055](ChromeDevTools#2055)) ([081c903](ChromeDevTools@081c903)) ### 🏗️ Refactor * waitForResult helpers ([ChromeDevTools#2041](ChromeDevTools#2041)) ([f6a12be](ChromeDevTools@f6a12be)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please).
OrKoN
pushed a commit
that referenced
this pull request
May 19, 2026
🤖 I have created a release *beep* *boop* --- ## [1.0.0](chrome-devtools-mcp-v0.26.0...chrome-devtools-mcp-v1.0.0) (2026-05-18) ### 🎉 Features * report new URL after actions that trigger navigation ([#1853](#1853)) ([b594858](b594858)) * support filePath in evaluate_script ([#2054](#2054)) ([90d368d](90d368d)) ### 🛠️ Fixes * disable NetworkManager in DevTools ([#1834](#1834)) ([d0e6539](d0e6539)) * do not use getSelectedMcpPage ([85f935b](85f935b)) * improve geolocation emulation ([#2036](#2036)) ([213720b](213720b)) * report unknown tool arguments ([#2064](#2064)) ([041b208](041b208)) * respect user's npm registry configuration in update check ([#2038](#2038)) ([83a299f](83a299f)) ### 📄 Documentation * explain concurrent session options ([#2062](#2062)) ([41944b3](41944b3)) * fix typo ([#2075](#2075)) ([1deb4f8](1deb4f8)) * remove windows workaround and document Node LTS support ([#2074](#2074)) ([30dcd0b](30dcd0b)) * unhide various experimental flags ([#2055](#2055)) ([081c903](081c903)) ### 🏗️ Refactor * waitForResult helpers ([#2041](#2041)) ([f6a12be](f6a12be)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds an optional
filePathparameter toevaluate_scriptthat saves the script output to a file instead of returning it inline.Refs #153
Motivation
Issue #153 requested
filePathsupport fortake_snapshotandevaluate_script.take_snapshotwas addressed in #463. PR #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
filePathparameter to theevaluate_scriptschemacontext.validatePath(filePath)call for path validation{filePath, context}options toperformEvaluation()performEvaluation(): whenfilePathis provided, save output viacontext.saveFile()with.jsonextension; otherwise return inline as beforedocs/tool-reference.mdvianpm run docs:generateKey design decisions
context.saveFile()pattern established bytake_snapshot(feat: support saving snapshots to file #463),take_screenshot,get_network_request(feat: support filePath for network request and response bodies #795), and performance tools (feat: support filePath in performance tools #686).performEvaluation()gains an optionaloptionsparameter. No new interfaces or abstractions.filePathis optional. When omitted, behavior is identical to before.Testing
Unit test added (
tests/tools/script.test.ts):evaluate_scriptwithfilePathset to a temp filefinallyblockManual testing performed:
() => document.titlewithfilePath: /tmp/test.json→ file contains"Example Domain"() => document.titlewithoutfilePath→ inline ```json block returned (no regression)() => Array.from({length: 100}, ...)withfilePath→ 100-item array saved correctlyfilePathpointing to non-existent directory → directory auto-created, file savedtest.json) → resolved to CWD, absolute path shown in responsefilePath→ file overwritten completely