@@ -5,7 +5,7 @@ description:
5
5
Using the Playwright MCP server with ToolHive for browser automation.
6
6
last_update :
7
7
author : danbarr
8
- date : 2025-08-27
8
+ date : 2025-10-07
9
9
---
10
10
11
11
import useBaseUrl from ' @docusaurus/useBaseUrl' ;
@@ -105,35 +105,35 @@ thv run playwright
105
105
Emulate a mobile device for responsive testing:
106
106
107
107
``` bash
108
- thv run playwright -- --port 8931 --device " iPhone 15"
108
+ thv run playwright -- --port 8931 --allowed-hosts " * " -- device " iPhone 15"
109
109
```
110
110
111
111
Restrict access to specific domains:
112
112
113
113
``` bash
114
- thv run playwright -- --port 8931 --allowed-origins " example.com;trusted-site.com"
114
+ thv run playwright -- --port 8931 --allowed-hosts " * " --allowed- origins " example.com;trusted-site.com"
115
115
```
116
116
117
117
Mount a host directory (e.g., ` ~/playwright-output ` ) to save browser output
118
118
files like screenshots and traces:
119
119
120
120
``` bash
121
121
mkdir ~ /playwright-output
122
- thv run --volume ~ /playwright-output:/browser-output playwright -- --port 8931 --output-dir /browser-output --save-trace --save-session
122
+ thv run --volume ~ /playwright-output:/browser-output playwright -- --port 8931 --allowed-hosts " * " -- output-dir /browser-output --save-trace --save-session
123
123
```
124
124
125
125
You can run multiple instances of the server with different configurations by
126
126
giving each a unique name:
127
127
128
128
``` bash
129
- thv run --name playwright-desktop playwright -- --port 8931 --device " Desktop Chrome" --viewport-size 1920,1080
130
- thv run --name playwright-iphone playwright -- --port 8931 --device " iPhone 15"
129
+ thv run --name playwright-desktop playwright -- --port 8931 --allowed-hosts " * " -- device " Desktop Chrome" --viewport-size 1920,1080
130
+ thv run --name playwright-iphone playwright -- --port 8931 --allowed-hosts " * " -- device " iPhone 15"
131
131
```
132
132
133
133
:::note[ Important]
134
134
135
- Don't remove the ` --port 8931 ` argument, as the server requires it to function
136
- correctly in ToolHive.
135
+ Don't remove the ` --port 8931 ` or ` --allowed-hosts "*" ` arguments, as the
136
+ server requires it to function correctly in ToolHive.
137
137
138
138
:::
139
139
@@ -149,13 +149,15 @@ metadata:
149
149
name : playwright
150
150
namespace : toolhive-system
151
151
spec :
152
- image : mcr.microsoft.com/playwright/mcp:v0.0.36
152
+ image : mcr.microsoft.com/playwright/mcp:v0.0.41
153
153
transport : streamable-http
154
154
targetPort : 8931
155
155
port : 8080
156
156
args :
157
157
- ' --port'
158
158
- ' 8931'
159
+ - ' --allowed-hosts'
160
+ - ' *'
159
161
permissionProfile :
160
162
type : builtin
161
163
name : network
@@ -167,22 +169,25 @@ Apply the manifest to your Kubernetes cluster:
167
169
kubectl apply -f playwright.yaml
168
170
```
169
171
170
- For production deployments with network restrictions:
172
+ For production deployments with network restrictions, add the
173
+ ` --allowed-origins ` argument with a list of trusted domains:
171
174
172
- ``` yaml title="playwright-restricted.yaml"
175
+ ``` yaml {16-17} title="playwright-restricted.yaml"
173
176
apiVersion : toolhive.stacklok.dev/v1alpha1
174
177
kind : MCPServer
175
178
metadata :
176
179
name : playwright
177
180
namespace : toolhive-system
178
181
spec :
179
- image : mcr.microsoft.com/playwright/mcp:v0.0.36
182
+ image : mcr.microsoft.com/playwright/mcp:v0.0.41
180
183
transport : streamable-http
181
184
targetPort : 8931
182
185
port : 8080
183
186
args :
184
187
- ' --port'
185
188
- ' 8931'
189
+ - ' --allowed-hosts'
190
+ - ' *'
186
191
- ' --allowed-origins'
187
192
- ' example.com;trusted-domain.org'
188
193
permissionProfile :
@@ -193,20 +198,22 @@ spec:
193
198
Mount a persistent volume to save browser output files like screenshots and
194
199
traces:
195
200
196
- ` ` ` yaml {13-14,22-25,28-31 } title="playwright-with-volume.yaml"
201
+ ` ` ` yaml {16-17,25-28,31-34 } title="playwright-with-volume.yaml"
197
202
apiVersion : toolhive.stacklok.dev/v1alpha1
198
203
kind : MCPServer
199
204
metadata :
200
205
name : playwright
201
206
namespace : toolhive-system
202
207
spec :
203
- image : mcr.microsoft.com/playwright/mcp:v0.0.36
208
+ image : mcr.microsoft.com/playwright/mcp:v0.0.41
204
209
transport : streamable-http
205
210
targetPort : 8931
206
211
port : 8080
207
212
args :
208
213
- ' --port'
209
214
- ' 8931'
215
+ - ' --allowed-hosts'
216
+ - ' *'
210
217
- ' --output-dir'
211
218
- ' /browser-output'
212
219
- ' --save-trace'
0 commit comments