Repository navigation
Expand file tree
/
Copy pathplaywright-mcp.patch
More file actions
143 lines (138 loc) · 7 KB
/
Copy pathplaywright-mcp.patch
File metadata and controls
143 lines (138 loc) · 7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
diff --git a/src/tools/common.ts b/src/tools/common.ts
--- a/src/tools/common.ts
+++ b/src/tools/common.ts
@@ -45,8 +45,8 @@ const resize: ToolFactory = captureSnapshot => defineTool({
title: 'Resize browser window',
description: 'Resize the browser window',
inputSchema: z.object({
- width: z.number().describe('Width of the browser window'),
- height: z.number().describe('Height of the browser window'),
+ width: z.coerce.number().describe('Width of the browser window'),
+ height: z.coerce.number().describe('Height of the browser window'),
}),
type: 'readOnly',
},
diff --git a/src/tools/dialogs.ts b/src/tools/dialogs.ts
--- a/src/tools/dialogs.ts
+++ b/src/tools/dialogs.ts
@@ -25,7 +25,7 @@ const handleDialog: ToolFactory = captureSnapshot => defineTool({
title: 'Handle a dialog',
description: 'Handle a dialog',
inputSchema: z.object({
- accept: z.boolean().describe('Whether to accept the dialog.'),
+ accept: z.coerce.boolean().describe('Whether to accept the dialog.'),
promptText: z.string().optional().describe('The text of the prompt in case of a prompt dialog.'),
}),
type: 'destructive',
diff --git a/src/tools/screenshot.ts b/src/tools/screenshot.ts
--- a/src/tools/screenshot.ts
+++ b/src/tools/screenshot.ts
@@ -24,7 +24,7 @@ import { generateLocator } from './utils.js';
import type * as playwright from 'playwright';
const screenshotSchema = z.object({
- raw: z.boolean().optional().describe('Whether to return without compression (in PNG format). Default is false, which returns a JPEG image.'),
+ raw: z.coerce.boolean().optional().describe('Whether to return without compression (in PNG format). Default is false, which returns a JPEG image.'),
filename: z.string().optional().describe('File name to save the screenshot to. Defaults to `page-{timestamp}.{png|jpeg}` if not specified.'),
element: z.string().optional().describe('Human-readable element description used to obtain permission to screenshot the element. If not provided, the screenshot will be taken of viewport. If element is provided, ref must be provided too.'),
ref: z.string().optional().describe('Exact target element reference from the page snapshot. If not provided, the screenshot will be taken of viewport. If ref is provided, element must be provided too.'),
diff --git a/src/tools/snapshot.ts b/src/tools/snapshot.ts
--- a/src/tools/snapshot.ts
+++ b/src/tools/snapshot.ts
@@ -47,7 +47,7 @@ const elementSchema = z.object({
});
const clickSchema = elementSchema.extend({
- doubleClick: z.boolean().optional().describe('Whether to perform a double click instead of a single click'),
+ doubleClick: z.coerce.boolean().optional().describe('Whether to perform a double click instead of a single click'),
});
const click = defineTool({
@@ -146,8 +146,8 @@ const hover = defineTool({
const typeSchema = elementSchema.extend({
text: z.string().describe('Text to type into the element'),
- submit: z.boolean().optional().describe('Whether to submit entered text (press Enter after)'),
- slowly: z.boolean().optional().describe('Whether to type one character at a time. Useful for triggering key handlers in the page. By default entire text is filled in at once.'),
+ submit: z.coerce.boolean().optional().describe('Whether to submit entered text (press Enter after)'),
+ slowly: z.coerce.boolean().optional().describe('Whether to type one character at a time. Useful for triggering key handlers in the page. By default entire text is filled in at once.'),
});
const type = defineTool({
diff --git a/src/tools/tabs.ts b/src/tools/tabs.ts
--- a/src/tools/tabs.ts
+++ b/src/tools/tabs.ts
@@ -52,7 +52,7 @@ const selectTab: ToolFactory = captureSnapshot => defineTool({
title: 'Select a tab',
description: 'Select a tab by index',
inputSchema: z.object({
- index: z.number().describe('The index of the tab to select'),
+ index: z.coerce.number().describe('The index of the tab to select'),
}),
type: 'readOnly',
},
@@ -108,7 +108,7 @@ const closeTab: ToolFactory = captureSnapshot => defineTool({
title: 'Close a tab',
description: 'Close a tab',
inputSchema: z.object({
- index: z.number().optional().describe('The index of the tab to close. Closes current tab if not provided.'),
+ index: z.coerce.number().optional().describe('The index of the tab to close. Closes current tab if not provided.'),
}),
type: 'destructive',
},
diff --git a/src/tools/vision.ts b/src/tools/vision.ts
--- a/src/tools/vision.ts
+++ b/src/tools/vision.ts
@@ -64,8 +64,8 @@ const moveMouse = defineTool({
title: 'Move mouse',
description: 'Move mouse to a given position',
inputSchema: elementSchema.extend({
- x: z.number().describe('X coordinate'),
- y: z.number().describe('Y coordinate'),
+ x: z.coerce.number().describe('X coordinate'),
+ y: z.coerce.number().describe('Y coordinate'),
}),
type: 'readOnly',
},
@@ -93,8 +93,8 @@ const click = defineTool({
title: 'Click',
description: 'Click left mouse button',
inputSchema: elementSchema.extend({
- x: z.number().describe('X coordinate'),
- y: z.number().describe('Y coordinate'),
+ x: z.coerce.number().describe('X coordinate'),
+ y: z.coerce.number().describe('Y coordinate'),
}),
type: 'destructive',
},
@@ -128,10 +128,10 @@ const drag = defineTool({
title: 'Drag mouse',
description: 'Drag left mouse button',
inputSchema: elementSchema.extend({
- startX: z.number().describe('Start X coordinate'),
- startY: z.number().describe('Start Y coordinate'),
- endX: z.number().describe('End X coordinate'),
- endY: z.number().describe('End Y coordinate'),
+ startX: z.coerce.number().describe('Start X coordinate'),
+ startY: z.coerce.number().describe('Start Y coordinate'),
+ endX: z.coerce.number().describe('End X coordinate'),
+ endY: z.coerce.number().describe('End Y coordinate'),
}),
type: 'destructive',
},
@@ -171,7 +171,7 @@ const type = defineTool({
description: 'Type text',
inputSchema: z.object({
text: z.string().describe('Text to type into the element'),
- submit: z.boolean().optional().describe('Whether to submit entered text (press Enter after)'),
+ submit: z.coerce.boolean().optional().describe('Whether to submit entered text (press Enter after)'),
}),
type: 'destructive',
},
diff --git a/src/tools/wait.ts b/src/tools/wait.ts
--- a/src/tools/wait.ts
+++ b/src/tools/wait.ts
@@ -25,7 +25,7 @@ const wait: ToolFactory = captureSnapshot => defineTool({
title: 'Wait for',
description: 'Wait for text to appear or disappear or a specified time to pass',
inputSchema: z.object({
- time: z.number().optional().describe('The time to wait in seconds'),
+ time: z.coerce.number().optional().describe('The time to wait in seconds'),
text: z.string().optional().describe('The text to wait for'),
textGone: z.string().optional().describe('The text to wait for to disappear'),
}),