Skip to content

Commit d5cde13

Browse files
committed
feat: Add evaluate_script_file tool to evaluate JavaScript files from the local filesystem
Added a new tool evaluate_script_file that reads a JavaScript file from the local filesystem and evaluates it inside the currently selected page. This is useful for evaluating large scripts without needing to pass the entire script content as a parameter.
1 parent 2eec55a commit d5cde13

8 files changed

Lines changed: 829 additions & 661 deletions

File tree

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -468,8 +468,9 @@ If you run into any issues, checkout our [troubleshooting guide](./docs/troubles
468468
- **Network** (2 tools)
469469
- [`get_network_request`](docs/tool-reference.md#get_network_request)
470470
- [`list_network_requests`](docs/tool-reference.md#list_network_requests)
471-
- **Debugging** (6 tools)
471+
- **Debugging** (7 tools)
472472
- [`evaluate_script`](docs/tool-reference.md#evaluate_script)
473+
- [`evaluate_script_file`](docs/tool-reference.md#evaluate_script_file)
473474
- [`get_console_message`](docs/tool-reference.md#get_console_message)
474475
- [`lighthouse_audit`](docs/tool-reference.md#lighthouse_audit)
475476
- [`list_console_messages`](docs/tool-reference.md#list_console_messages)

docs/tool-reference.md

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<!-- AUTO GENERATED DO NOT EDIT - run 'npm run gen' to update-->
22

3-
# Chrome DevTools MCP Tool Reference (~6940 cl100k_base tokens)
3+
# Chrome DevTools MCP Tool Reference (~7262 cl100k_base tokens)
44

55
- **[Input automation](#input-automation)** (9 tools)
66
- [`click`](#click)
@@ -30,8 +30,9 @@
3030
- **[Network](#network)** (2 tools)
3131
- [`get_network_request`](#get_network_request)
3232
- [`list_network_requests`](#list_network_requests)
33-
- **[Debugging](#debugging)** (6 tools)
33+
- **[Debugging](#debugging)** (7 tools)
3434
- [`evaluate_script`](#evaluate_script)
35+
- [`evaluate_script_file`](#evaluate_script_file)
3536
- [`get_console_message`](#get_console_message)
3637
- [`lighthouse_audit`](#lighthouse_audit)
3738
- [`list_console_messages`](#list_console_messages)
@@ -157,7 +158,7 @@
157158

158159
### `list_pages`
159160

160-
**Description:** Get a list of pages open in the browser.
161+
**Description:** Get a list of pages open in the browser.
161162

162163
**Parameters:** None
163164

@@ -323,19 +324,36 @@ so returned values have to be JSON-serializable.
323324
**Parameters:**
324325

325326
- **function** (string) **(required)**: A JavaScript function declaration to be executed by the tool in the currently selected page.
326-
Example without arguments: `() => {
327+
Example without arguments: `() => {
327328
return document.title
328329
}` or `async () => {
329330
return await fetch("example.com")
330331
}`.
331-
Example with arguments: `(el) => {
332+
Example with arguments: `(el) => {
332333
return el.innerText;
333334
}`
334335

335336
- **args** (array) _(optional)_: An optional list of arguments to pass to the function.
336337

337338
---
338339

340+
### `evaluate_script_file`
341+
342+
**Description:** Read a JavaScript file from the local filesystem and evaluate it inside the currently selected page.
343+
The file should contain a JavaScript function declaration (e.g., an arrow function or function expression).
344+
Returns the response as JSON, so returned values have to be JSON-serializable.
345+
This is useful for evaluating large scripts without needing to pass the entire script content as a parameter.
346+
347+
**Parameters:**
348+
349+
- **filePath** (string) **(required)**: The absolute path to a JavaScript file containing a function declaration to be executed in the currently selected page.
350+
The file content should be a JavaScript function declaration, for example:
351+
`() => { return document.title; }` or `async () => { return await fetch("example.com"); }`
352+
353+
- **args** (array) _(optional)_: An optional list of arguments to pass to the function.
354+
355+
---
356+
339357
### `get_console_message`
340358

341359
**Description:** Gets a console message by its ID. You can get all messages by calling [`list_console_messages`](#list_console_messages).

0 commit comments

Comments
 (0)