You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/tool-reference.md
+12-2Lines changed: 12 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -259,11 +259,21 @@
259
259
260
260
### `evaluate_script`
261
261
262
-
**Description:** Evaluate a JavaScript function inside the currently selected page. Returns the response as JSON.
262
+
**Description:** Evaluate a JavaScript function inside the currently selected page. Returns the response as JSON
263
+
so returned values have to JSON-serializable.
263
264
264
265
**Parameters:**
265
266
266
-
-**function** (string) **(required)**: A JavaScript function to run in the currently selected page. Example: `() => {return document.title}` or `async () => {return await fetch("example.com")}`
267
+
-**args** (array) _(optional)_: An optional list of arguments to pass to the function.
268
+
-**function** (string) **(required)**: A JavaScript function to run in the currently selected page.
description: `Evaluate a JavaScript function inside the currently selected page. Returns the response as JSON.`,
14
+
description: `Evaluate a JavaScript function inside the currently selected page. Returns the response as JSON
15
+
so returned values have to JSON-serializable.`,
14
16
annotations: {
15
17
category: ToolCategories.DEBUGGING,
16
18
readOnlyHint: false,
17
19
},
18
20
schema: {
19
-
function: z
20
-
.string()
21
-
.describe(
22
-
'A JavaScript function to run in the currently selected page. Example: `() => {return document.title}` or `async () => {return await fetch("example.com")}`',
23
-
),
21
+
function: z.string().describe(
22
+
`A JavaScript function to run in the currently selected page.
23
+
Example without arguments: \`() => {
24
+
return document.title
25
+
}\` or \`async () => {
26
+
return await fetch("example.com")
27
+
}\`.
28
+
Example with arguments: \`(el) => {
29
+
return el.innerText;
30
+
}\`
31
+
`,
32
+
),
33
+
args: z
34
+
.array(
35
+
z.object({
36
+
uid: z
37
+
.string()
38
+
.describe(
39
+
'The uid of an element on the page from the page content snapshot',
40
+
),
41
+
}),
42
+
)
43
+
.optional()
44
+
.describe(`An optional list of arguments to pass to the function.`),
0 commit comments