chrometools-mcp 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +15 -0
- package/README.md +329 -0
- package/WSL_SETUP.md +270 -0
- package/index.js +1286 -0
- package/package.json +55 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
ISC License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025, chrometools-mcp contributors
|
|
4
|
+
|
|
5
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
6
|
+
purpose with or without fee is hereby granted, provided that the above
|
|
7
|
+
copyright notice and this permission notice appear in all copies.
|
|
8
|
+
|
|
9
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
10
|
+
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
11
|
+
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
12
|
+
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
13
|
+
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
14
|
+
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
15
|
+
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,329 @@
|
|
|
1
|
+
# chrometools-mcp
|
|
2
|
+
|
|
3
|
+
MCP server for Chrome automation using Puppeteer with persistent browser sessions.
|
|
4
|
+
|
|
5
|
+
## Table of Contents
|
|
6
|
+
|
|
7
|
+
- [Installation](#installation)
|
|
8
|
+
- [Usage](#usage)
|
|
9
|
+
- [Available Tools](#available-tools) - **16 Tools Total**
|
|
10
|
+
- [Core Tools](#1-core-tools) - ping, openBrowser
|
|
11
|
+
- [Interaction Tools](#2-interaction-tools) - click, type, scrollTo
|
|
12
|
+
- [Inspection Tools](#3-inspection-tools) - getElement, getComputedCss, getBoxModel, screenshot
|
|
13
|
+
- [Advanced Tools](#4-advanced-tools) - executeScript, getConsoleLogs, hover, setStyles, setViewport, getViewport, navigateTo
|
|
14
|
+
- [Typical Workflow Example](#typical-workflow-example)
|
|
15
|
+
- [Tool Usage Tips](#tool-usage-tips)
|
|
16
|
+
- [Configuration](#configuration)
|
|
17
|
+
- [WSL Setup Guide](#wsl-setup-guide) → [Full WSL Guide](WSL_SETUP.md)
|
|
18
|
+
- [Development](#development)
|
|
19
|
+
- [Features](#features)
|
|
20
|
+
- [Architecture](#architecture)
|
|
21
|
+
|
|
22
|
+
## Installation
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
npx -y chrometools-mcp
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Usage
|
|
29
|
+
|
|
30
|
+
Add to your MCP client configuration (e.g., Claude Desktop):
|
|
31
|
+
|
|
32
|
+
```json
|
|
33
|
+
{
|
|
34
|
+
"mcpServers": {
|
|
35
|
+
"chrometools": {
|
|
36
|
+
"command": "npx",
|
|
37
|
+
"args": ["-y", "chrometools-mcp"]
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## Available Tools
|
|
44
|
+
|
|
45
|
+
### 1. Core Tools
|
|
46
|
+
|
|
47
|
+
#### ping
|
|
48
|
+
Test MCP connection with a simple ping-pong response.
|
|
49
|
+
- **Parameters**: `message` (optional)
|
|
50
|
+
- **Example**: `{ "name": "ping", "arguments": { "message": "hello" } }`
|
|
51
|
+
- **Returns**: `pong: hello`
|
|
52
|
+
|
|
53
|
+
#### openBrowser
|
|
54
|
+
Opens browser and navigates to URL. Browser stays open for further interactions.
|
|
55
|
+
- **Parameters**: `url` (required)
|
|
56
|
+
- **Use case**: First step before other tools
|
|
57
|
+
- **Returns**: Page title + confirmation
|
|
58
|
+
|
|
59
|
+
### 2. Interaction Tools
|
|
60
|
+
|
|
61
|
+
#### click
|
|
62
|
+
Click an element and capture result screenshot.
|
|
63
|
+
- **Parameters**:
|
|
64
|
+
- `selector` (required): CSS selector
|
|
65
|
+
- `waitAfter` (optional): Wait time in ms (default: 1500)
|
|
66
|
+
- **Use case**: Buttons, links, form submissions
|
|
67
|
+
- **Returns**: Confirmation text + screenshot
|
|
68
|
+
|
|
69
|
+
#### type
|
|
70
|
+
Type text into input fields with optional clearing and typing delay.
|
|
71
|
+
- **Parameters**:
|
|
72
|
+
- `selector` (required): CSS selector
|
|
73
|
+
- `text` (required): Text to type
|
|
74
|
+
- `delay` (optional): Delay between keystrokes in ms
|
|
75
|
+
- `clearFirst` (optional): Clear field first (default: true)
|
|
76
|
+
- **Use case**: Filling forms, search boxes, text inputs
|
|
77
|
+
- **Returns**: Confirmation text
|
|
78
|
+
|
|
79
|
+
#### scrollTo
|
|
80
|
+
Scroll page to bring element into view.
|
|
81
|
+
- **Parameters**:
|
|
82
|
+
- `selector` (required): CSS selector
|
|
83
|
+
- `behavior` (optional): "auto" or "smooth"
|
|
84
|
+
- **Use case**: Lazy loading, sticky elements, visibility checks
|
|
85
|
+
- **Returns**: Final scroll position
|
|
86
|
+
|
|
87
|
+
### 3. Inspection Tools
|
|
88
|
+
|
|
89
|
+
#### getElement
|
|
90
|
+
Get HTML markup of element (defaults to body if no selector).
|
|
91
|
+
- **Parameters**: `selector` (optional)
|
|
92
|
+
- **Use case**: Inspecting structure, debugging markup
|
|
93
|
+
- **Returns**: Complete outerHTML
|
|
94
|
+
|
|
95
|
+
#### getComputedCss
|
|
96
|
+
Get all computed CSS styles for an element.
|
|
97
|
+
- **Parameters**: `selector` (optional)
|
|
98
|
+
- **Use case**: Debugging layout, verifying styles
|
|
99
|
+
- **Returns**: JSON object with CSS properties
|
|
100
|
+
|
|
101
|
+
#### getBoxModel
|
|
102
|
+
Get precise dimensions, positioning, margins, padding, and borders.
|
|
103
|
+
- **Parameters**: `selector` (required)
|
|
104
|
+
- **Use case**: Pixel-perfect measurements, layout analysis
|
|
105
|
+
- **Returns**: Box model data + metrics
|
|
106
|
+
|
|
107
|
+
#### screenshot
|
|
108
|
+
Capture PNG screenshot of specific element.
|
|
109
|
+
- **Parameters**:
|
|
110
|
+
- `selector` (required)
|
|
111
|
+
- `padding` (optional): Padding in pixels
|
|
112
|
+
- **Use case**: Visual documentation, bug reports
|
|
113
|
+
- **Returns**: Base64 PNG image
|
|
114
|
+
|
|
115
|
+
### 4. Advanced Tools
|
|
116
|
+
|
|
117
|
+
#### executeScript
|
|
118
|
+
Execute arbitrary JavaScript in page context.
|
|
119
|
+
- **Parameters**:
|
|
120
|
+
- `script` (required): JavaScript code
|
|
121
|
+
- `waitAfter` (optional): Wait time in ms (default: 500)
|
|
122
|
+
- **Use case**: Complex interactions, custom manipulations
|
|
123
|
+
- **Returns**: Execution result + screenshot
|
|
124
|
+
|
|
125
|
+
#### getConsoleLogs
|
|
126
|
+
Retrieve browser console logs (log, warn, error, etc.).
|
|
127
|
+
- **Parameters**:
|
|
128
|
+
- `types` (optional): Array of log types to filter
|
|
129
|
+
- `clear` (optional): Clear logs after reading (default: false)
|
|
130
|
+
- **Use case**: Debugging JavaScript errors, tracking behavior
|
|
131
|
+
- **Returns**: Array of log entries with timestamps
|
|
132
|
+
|
|
133
|
+
#### hover
|
|
134
|
+
Simulate mouse hover over element.
|
|
135
|
+
- **Parameters**: `selector` (required)
|
|
136
|
+
- **Use case**: Testing hover effects, tooltips, dropdown menus
|
|
137
|
+
- **Returns**: Confirmation text
|
|
138
|
+
|
|
139
|
+
#### setStyles
|
|
140
|
+
Apply inline CSS styles to element for live editing.
|
|
141
|
+
- **Parameters**:
|
|
142
|
+
- `selector` (required)
|
|
143
|
+
- `styles` (required): Array of {name, value} pairs
|
|
144
|
+
- **Use case**: Testing design changes, rapid prototyping
|
|
145
|
+
- **Returns**: Applied styles confirmation
|
|
146
|
+
|
|
147
|
+
#### setViewport
|
|
148
|
+
Change viewport dimensions for responsive testing.
|
|
149
|
+
- **Parameters**:
|
|
150
|
+
- `width` (required): 320-4000px
|
|
151
|
+
- `height` (required): 200-3000px
|
|
152
|
+
- `deviceScaleFactor` (optional): 0.5-3 (default: 1)
|
|
153
|
+
- **Use case**: Testing mobile, tablet, desktop layouts
|
|
154
|
+
- **Returns**: Actual viewport dimensions
|
|
155
|
+
|
|
156
|
+
#### getViewport
|
|
157
|
+
Get current viewport size and device pixel ratio.
|
|
158
|
+
- **Parameters**: None
|
|
159
|
+
- **Use case**: Checking current screen dimensions
|
|
160
|
+
- **Returns**: Viewport metrics (width, height, DPR)
|
|
161
|
+
|
|
162
|
+
#### navigateTo
|
|
163
|
+
Navigate to different URL while keeping browser instance.
|
|
164
|
+
- **Parameters**:
|
|
165
|
+
- `url` (required)
|
|
166
|
+
- `waitUntil` (optional): load event type
|
|
167
|
+
- **Use case**: Moving between pages in workflow
|
|
168
|
+
- **Returns**: New page title
|
|
169
|
+
|
|
170
|
+
---
|
|
171
|
+
|
|
172
|
+
## Typical Workflow Example
|
|
173
|
+
|
|
174
|
+
```javascript
|
|
175
|
+
// 1. Open page
|
|
176
|
+
openBrowser({ url: "https://example.com/form" })
|
|
177
|
+
|
|
178
|
+
// 2. Fill form
|
|
179
|
+
type({ selector: "input[name='email']", text: "user@example.com" })
|
|
180
|
+
type({ selector: "input[name='password']", text: "secret123" })
|
|
181
|
+
|
|
182
|
+
// 3. Submit
|
|
183
|
+
click({ selector: "button[type='submit']" })
|
|
184
|
+
|
|
185
|
+
// 4. Verify
|
|
186
|
+
getElement({ selector: ".success-message" })
|
|
187
|
+
screenshot({ selector: ".dashboard", padding: 20 })
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
---
|
|
191
|
+
|
|
192
|
+
## Tool Usage Tips
|
|
193
|
+
|
|
194
|
+
**Persistent Browser:**
|
|
195
|
+
- Browser windows remain open after each command
|
|
196
|
+
- Manual interaction possible between AI requests
|
|
197
|
+
- All tools work with currently open page
|
|
198
|
+
|
|
199
|
+
**Best Practices:**
|
|
200
|
+
- Start with `openBrowser` to establish context
|
|
201
|
+
- Use `screenshot` to verify visual results
|
|
202
|
+
- Combine tools for complex workflows
|
|
203
|
+
- Tools use CDP (Chrome DevTools Protocol) for precision
|
|
204
|
+
|
|
205
|
+
## Configuration
|
|
206
|
+
|
|
207
|
+
### Basic Configuration (Linux, macOS, Windows)
|
|
208
|
+
|
|
209
|
+
Add the MCP server to your MCP client configuration file:
|
|
210
|
+
|
|
211
|
+
**Claude Desktop** (`~/.claude/mcp_config.json` or `~/AppData/Roaming/Claude/mcp_config.json` on Windows):
|
|
212
|
+
|
|
213
|
+
```json
|
|
214
|
+
{
|
|
215
|
+
"mcpServers": {
|
|
216
|
+
"chrometools": {
|
|
217
|
+
"command": "npx",
|
|
218
|
+
"args": ["-y", "chrometools-mcp"]
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
**Claude Code** (`~/.claude.json`):
|
|
225
|
+
|
|
226
|
+
```json
|
|
227
|
+
{
|
|
228
|
+
"mcpServers": {
|
|
229
|
+
"chrometools": {
|
|
230
|
+
"type": "stdio",
|
|
231
|
+
"command": "npx",
|
|
232
|
+
"args": ["-y", "chrometools-mcp"],
|
|
233
|
+
"env": {}
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
### GUI Mode vs Headless Mode
|
|
240
|
+
|
|
241
|
+
The MCP server runs Chrome with `headless: false` by default, which means:
|
|
242
|
+
- ✅ Browser windows are visible on your screen
|
|
243
|
+
- ✅ You can interact with pages between AI requests
|
|
244
|
+
- ✅ You can see what the automation is doing in real-time
|
|
245
|
+
|
|
246
|
+
**Requirements for GUI Mode:**
|
|
247
|
+
- **Linux/macOS**: X server (usually available by default)
|
|
248
|
+
- **WSL (Windows Subsystem for Linux)**: Requires X server setup (see WSL Setup Guide below)
|
|
249
|
+
- **Windows**: No additional setup needed
|
|
250
|
+
|
|
251
|
+
**Alternative: Headless Mode with Virtual Display (xvfb)**
|
|
252
|
+
|
|
253
|
+
If you don't need to see the browser window, you can use xvfb (virtual X server):
|
|
254
|
+
|
|
255
|
+
```json
|
|
256
|
+
{
|
|
257
|
+
"mcpServers": {
|
|
258
|
+
"chrometools": {
|
|
259
|
+
"type": "stdio",
|
|
260
|
+
"command": "xvfb-run",
|
|
261
|
+
"args": ["-a", "npx", "-y", "chrometools-mcp"],
|
|
262
|
+
"env": {}
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
```
|
|
267
|
+
|
|
268
|
+
This runs Chrome in GUI mode but on a virtual display (window is not visible).
|
|
269
|
+
|
|
270
|
+
---
|
|
271
|
+
|
|
272
|
+
## WSL Setup Guide
|
|
273
|
+
|
|
274
|
+
If you're using **Windows Subsystem for Linux (WSL)**, special configuration is required to display Chrome GUI windows.
|
|
275
|
+
|
|
276
|
+
📖 **See the complete WSL Setup Guide:** [WSL_SETUP.md](WSL_SETUP.md)
|
|
277
|
+
|
|
278
|
+
The guide includes:
|
|
279
|
+
- Step-by-step VcXsrv installation and configuration
|
|
280
|
+
- MCP server configuration for WSL (3 different options)
|
|
281
|
+
- Testing and troubleshooting procedures
|
|
282
|
+
- Solutions for common issues
|
|
283
|
+
- All reference links and resources
|
|
284
|
+
|
|
285
|
+
**Quick Summary for WSL Users:**
|
|
286
|
+
1. Install VcXsrv on Windows ([Download](https://sourceforge.net/projects/vcxsrv/))
|
|
287
|
+
2. Enable "Disable access control" in VcXsrv settings ⚠️ (Critical!)
|
|
288
|
+
3. Configure MCP server with `DISPLAY=<your-windows-ip>:0` environment variable
|
|
289
|
+
4. Fully restart your MCP client
|
|
290
|
+
|
|
291
|
+
For detailed instructions, see [WSL_SETUP.md](WSL_SETUP.md).
|
|
292
|
+
|
|
293
|
+
---
|
|
294
|
+
|
|
295
|
+
## Development
|
|
296
|
+
|
|
297
|
+
```bash
|
|
298
|
+
# Install dependencies
|
|
299
|
+
npm install
|
|
300
|
+
|
|
301
|
+
# Run locally
|
|
302
|
+
npm start
|
|
303
|
+
|
|
304
|
+
# Test with MCP inspector
|
|
305
|
+
npx @modelcontextprotocol/inspector node index.js
|
|
306
|
+
```
|
|
307
|
+
|
|
308
|
+
## Features
|
|
309
|
+
|
|
310
|
+
- **16 Powerful Tools**: Complete toolkit for browser automation
|
|
311
|
+
- Core: ping, openBrowser
|
|
312
|
+
- Interaction: click, type, scrollTo
|
|
313
|
+
- Inspection: getElement, getComputedCss, getBoxModel, screenshot
|
|
314
|
+
- Advanced: executeScript, getConsoleLogs, hover, setStyles, setViewport, getViewport, navigateTo
|
|
315
|
+
- **Console Log Capture**: Automatic JavaScript console monitoring
|
|
316
|
+
- **Persistent Browser Sessions**: Browser tabs remain open between requests
|
|
317
|
+
- **Visual Browser (GUI Mode)**: See automation in real-time
|
|
318
|
+
- **Cross-platform**: Works on Windows/WSL, Linux, macOS
|
|
319
|
+
- **Simple Installation**: One command with npx
|
|
320
|
+
- **CDP Integration**: Uses Chrome DevTools Protocol for precision
|
|
321
|
+
- **AI-Friendly**: Detailed descriptions optimized for AI agents
|
|
322
|
+
- **Responsive Testing**: Built-in viewport control for mobile/tablet/desktop
|
|
323
|
+
|
|
324
|
+
## Architecture
|
|
325
|
+
|
|
326
|
+
- Uses Puppeteer for Chrome automation
|
|
327
|
+
- MCP Server SDK for protocol implementation
|
|
328
|
+
- Zod for schema validation
|
|
329
|
+
- Stdio transport for communication
|
package/WSL_SETUP.md
ADDED
|
@@ -0,0 +1,270 @@
|
|
|
1
|
+
# WSL Setup Guide for chrometools-mcp
|
|
2
|
+
|
|
3
|
+
If you're using **Windows Subsystem for Linux (WSL)**, follow these steps to enable visible Chrome GUI windows.
|
|
4
|
+
|
|
5
|
+
> **Note:** This setup is based on the solution from [Puppeteer Issue #8148](https://github.com/puppeteer/puppeteer/issues/8148#issuecomment-1195390456):
|
|
6
|
+
>
|
|
7
|
+
> _"I was able to partially resolve this issue using VcXsrv Windows X Server, and with the help of this guide [...] now when I enter `google-chrome` into my WSL Ubuntu terminal, it launches and works just fine."_
|
|
8
|
+
> — Solution tested on Ubuntu WSL2 on Windows 11
|
|
9
|
+
|
|
10
|
+
## Table of Contents
|
|
11
|
+
|
|
12
|
+
- [Why WSL Needs Special Setup?](#why-wsl-needs-special-setup)
|
|
13
|
+
- [Step 1: Install VcXsrv Windows X Server](#step-1-install-vcxsrv-windows-x-server)
|
|
14
|
+
- [Step 2: Configure VcXsrv (First Time Setup)](#step-2-configure-vcxsrv-first-time-setup)
|
|
15
|
+
- [Step 3: Configure MCP Server for WSL](#step-3-configure-mcp-server-for-wsl)
|
|
16
|
+
- [Step 4: Test the Setup](#step-4-test-the-setup)
|
|
17
|
+
- [Step 5: Restart MCP Client](#step-5-restart-mcp-client)
|
|
18
|
+
- [Troubleshooting WSL](#troubleshooting-wsl)
|
|
19
|
+
- [References](#references-for-wsl-setup)
|
|
20
|
+
|
|
21
|
+
---
|
|
22
|
+
|
|
23
|
+
## Why WSL Needs Special Setup?
|
|
24
|
+
|
|
25
|
+
WSL runs Linux in a separate environment from Windows. To display GUI applications (like Chrome), you need an X server running on Windows that WSL can connect to.
|
|
26
|
+
|
|
27
|
+
## Step 1: Install VcXsrv Windows X Server
|
|
28
|
+
|
|
29
|
+
VcXsrv is a free X server for Windows that allows WSL Linux applications to display GUI windows.
|
|
30
|
+
|
|
31
|
+
**Download and Install:**
|
|
32
|
+
1. Download VcXsrv: [https://sourceforge.net/projects/vcxsrv/](https://sourceforge.net/projects/vcxsrv/)
|
|
33
|
+
2. Run the installer (default settings are fine)
|
|
34
|
+
3. Launch **XLaunch** from Start Menu or Desktop
|
|
35
|
+
|
|
36
|
+
## Step 2: Configure VcXsrv (First Time Setup)
|
|
37
|
+
|
|
38
|
+
When you launch XLaunch for the first time, configure it as follows:
|
|
39
|
+
|
|
40
|
+
**Screen 1: Display settings**
|
|
41
|
+
- ✅ Select **"Multiple windows"** (recommended for WSL)
|
|
42
|
+
- Display number: `0` (leave default)
|
|
43
|
+
- Click "Next"
|
|
44
|
+
|
|
45
|
+
**Screen 2: Client startup**
|
|
46
|
+
- ✅ Select **"Start no client"** (recommended)
|
|
47
|
+
- Click "Next"
|
|
48
|
+
|
|
49
|
+
**Screen 3: Extra settings** ⚠️ **IMPORTANT**
|
|
50
|
+
- ☑️ **"Clipboard"** (optional, convenient for copy-paste)
|
|
51
|
+
- ☑️ **"Disable access control"** ✅ **MUST BE ENABLED!**
|
|
52
|
+
- This allows WSL to connect to the X server
|
|
53
|
+
- Without this, you'll get "Connection refused" errors
|
|
54
|
+
- Click "Next"
|
|
55
|
+
|
|
56
|
+
**Screen 4: Finish**
|
|
57
|
+
- Optionally save configuration as `.xlaunch` file for quick restart
|
|
58
|
+
- Place saved file in Windows Startup folder for automatic launch
|
|
59
|
+
- Click "Finish"
|
|
60
|
+
|
|
61
|
+
**Verify VcXsrv is Running:**
|
|
62
|
+
- Check for VcXsrv icon in Windows system tray (bottom-right)
|
|
63
|
+
- If you see the icon, VcXsrv is running
|
|
64
|
+
|
|
65
|
+
## Step 3: Configure MCP Server for WSL
|
|
66
|
+
|
|
67
|
+
**Find your Windows host IP address:**
|
|
68
|
+
|
|
69
|
+
In WSL terminal, run:
|
|
70
|
+
```bash
|
|
71
|
+
ip route show | grep -i default | awk '{print $3}'
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
You should see an IP like `172.x.x.1` (commonly `172.25.96.1` or similar).
|
|
75
|
+
|
|
76
|
+
### Option A: Using Environment Variable (Recommended)
|
|
77
|
+
|
|
78
|
+
Configure the MCP server with `DISPLAY` pointing to your Windows host:
|
|
79
|
+
|
|
80
|
+
```json
|
|
81
|
+
{
|
|
82
|
+
"mcpServers": {
|
|
83
|
+
"chrometools": {
|
|
84
|
+
"type": "stdio",
|
|
85
|
+
"command": "npx",
|
|
86
|
+
"args": ["-y", "chrometools-mcp"],
|
|
87
|
+
"env": {
|
|
88
|
+
"DISPLAY": "172.25.96.1:0"
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
⚠️ **Replace `172.25.96.1` with your actual Windows host IP!**
|
|
96
|
+
|
|
97
|
+
### Option B: Using Direct Node Path (For Claude Code)
|
|
98
|
+
|
|
99
|
+
If you're using Claude Code, use the full path to node:
|
|
100
|
+
|
|
101
|
+
```json
|
|
102
|
+
{
|
|
103
|
+
"mcpServers": {
|
|
104
|
+
"chrometools": {
|
|
105
|
+
"type": "stdio",
|
|
106
|
+
"command": "/home/user/.nvm/versions/node/v22.20.0/bin/node",
|
|
107
|
+
"args": ["/path/to/chrometools-mcp/index.js"],
|
|
108
|
+
"env": {
|
|
109
|
+
"DISPLAY": "172.25.96.1:0"
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
### Option C: Using xvfb (No VcXsrv Required)
|
|
117
|
+
|
|
118
|
+
If you don't want to install VcXsrv, you can use xvfb (virtual display):
|
|
119
|
+
|
|
120
|
+
```bash
|
|
121
|
+
# Install xvfb in WSL
|
|
122
|
+
sudo apt-get update
|
|
123
|
+
sudo apt-get install -y xvfb
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
Then configure:
|
|
127
|
+
|
|
128
|
+
```json
|
|
129
|
+
{
|
|
130
|
+
"mcpServers": {
|
|
131
|
+
"chrometools": {
|
|
132
|
+
"type": "stdio",
|
|
133
|
+
"command": "xvfb-run",
|
|
134
|
+
"args": ["-a", "npx", "-y", "chrometools-mcp"],
|
|
135
|
+
"env": {}
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
**Note:** With xvfb, the browser runs but windows are **not visible**. This is useful for automation without GUI.
|
|
142
|
+
|
|
143
|
+
## Step 4: Test the Setup
|
|
144
|
+
|
|
145
|
+
### Test VcXsrv Connection (if using GUI mode)
|
|
146
|
+
|
|
147
|
+
In WSL terminal:
|
|
148
|
+
```bash
|
|
149
|
+
# Set DISPLAY variable (use your Windows host IP)
|
|
150
|
+
export DISPLAY=172.25.96.1:0
|
|
151
|
+
|
|
152
|
+
# Test X server connection
|
|
153
|
+
timeout 3 nc -zv 172.25.96.1 6000
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
Expected output: `Connection to 172.25.96.1 6000 port [tcp/x11] succeeded!`
|
|
157
|
+
|
|
158
|
+
If you get "Connection refused", check:
|
|
159
|
+
- VcXsrv is running (icon in system tray)
|
|
160
|
+
- "Disable access control" is enabled in XLaunch settings
|
|
161
|
+
- Windows Firewall is not blocking port 6000
|
|
162
|
+
|
|
163
|
+
### Test Chrome GUI
|
|
164
|
+
|
|
165
|
+
```bash
|
|
166
|
+
# Test with a simple command
|
|
167
|
+
DISPLAY=172.25.96.1:0 google-chrome https://example.com
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
You should see a Chrome window appear on your screen with example.com loaded!
|
|
171
|
+
|
|
172
|
+
## Step 5: Restart MCP Client
|
|
173
|
+
|
|
174
|
+
After configuring, **fully restart your MCP client** (Claude Desktop or Claude Code):
|
|
175
|
+
- Close the application completely
|
|
176
|
+
- Relaunch it
|
|
177
|
+
- The MCP server will now use the new configuration
|
|
178
|
+
|
|
179
|
+
## Troubleshooting WSL
|
|
180
|
+
|
|
181
|
+
### Problem: "Missing X server" error
|
|
182
|
+
|
|
183
|
+
```
|
|
184
|
+
Error: Missing X server to start the headful browser.
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
**Solutions:**
|
|
188
|
+
1. Make sure VcXsrv is running (check system tray)
|
|
189
|
+
2. Verify "Disable access control" is enabled in VcXsrv
|
|
190
|
+
3. Check DISPLAY variable is set correctly in MCP config
|
|
191
|
+
4. Test X server connection: `nc -zv 172.25.96.1 6000`
|
|
192
|
+
5. Fully restart MCP client after config changes
|
|
193
|
+
|
|
194
|
+
### Problem: Browser opens but window is not visible
|
|
195
|
+
|
|
196
|
+
**Cause:** MCP server is using xvfb (virtual display) instead of VcXsrv.
|
|
197
|
+
|
|
198
|
+
**Solution:**
|
|
199
|
+
1. Check your config has `"env": { "DISPLAY": "172.25.96.1:0" }`
|
|
200
|
+
2. Make sure you're **not** using `xvfb-run` in the command
|
|
201
|
+
3. Fully restart MCP client (close and reopen)
|
|
202
|
+
4. Check process: `ps aux | grep chrometools` - should NOT show `xvfb-run`
|
|
203
|
+
|
|
204
|
+
### Problem: Windows Firewall blocking connection
|
|
205
|
+
|
|
206
|
+
If `nc -zv 172.25.96.1 6000` fails, Windows Firewall might be blocking the connection.
|
|
207
|
+
|
|
208
|
+
**Solution:**
|
|
209
|
+
1. Open Windows Defender Firewall
|
|
210
|
+
2. Click "Allow an app or feature through Windows Defender Firewall"
|
|
211
|
+
3. Find "VcXsrv windows xserver" and enable it for Private networks
|
|
212
|
+
4. If not listed, click "Allow another app" and add `vcxsrv.exe`
|
|
213
|
+
|
|
214
|
+
### Problem: IP address changes after Windows restart
|
|
215
|
+
|
|
216
|
+
WSL assigns a new IP to Windows host after each restart.
|
|
217
|
+
|
|
218
|
+
**Solution:** Create a startup script to get current IP:
|
|
219
|
+
|
|
220
|
+
```bash
|
|
221
|
+
# In WSL ~/.bashrc or ~/.zshrc
|
|
222
|
+
export DISPLAY=$(ip route show | grep -i default | awk '{print $3}'):0
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
Or use a helper script:
|
|
226
|
+
```bash
|
|
227
|
+
#!/bin/bash
|
|
228
|
+
# ~/.local/bin/win-ip.sh
|
|
229
|
+
ip route show | grep -i default | awk '{print $3}'
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
## References for WSL Setup
|
|
233
|
+
|
|
234
|
+
These resources were instrumental in solving the WSL + Puppeteer GUI setup:
|
|
235
|
+
|
|
236
|
+
- **VcXsrv Windows X Server** (Free X server for Windows)
|
|
237
|
+
[https://sourceforge.net/projects/vcxsrv/](https://sourceforge.net/projects/vcxsrv/)
|
|
238
|
+
|
|
239
|
+
- **ChromeDriver in WSL2** by Greg Brisebois (Comprehensive setup guide)
|
|
240
|
+
[https://www.gregbrisebois.com/posts/chromedriver-in-wsl2/](https://www.gregbrisebois.com/posts/chromedriver-in-wsl2/)
|
|
241
|
+
|
|
242
|
+
- **Puppeteer Issue #8148** (Missing X server or $DISPLAY)
|
|
243
|
+
- Main issue thread: [https://github.com/puppeteer/puppeteer/issues/8148](https://github.com/puppeteer/puppeteer/issues/8148)
|
|
244
|
+
- Solution comment: [https://github.com/puppeteer/puppeteer/issues/8148#issuecomment-1195390456](https://github.com/puppeteer/puppeteer/issues/8148#issuecomment-1195390456)
|
|
245
|
+
|
|
246
|
+
- **Stack Overflow: WSL2 X Server Setup**
|
|
247
|
+
[https://stackoverflow.com/a/66398613](https://stackoverflow.com/a/66398613)
|
|
248
|
+
|
|
249
|
+
**Additional Resources:**
|
|
250
|
+
- [WSL GUI Apps Official Documentation](https://learn.microsoft.com/en-us/windows/wsl/tutorials/gui-apps) (Microsoft)
|
|
251
|
+
- [Puppeteer Troubleshooting Guide](https://pptr.dev/troubleshooting) (Official Docs)
|
|
252
|
+
|
|
253
|
+
---
|
|
254
|
+
|
|
255
|
+
## Quick Summary
|
|
256
|
+
|
|
257
|
+
**For visible Chrome windows in WSL:**
|
|
258
|
+
1. Install and run VcXsrv on Windows
|
|
259
|
+
2. Enable "Disable access control" in VcXsrv settings
|
|
260
|
+
3. Get Windows host IP: `ip route show | grep -i default | awk '{print $3}'`
|
|
261
|
+
4. Configure MCP server with `DISPLAY=<your-ip>:0` in env
|
|
262
|
+
5. Fully restart MCP client
|
|
263
|
+
6. Test: `DISPLAY=172.25.96.1:0 google-chrome https://example.com`
|
|
264
|
+
|
|
265
|
+
**For headless automation (no visible windows):**
|
|
266
|
+
1. Install xvfb: `sudo apt-get install xvfb`
|
|
267
|
+
2. Configure MCP server with `xvfb-run` command
|
|
268
|
+
3. Restart MCP client
|
|
269
|
+
|
|
270
|
+
[← Back to README](README.md)
|