browser-devtools-mcp 0.0.1
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 +21 -0
- package/README.md +652 -0
- package/dist/browser.js +67 -0
- package/dist/browser.js.map +1 -0
- package/dist/config.js +11 -0
- package/dist/config.js.map +1 -0
- package/dist/context.js +210 -0
- package/dist/context.js.map +1 -0
- package/dist/index.js +296 -0
- package/dist/index.js.map +1 -0
- package/dist/logger.js +97 -0
- package/dist/logger.js.map +1 -0
- package/dist/server-info.js +33 -0
- package/dist/server-info.js.map +1 -0
- package/dist/server.js +131 -0
- package/dist/server.js.map +1 -0
- package/dist/tools/content/get-as-html.js +164 -0
- package/dist/tools/content/get-as-html.js.map +1 -0
- package/dist/tools/content/get-as-text.js +76 -0
- package/dist/tools/content/get-as-text.js.map +1 -0
- package/dist/tools/content/index.js +16 -0
- package/dist/tools/content/index.js.map +1 -0
- package/dist/tools/content/save-as-pdf.js +146 -0
- package/dist/tools/content/save-as-pdf.js.map +1 -0
- package/dist/tools/content/take-aria-snapshot.js +49 -0
- package/dist/tools/content/take-aria-snapshot.js.map +1 -0
- package/dist/tools/content/take-screenshot.js +113 -0
- package/dist/tools/content/take-screenshot.js.map +1 -0
- package/dist/tools/index.js +29 -0
- package/dist/tools/index.js.map +1 -0
- package/dist/tools/interaction/click.js +29 -0
- package/dist/tools/interaction/click.js.map +1 -0
- package/dist/tools/interaction/drag.js +41 -0
- package/dist/tools/interaction/drag.js.map +1 -0
- package/dist/tools/interaction/evaluate.js +33 -0
- package/dist/tools/interaction/evaluate.js.map +1 -0
- package/dist/tools/interaction/fill.js +28 -0
- package/dist/tools/interaction/fill.js.map +1 -0
- package/dist/tools/interaction/hover.js +29 -0
- package/dist/tools/interaction/hover.js.map +1 -0
- package/dist/tools/interaction/index.js +20 -0
- package/dist/tools/interaction/index.js.map +1 -0
- package/dist/tools/interaction/press-key.js +36 -0
- package/dist/tools/interaction/press-key.js.map +1 -0
- package/dist/tools/interaction/select.js +30 -0
- package/dist/tools/interaction/select.js.map +1 -0
- package/dist/tools/monitoring/get-console-messages.js +151 -0
- package/dist/tools/monitoring/get-console-messages.js.map +1 -0
- package/dist/tools/monitoring/get-http-requests.js +216 -0
- package/dist/tools/monitoring/get-http-requests.js.map +1 -0
- package/dist/tools/monitoring/index.js +7 -0
- package/dist/tools/monitoring/index.js.map +1 -0
- package/dist/tools/navigation/go-back.js +76 -0
- package/dist/tools/navigation/go-back.js.map +1 -0
- package/dist/tools/navigation/go-forward.js +76 -0
- package/dist/tools/navigation/go-forward.js.map +1 -0
- package/dist/tools/navigation/go-to.js +80 -0
- package/dist/tools/navigation/go-to.js.map +1 -0
- package/dist/tools/navigation/index.js +8 -0
- package/dist/tools/navigation/index.js.map +1 -0
- package/dist/tools/tool-executor.js +57 -0
- package/dist/tools/tool-executor.js.map +1 -0
- package/dist/tools/types.js +3 -0
- package/dist/tools/types.js.map +1 -0
- package/dist/types.js +55 -0
- package/dist/types.js.map +1 -0
- package/dist/utils.js +47 -0
- package/dist/utils.js.map +1 -0
- package/package.json +73 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Serkan ÖZAL
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,652 @@
|
|
|
1
|
+
# Browser DevTools MCP
|
|
2
|
+
|
|
3
|
+

|
|
4
|
+

|
|
5
|
+

|
|
6
|
+
|
|
7
|
+
A powerful [Model Context Protocol (MCP)](https://modelcontextprotocol.io) server that provides AI coding assistants with comprehensive browser automation and debugging capabilities using Playwright. This server enables both **execution-level debugging** (logs, network requests) and **visual debugging** (screenshots, ARIA snapshots) to help AI assistants understand and interact with web pages effectively.
|
|
8
|
+
|
|
9
|
+
## Overview
|
|
10
|
+
|
|
11
|
+
Browser DevTools MCP exposes a Playwright-powered browser runtime to AI agents, enabling deep, bidirectional debugging and interaction with live web pages. It supports both visual understanding and code-level inspection of browser state, making it ideal for AI-driven exploration, diagnosis, and automation.
|
|
12
|
+
|
|
13
|
+
### Key Capabilities
|
|
14
|
+
|
|
15
|
+
- **Visual Inspection**: Screenshots, ARIA snapshots, HTML/text extraction, PDF generation
|
|
16
|
+
- **DOM & Code-Level Debugging**: Element inspection, computed styles, accessibility data
|
|
17
|
+
- **Browser Automation**: Navigation, input, clicking, scrolling, viewport control
|
|
18
|
+
- **Execution Monitoring**: Console message capture, HTTP request/response tracking
|
|
19
|
+
- **JavaScript Evaluation**: Execute code in page context
|
|
20
|
+
- **Session Management**: Long-lived, session-based debugging with automatic cleanup
|
|
21
|
+
- **Multiple Transport Modes**: Supports both stdio and HTTP transports
|
|
22
|
+
|
|
23
|
+
## Features
|
|
24
|
+
|
|
25
|
+
### Content Tools
|
|
26
|
+
- **Screenshots**: Capture full page or specific elements (PNG/JPEG)
|
|
27
|
+
- **ARIA Snapshots**: Accessibility tree capture for understanding page structure
|
|
28
|
+
- **HTML/Text Extraction**: Get page content in various formats
|
|
29
|
+
- **PDF Export**: Save pages as PDF documents
|
|
30
|
+
|
|
31
|
+
### Interaction Tools
|
|
32
|
+
- **Click**: Click elements by CSS selector
|
|
33
|
+
- **Fill**: Fill form inputs
|
|
34
|
+
- **Hover**: Hover over elements
|
|
35
|
+
- **Press Key**: Simulate keyboard input
|
|
36
|
+
- **Select**: Select dropdown options
|
|
37
|
+
- **Drag**: Drag and drop operations
|
|
38
|
+
- **Evaluate**: Execute JavaScript in page context
|
|
39
|
+
|
|
40
|
+
### Navigation Tools
|
|
41
|
+
- **Go To**: Navigate to URLs with configurable wait strategies
|
|
42
|
+
- **Go Back**: Navigate backward in history
|
|
43
|
+
- **Go Forward**: Navigate forward in history
|
|
44
|
+
|
|
45
|
+
### Monitoring Tools
|
|
46
|
+
- **Console Messages**: Capture and filter browser console logs with advanced filtering (level, search, timestamp, sequence number)
|
|
47
|
+
- **HTTP Requests**: Monitor network traffic with detailed request/response data, filtering by resource type, status code, and more
|
|
48
|
+
|
|
49
|
+
## Prerequisites
|
|
50
|
+
|
|
51
|
+
- Node.js 18+
|
|
52
|
+
- An AI assistant (with MCP client) like Cursor, Claude (Desktop or Code), VS Code, Windsurf, etc.
|
|
53
|
+
|
|
54
|
+
## Quick Start
|
|
55
|
+
|
|
56
|
+
This MCP server (using `STDIO` or `Streamable HTTP` transport) can be added to any MCP Client
|
|
57
|
+
like VS Code, Claude, Cursor, Windsurf, GitHub Copilot via the `browser-devtools-mcp` NPM package.
|
|
58
|
+
|
|
59
|
+
No manual installation required! The server can be run directly using `npx`, which automatically downloads and runs the package.
|
|
60
|
+
|
|
61
|
+
### CLI Arguments
|
|
62
|
+
|
|
63
|
+
Browser DevTools MCP server supports the following CLI arguments for configuration:
|
|
64
|
+
- `--transport <stdio|streamable-http>` - Configures the transport protocol (defaults to `stdio`).
|
|
65
|
+
- `--port <number>` – Configures the port number to listen on when using `streamable-http` transport (defaults to `3000`).
|
|
66
|
+
|
|
67
|
+
## MCP Client Configuration
|
|
68
|
+
|
|
69
|
+
### Claude Desktop
|
|
70
|
+
|
|
71
|
+
#### Local Server
|
|
72
|
+
Add the following configuration into the `claude_desktop_config.json` file.
|
|
73
|
+
See the [Claude Desktop MCP docs](https://modelcontextprotocol.io/docs/develop/connect-local-servers) for more info.
|
|
74
|
+
|
|
75
|
+
```json
|
|
76
|
+
{
|
|
77
|
+
"mcpServers": {
|
|
78
|
+
"browser-devtools": {
|
|
79
|
+
"command": "npx",
|
|
80
|
+
"args": ["-y", "browser-devtools-mcp"]
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
#### Remote Server (HTTP Transport)
|
|
87
|
+
First, start the server with HTTP transport:
|
|
88
|
+
```bash
|
|
89
|
+
npx -y browser-devtools-mcp --transport=streamable-http --port=3000
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
Then, go to `Settings` > `Connectors` > `Add Custom Connector` in Claude Desktop and add the MCP server with:
|
|
93
|
+
- Name: `Browser DevTools`
|
|
94
|
+
- Remote MCP server URL: Point to where your server is hosted (e.g., `http://localhost:3000/mcp` if running locally, or `https://your-server.com/mcp` if hosted remotely)
|
|
95
|
+
|
|
96
|
+
### Claude Code
|
|
97
|
+
|
|
98
|
+
Run the following command.
|
|
99
|
+
See [Claude Code MCP docs](https://docs.anthropic.com/en/docs/claude-code/mcp) for more info.
|
|
100
|
+
|
|
101
|
+
#### Local Server
|
|
102
|
+
```bash
|
|
103
|
+
claude mcp add browser-devtools -- npx -y browser-devtools-mcp
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
#### Remote Server
|
|
107
|
+
First, start the server with HTTP transport:
|
|
108
|
+
```bash
|
|
109
|
+
npx -y browser-devtools-mcp --transport=streamable-http --port=3000
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
Then add the MCP server:
|
|
113
|
+
```bash
|
|
114
|
+
claude mcp add --transport http browser-devtools <SERVER_URL>
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
Replace `<SERVER_URL>` with your server URL (e.g., `http://localhost:3000/mcp` if running locally, or `https://your-server.com/mcp` if hosted remotely).
|
|
118
|
+
|
|
119
|
+
### Cursor
|
|
120
|
+
|
|
121
|
+
Add the following configuration into the `~/.cursor/mcp.json` file (or `.cursor/mcp.json` in your project folder).
|
|
122
|
+
See the [Cursor MCP docs](https://docs.cursor.com/context/model-context-protocol) for more info.
|
|
123
|
+
|
|
124
|
+
#### Local Server
|
|
125
|
+
```json
|
|
126
|
+
{
|
|
127
|
+
"mcpServers": {
|
|
128
|
+
"browser-devtools": {
|
|
129
|
+
"command": "npx",
|
|
130
|
+
"args": ["-y", "browser-devtools-mcp"]
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
#### Remote Server
|
|
137
|
+
First, start the server with HTTP transport:
|
|
138
|
+
```bash
|
|
139
|
+
npx -y browser-devtools-mcp --transport=streamable-http --port=3000
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
Then add the configuration:
|
|
143
|
+
```json
|
|
144
|
+
{
|
|
145
|
+
"mcpServers": {
|
|
146
|
+
"browser-devtools": {
|
|
147
|
+
"url": "<SERVER_URL>"
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
Replace `<SERVER_URL>` with your server URL (e.g., `http://localhost:3000/mcp` if running locally, or `https://your-server.com/mcp` if hosted remotely).
|
|
154
|
+
|
|
155
|
+
### VS Code
|
|
156
|
+
|
|
157
|
+
Add the following configuration into the `.vscode/mcp.json` file.
|
|
158
|
+
See the [VS Code MCP docs](https://code.visualstudio.com/docs/copilot/chat/mcp-servers) for more info.
|
|
159
|
+
|
|
160
|
+
#### Local Server
|
|
161
|
+
```json
|
|
162
|
+
{
|
|
163
|
+
"mcp": {
|
|
164
|
+
"servers": {
|
|
165
|
+
"browser-devtools": {
|
|
166
|
+
"type": "stdio",
|
|
167
|
+
"command": "npx",
|
|
168
|
+
"args": ["-y", "browser-devtools-mcp"]
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
#### Remote Server
|
|
176
|
+
First, start the server with HTTP transport:
|
|
177
|
+
```bash
|
|
178
|
+
npx -y browser-devtools-mcp --transport=streamable-http --port=3000
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
Then add the configuration:
|
|
182
|
+
```json
|
|
183
|
+
{
|
|
184
|
+
"mcp": {
|
|
185
|
+
"servers": {
|
|
186
|
+
"browser-devtools": {
|
|
187
|
+
"type": "http",
|
|
188
|
+
"url": "<SERVER_URL>"
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
Replace `<SERVER_URL>` with your server URL (e.g., `http://localhost:3000/mcp` if running locally, or `https://your-server.com/mcp` if hosted remotely).
|
|
196
|
+
|
|
197
|
+
### Windsurf
|
|
198
|
+
|
|
199
|
+
Add the following configuration into the `~/.codeium/windsurf/mcp_config.json` file.
|
|
200
|
+
See the [Windsurf MCP docs](https://docs.windsurf.com/windsurf/cascade/mcp) for more info.
|
|
201
|
+
|
|
202
|
+
#### Local Server
|
|
203
|
+
```json
|
|
204
|
+
{
|
|
205
|
+
"mcpServers": {
|
|
206
|
+
"browser-devtools": {
|
|
207
|
+
"command": "npx",
|
|
208
|
+
"args": ["-y", "browser-devtools-mcp"]
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
#### Remote Server
|
|
215
|
+
First, start the server with HTTP transport:
|
|
216
|
+
```bash
|
|
217
|
+
npx -y browser-devtools-mcp --transport=streamable-http --port=3000
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
Then add the configuration:
|
|
221
|
+
```json
|
|
222
|
+
{
|
|
223
|
+
"mcpServers": {
|
|
224
|
+
"browser-devtools": {
|
|
225
|
+
"serverUrl": "<SERVER_URL>"
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
Replace `<SERVER_URL>` with your server URL (e.g., `http://localhost:3000/mcp` if running locally, or `https://your-server.com/mcp` if hosted remotely).
|
|
232
|
+
|
|
233
|
+
### Copilot Coding Agent
|
|
234
|
+
|
|
235
|
+
Add the following configuration to the `mcpServers` section of your Copilot Coding Agent configuration through
|
|
236
|
+
`Repository` > `Settings` > `Copilot` > `Coding agent` > `MCP configuration`.
|
|
237
|
+
See the [Copilot Coding Agent MCP docs](https://docs.github.com/en/enterprise-cloud@latest/copilot/how-tos/agents/copilot-coding-agent/extending-copilot-coding-agent-with-mcp) for more info.
|
|
238
|
+
|
|
239
|
+
#### Local Server
|
|
240
|
+
```json
|
|
241
|
+
{
|
|
242
|
+
"mcpServers": {
|
|
243
|
+
"browser-devtools": {
|
|
244
|
+
"type": "local",
|
|
245
|
+
"command": "npx",
|
|
246
|
+
"args": ["-y", "browser-devtools-mcp"]
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
```
|
|
251
|
+
|
|
252
|
+
#### Remote Server
|
|
253
|
+
First, start the server with HTTP transport:
|
|
254
|
+
```bash
|
|
255
|
+
npx -y browser-devtools-mcp --transport=streamable-http --port=3000
|
|
256
|
+
```
|
|
257
|
+
|
|
258
|
+
Then add the configuration:
|
|
259
|
+
```json
|
|
260
|
+
{
|
|
261
|
+
"mcpServers": {
|
|
262
|
+
"browser-devtools": {
|
|
263
|
+
"type": "http",
|
|
264
|
+
"url": "<SERVER_URL>"
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
```
|
|
269
|
+
|
|
270
|
+
Replace `<SERVER_URL>` with your server URL (e.g., `http://localhost:3000/mcp` if running locally, or `https://your-server.com/mcp` if hosted remotely).
|
|
271
|
+
|
|
272
|
+
### Gemini CLI
|
|
273
|
+
|
|
274
|
+
Add the following configuration into the `~/.gemini/settings.json` file.
|
|
275
|
+
See the [Gemini CLI MCP docs](https://google-gemini.github.io/gemini-cli/docs/tools/mcp-server.html) for more info.
|
|
276
|
+
|
|
277
|
+
#### Local Server
|
|
278
|
+
```json
|
|
279
|
+
{
|
|
280
|
+
"mcpServers": {
|
|
281
|
+
"browser-devtools": {
|
|
282
|
+
"command": "npx",
|
|
283
|
+
"args": ["-y", "browser-devtools-mcp"]
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
```
|
|
288
|
+
|
|
289
|
+
#### Remote Server
|
|
290
|
+
First, start the server with HTTP transport:
|
|
291
|
+
```bash
|
|
292
|
+
npx -y browser-devtools-mcp --transport=streamable-http --port=3000
|
|
293
|
+
```
|
|
294
|
+
|
|
295
|
+
Then add the configuration:
|
|
296
|
+
```json
|
|
297
|
+
{
|
|
298
|
+
"mcpServers": {
|
|
299
|
+
"browser-devtools": {
|
|
300
|
+
"httpUrl": "<SERVER_URL>"
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
```
|
|
305
|
+
|
|
306
|
+
Replace `<SERVER_URL>` with your server URL (e.g., `http://localhost:3000/mcp` if running locally, or `https://your-server.com/mcp` if hosted remotely).
|
|
307
|
+
|
|
308
|
+
### Smithery
|
|
309
|
+
|
|
310
|
+
Run the following command.
|
|
311
|
+
You can find your Smithery API key [here](https://smithery.ai/account/api-keys).
|
|
312
|
+
See the [Smithery CLI docs](https://smithery.ai/docs/concepts/cli) for more info.
|
|
313
|
+
|
|
314
|
+
```bash
|
|
315
|
+
npx -y @smithery/cli install serkan-ozal/browser-devtools-mcp --client <SMITHERY-CLIENT-NAME> --key <SMITHERY-API-KEY>
|
|
316
|
+
```
|
|
317
|
+
|
|
318
|
+
## HTTP Transport
|
|
319
|
+
|
|
320
|
+
To use HTTP transport, start the server with:
|
|
321
|
+
```bash
|
|
322
|
+
npx -y browser-devtools-mcp --transport=streamable-http --port=3000
|
|
323
|
+
```
|
|
324
|
+
|
|
325
|
+
The server exposes the following endpoints:
|
|
326
|
+
|
|
327
|
+
- `GET /health` - Health check
|
|
328
|
+
- `GET /ping` - Ping endpoint
|
|
329
|
+
- `GET /mcp` - MCP protocol info
|
|
330
|
+
- `POST /mcp` - MCP protocol messages
|
|
331
|
+
- `DELETE /mcp` - Delete session
|
|
332
|
+
|
|
333
|
+
**Important**: When configuring remote MCP servers, use the actual URL where your server is hosted:
|
|
334
|
+
- If running locally: `http://localhost:3000/mcp` (or `http://127.0.0.1:3000/mcp`)
|
|
335
|
+
- If hosted remotely: `https://your-server.com/mcp` (replace with your actual server URL)
|
|
336
|
+
|
|
337
|
+
## MCP Inspector
|
|
338
|
+
|
|
339
|
+
Test the server using the MCP Inspector:
|
|
340
|
+
|
|
341
|
+
```bash
|
|
342
|
+
# For stdio transport
|
|
343
|
+
npx -y @modelcontextprotocol/inspector npx -y browser-devtools-mcp
|
|
344
|
+
|
|
345
|
+
# For HTTP transport (start server first)
|
|
346
|
+
npx -y browser-devtools-mcp --transport=streamable-http --port=3000
|
|
347
|
+
# Then in another terminal:
|
|
348
|
+
npx -y @modelcontextprotocol/inspector http://localhost:3000/mcp --transport http
|
|
349
|
+
```
|
|
350
|
+
|
|
351
|
+
## Configuration
|
|
352
|
+
|
|
353
|
+
The server can be configured using environment variables:
|
|
354
|
+
|
|
355
|
+
| Variable | Description | Default |
|
|
356
|
+
|----------|-------------|---------|
|
|
357
|
+
| `PORT` | Port for HTTP transport | `3000` |
|
|
358
|
+
| `SESSION_IDLE_SECONDS` | Idle session timeout (seconds) | `300` |
|
|
359
|
+
| `SESSION_IDLE_CHECK_SECONDS` | Interval for checking idle sessions (seconds) | `30` |
|
|
360
|
+
| `SESSION_CLOSE_ON_SOCKET_CLOSE` | Close session when socket closes | `false` |
|
|
361
|
+
| `CONSOLE_MESSAGES_BUFFER_SIZE` | Maximum console messages to buffer | `1000` |
|
|
362
|
+
| `HTTP_REQUESTS_BUFFER_SIZE` | Maximum HTTP requests to buffer | `1000` |
|
|
363
|
+
| `BROWSER_EXECUTABLE_PATH` | Custom browser executable path | (uses Playwright default) |
|
|
364
|
+
|
|
365
|
+
## Available Tools
|
|
366
|
+
|
|
367
|
+
### Content Tools
|
|
368
|
+
|
|
369
|
+
#### `content_take-screenshot`
|
|
370
|
+
Takes a screenshot of the current page or a specific element.
|
|
371
|
+
|
|
372
|
+
**Parameters:**
|
|
373
|
+
- `outputPath` (string, required): Directory path where screenshot will be saved
|
|
374
|
+
- `name` (string, optional): Screenshot name (default: "screenshot")
|
|
375
|
+
- `selector` (string, optional): CSS selector for element to capture
|
|
376
|
+
- `fullPage` (boolean, optional): Capture full scrollable page (default: false)
|
|
377
|
+
- `type` (enum, optional): Image format - "png" or "jpeg" (default: "png")
|
|
378
|
+
|
|
379
|
+
**Returns:**
|
|
380
|
+
- `filePath` (string): Full path of the saved screenshot file
|
|
381
|
+
|
|
382
|
+
#### `content_take-aria-snapshot`
|
|
383
|
+
Captures an ARIA (accessibility) snapshot of the current page or a specific element.
|
|
384
|
+
|
|
385
|
+
**Parameters:**
|
|
386
|
+
- `selector` (string, optional): CSS selector for element to snapshot
|
|
387
|
+
|
|
388
|
+
**Returns:**
|
|
389
|
+
- `output` (string): YAML-formatted accessibility tree with page URL and title
|
|
390
|
+
|
|
391
|
+
#### `content_get-as-html`
|
|
392
|
+
Retrieves the HTML content of the current page or a specific element.
|
|
393
|
+
|
|
394
|
+
**Parameters:**
|
|
395
|
+
- `selector` (string, optional): CSS selector for element
|
|
396
|
+
|
|
397
|
+
**Returns:**
|
|
398
|
+
- `html` (string): HTML content
|
|
399
|
+
|
|
400
|
+
#### `content_get-as-text`
|
|
401
|
+
Retrieves the text content of the current page or a specific element.
|
|
402
|
+
|
|
403
|
+
**Parameters:**
|
|
404
|
+
- `selector` (string, optional): CSS selector for element
|
|
405
|
+
|
|
406
|
+
**Returns:**
|
|
407
|
+
- `text` (string): Text content
|
|
408
|
+
|
|
409
|
+
#### `content_save-as-pdf`
|
|
410
|
+
Saves the current page as a PDF document.
|
|
411
|
+
|
|
412
|
+
**Parameters:**
|
|
413
|
+
- `outputPath` (string, required): Directory path where PDF will be saved
|
|
414
|
+
- `name` (string, optional): PDF name (default: "page")
|
|
415
|
+
- Additional PDF options (format, margin, etc.)
|
|
416
|
+
|
|
417
|
+
**Returns:**
|
|
418
|
+
- `filePath` (string): Full path of the saved PDF file
|
|
419
|
+
|
|
420
|
+
### Interaction Tools
|
|
421
|
+
|
|
422
|
+
#### `interaction_click`
|
|
423
|
+
Clicks an element on the page.
|
|
424
|
+
|
|
425
|
+
**Parameters:**
|
|
426
|
+
- `selector` (string, required): CSS selector for the element to click
|
|
427
|
+
|
|
428
|
+
#### `interaction_fill`
|
|
429
|
+
Fills a form input field.
|
|
430
|
+
|
|
431
|
+
**Parameters:**
|
|
432
|
+
- `selector` (string, required): CSS selector for the input field
|
|
433
|
+
- `value` (string, required): Value to fill
|
|
434
|
+
|
|
435
|
+
#### `interaction_hover`
|
|
436
|
+
Hovers over an element.
|
|
437
|
+
|
|
438
|
+
**Parameters:**
|
|
439
|
+
- `selector` (string, required): CSS selector for the element to hover
|
|
440
|
+
|
|
441
|
+
#### `interaction_press-key`
|
|
442
|
+
Simulates keyboard input.
|
|
443
|
+
|
|
444
|
+
**Parameters:**
|
|
445
|
+
- `key` (string, required): Key to press (e.g., "Enter", "Escape", "Tab")
|
|
446
|
+
|
|
447
|
+
#### `interaction_select`
|
|
448
|
+
Selects an option from a dropdown.
|
|
449
|
+
|
|
450
|
+
**Parameters:**
|
|
451
|
+
- `selector` (string, required): CSS selector for the select element
|
|
452
|
+
- `value` (string, required): Value to select
|
|
453
|
+
|
|
454
|
+
#### `interaction_drag`
|
|
455
|
+
Performs drag and drop operation.
|
|
456
|
+
|
|
457
|
+
**Parameters:**
|
|
458
|
+
- `sourceSelector` (string, required): CSS selector for the source element
|
|
459
|
+
- `targetSelector` (string, required): CSS selector for the target element
|
|
460
|
+
|
|
461
|
+
#### `interaction_evaluate`
|
|
462
|
+
Executes JavaScript in the browser console.
|
|
463
|
+
|
|
464
|
+
**Parameters:**
|
|
465
|
+
- `script` (string, required): JavaScript code to execute
|
|
466
|
+
|
|
467
|
+
**Returns:**
|
|
468
|
+
- `result` (any): Result of the JavaScript evaluation
|
|
469
|
+
|
|
470
|
+
### Navigation Tools
|
|
471
|
+
|
|
472
|
+
#### `navigation_go-to`
|
|
473
|
+
Navigates to a URL.
|
|
474
|
+
|
|
475
|
+
**Parameters:**
|
|
476
|
+
- `url` (string, required): URL to navigate to (must include scheme)
|
|
477
|
+
- `timeout` (number, optional): Maximum operation time in milliseconds (default: 0 - no timeout)
|
|
478
|
+
- `waitUntil` (enum, optional): When to consider navigation succeeded - "load", "domcontentloaded", "networkidle", or "commit" (default: "load")
|
|
479
|
+
|
|
480
|
+
**Returns:**
|
|
481
|
+
- `url` (string): Final URL after navigation
|
|
482
|
+
- `status` (number): HTTP status code
|
|
483
|
+
- `statusText` (string): HTTP status text
|
|
484
|
+
- `ok` (boolean): Whether navigation was successful (2xx status)
|
|
485
|
+
|
|
486
|
+
#### `navigation_go-back`
|
|
487
|
+
Navigates backward in browser history.
|
|
488
|
+
|
|
489
|
+
#### `navigation_go-forward`
|
|
490
|
+
Navigates forward in browser history.
|
|
491
|
+
|
|
492
|
+
### Monitoring Tools
|
|
493
|
+
|
|
494
|
+
#### `monitoring_get-console-messages`
|
|
495
|
+
Retrieves console messages/logs from the browser with advanced filtering.
|
|
496
|
+
|
|
497
|
+
**Parameters:**
|
|
498
|
+
- `type` (enum, optional): Filter by message level - "ERROR", "WARNING", "INFO", "DEBUG"
|
|
499
|
+
- `search` (string, optional): Text to search for in messages
|
|
500
|
+
- `timestamp` (number, optional): Start time filter (Unix epoch milliseconds)
|
|
501
|
+
- `sequenceNumber` (number, optional): Only return messages after this sequence number
|
|
502
|
+
- `limit` (object, optional): Limit results
|
|
503
|
+
- `count` (number): Maximum number of messages
|
|
504
|
+
- `from` (enum): "start" or "end" (default: "end")
|
|
505
|
+
|
|
506
|
+
**Returns:**
|
|
507
|
+
- `messages` (array): Array of console messages with type, text, location, timestamp, and sequence number
|
|
508
|
+
|
|
509
|
+
#### `monitoring_get-http-requests`
|
|
510
|
+
Retrieves HTTP requests from the browser with detailed filtering.
|
|
511
|
+
|
|
512
|
+
**Parameters:**
|
|
513
|
+
- `resourceType` (enum, optional): Filter by resource type (e.g., "document", "script", "stylesheet")
|
|
514
|
+
- `status` (object, optional): Filter by status code range
|
|
515
|
+
- `min` (number): Minimum status code
|
|
516
|
+
- `max` (number): Maximum status code
|
|
517
|
+
- `ok` (boolean, optional): Filter by success/failure (2xx = success)
|
|
518
|
+
- `timestamp` (number, optional): Start time filter (Unix epoch milliseconds)
|
|
519
|
+
- `sequenceNumber` (number, optional): Only return requests after this sequence number
|
|
520
|
+
- `limit` (object, optional): Limit results
|
|
521
|
+
- `count` (number): Maximum number of requests
|
|
522
|
+
- `from` (enum): "start" or "end" (default: "end")
|
|
523
|
+
|
|
524
|
+
**Returns:**
|
|
525
|
+
- `requests` (array): Array of HTTP requests with URL, method, headers, body, response, timing, and metadata
|
|
526
|
+
|
|
527
|
+
## Architecture
|
|
528
|
+
|
|
529
|
+
### Session Management
|
|
530
|
+
|
|
531
|
+
The server uses session-based architecture where each MCP client connection gets its own browser context and page. Sessions are automatically cleaned up when:
|
|
532
|
+
|
|
533
|
+
- The client disconnects
|
|
534
|
+
- The session becomes idle (configurable timeout)
|
|
535
|
+
- The session is explicitly closed
|
|
536
|
+
|
|
537
|
+
### Browser Support
|
|
538
|
+
|
|
539
|
+
The server supports multiple browser engines:
|
|
540
|
+
- **Chromium** (default)
|
|
541
|
+
- **Firefox**
|
|
542
|
+
- **WebKit**
|
|
543
|
+
|
|
544
|
+
Browser instances are shared across sessions for efficiency, but each session has its own isolated browser context.
|
|
545
|
+
|
|
546
|
+
### Buffering & Filtering
|
|
547
|
+
|
|
548
|
+
Console messages and HTTP requests are buffered in memory with configurable buffer sizes. Both tools support advanced filtering:
|
|
549
|
+
|
|
550
|
+
- **Level-based filtering**: Filter by severity/type
|
|
551
|
+
- **Text search**: Search within message/request content
|
|
552
|
+
- **Time-based filtering**: Filter by timestamp
|
|
553
|
+
- **Incremental retrieval**: Use sequence numbers to fetch only new items
|
|
554
|
+
- **Pagination**: Limit results with start/end trimming
|
|
555
|
+
|
|
556
|
+
## Development
|
|
557
|
+
|
|
558
|
+
### Prerequisites
|
|
559
|
+
|
|
560
|
+
- Node.js 18+
|
|
561
|
+
- npm or yarn
|
|
562
|
+
|
|
563
|
+
### Setup
|
|
564
|
+
|
|
565
|
+
```bash
|
|
566
|
+
# Clone the repository
|
|
567
|
+
git clone https://github.com/serkan-ozal/browser-devtools-mcp.git
|
|
568
|
+
cd browser-devtools-mcp
|
|
569
|
+
|
|
570
|
+
# Install dependencies
|
|
571
|
+
npm install
|
|
572
|
+
|
|
573
|
+
# Build the project
|
|
574
|
+
npm run build
|
|
575
|
+
```
|
|
576
|
+
|
|
577
|
+
### Scripts
|
|
578
|
+
|
|
579
|
+
- `npm run build` - Build TypeScript to JavaScript
|
|
580
|
+
- `npm run start` - Start server with stdio transport
|
|
581
|
+
- `npm run start:http` - Start server with HTTP transport
|
|
582
|
+
- `npm run watch` - Watch mode for development
|
|
583
|
+
- `npm run inspector` - Run MCP Inspector (stdio)
|
|
584
|
+
- `npm run inspector:http` - Run MCP Inspector (HTTP)
|
|
585
|
+
- `npm run lint:check` - Check code formatting
|
|
586
|
+
- `npm run lint:format` - Format code
|
|
587
|
+
|
|
588
|
+
### Project Structure
|
|
589
|
+
|
|
590
|
+
```
|
|
591
|
+
src/
|
|
592
|
+
├── browser.ts # Browser instance management
|
|
593
|
+
├── config.ts # Configuration and environment variables
|
|
594
|
+
├── context.ts # MCP session context with monitoring
|
|
595
|
+
├── index.ts # Entry point (CLI)
|
|
596
|
+
├── logger.ts # Logging utilities
|
|
597
|
+
├── server.ts # MCP server creation and tool registration
|
|
598
|
+
├── server-info.ts # Server metadata and instructions
|
|
599
|
+
├── types.ts # TypeScript type definitions
|
|
600
|
+
├── utils.ts # Utility functions
|
|
601
|
+
└── tools/ # Tool implementations
|
|
602
|
+
├── content/ # Content extraction tools
|
|
603
|
+
├── interaction/ # User interaction tools
|
|
604
|
+
├── monitoring/ # Monitoring and debugging tools
|
|
605
|
+
├── navigation/ # Navigation tools
|
|
606
|
+
├── tool-executor.ts # Tool execution engine
|
|
607
|
+
└── types.ts # Tool type definitions
|
|
608
|
+
```
|
|
609
|
+
|
|
610
|
+
## Use Cases
|
|
611
|
+
|
|
612
|
+
### For AI Coding Assistants
|
|
613
|
+
|
|
614
|
+
This server enables AI assistants to:
|
|
615
|
+
|
|
616
|
+
1. **Debug Web Applications**: Capture screenshots, inspect DOM, check console errors
|
|
617
|
+
2. **Monitor Network Activity**: Track API calls, analyze request/response patterns
|
|
618
|
+
3. **Test User Flows**: Automate navigation and interactions
|
|
619
|
+
4. **Visual Verification**: Compare visual states, verify UI changes
|
|
620
|
+
5. **Accessibility Analysis**: Use ARIA snapshots to understand page structure
|
|
621
|
+
6. **Performance Analysis**: Monitor HTTP request timing and failures
|
|
622
|
+
|
|
623
|
+
### Example Workflow
|
|
624
|
+
|
|
625
|
+
1. Navigate to a web page using `navigation_go-to`
|
|
626
|
+
2. Take a screenshot with `content_take-screenshot` to see the current state
|
|
627
|
+
3. Check console messages with `monitoring_get-console-messages` for errors
|
|
628
|
+
4. Monitor HTTP requests with `monitoring_get-http-requests` to see API calls
|
|
629
|
+
5. Interact with elements using `interaction_click`, `interaction_fill`, etc.
|
|
630
|
+
6. Capture ARIA snapshot with `content_take-aria-snapshot` to understand structure
|
|
631
|
+
7. Extract content using `content_get-as-html` or `content_get-as-text`
|
|
632
|
+
|
|
633
|
+
## Contributing
|
|
634
|
+
|
|
635
|
+
Contributions are welcome! Please feel free to submit a Pull Request.
|
|
636
|
+
|
|
637
|
+
## License
|
|
638
|
+
|
|
639
|
+
MIT License - see [LICENSE](LICENSE) file for details.
|
|
640
|
+
|
|
641
|
+
## Author
|
|
642
|
+
|
|
643
|
+
**Serkan Ozal**
|
|
644
|
+
|
|
645
|
+
- Email: serkanozal86@gmail.com
|
|
646
|
+
- GitHub: [@serkan-ozal](https://github.com/serkan-ozal)
|
|
647
|
+
|
|
648
|
+
## Acknowledgments
|
|
649
|
+
|
|
650
|
+
- Built with [Playwright](https://playwright.dev) for browser automation
|
|
651
|
+
- Uses [Model Context Protocol SDK](https://github.com/modelcontextprotocol/sdk) for MCP implementation
|
|
652
|
+
- HTTP transport powered by [Hono](https://hono.dev)
|