browser-devtools-mcp 0.0.1 → 0.0.3
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/README.md +177 -50
- package/dist/browser.js +162 -22
- package/dist/browser.js.map +1 -1
- package/dist/config.js +46 -1
- package/dist/config.js.map +1 -1
- package/dist/context.js +72 -12
- package/dist/context.js.map +1 -1
- package/dist/index.js +77 -42
- package/dist/index.js.map +1 -1
- package/dist/otel/otel-controller.js +319 -0
- package/dist/otel/otel-controller.js.map +1 -0
- package/dist/otel/otel-initializer.bundle.js +2 -0
- package/dist/otel/otel-initializer.bundle.js.map +7 -0
- package/dist/otel/otel-proxy.js +407 -0
- package/dist/otel/otel-proxy.js.map +1 -0
- package/dist/server-info.js +48 -10
- package/dist/server-info.js.map +1 -1
- package/dist/server.js +47 -32
- package/dist/server.js.map +1 -1
- package/dist/tools/a11y/index.js +7 -0
- package/dist/tools/a11y/index.js.map +1 -0
- package/dist/tools/{content → a11y}/take-aria-snapshot.js +6 -1
- package/dist/tools/a11y/take-aria-snapshot.js.map +1 -0
- package/dist/tools/a11y/take-ax-tree-snapshot.js +850 -0
- package/dist/tools/a11y/take-ax-tree-snapshot.js.map +1 -0
- package/dist/tools/content/index.js +0 -2
- package/dist/tools/content/index.js.map +1 -1
- package/dist/tools/content/save-as-pdf.js +9 -36
- package/dist/tools/content/save-as-pdf.js.map +1 -1
- package/dist/tools/content/take-screenshot.js +14 -37
- package/dist/tools/content/take-screenshot.js.map +1 -1
- package/dist/tools/index.js +2 -0
- package/dist/tools/index.js.map +1 -1
- package/dist/tools/monitoring/get-trace-id.js +30 -0
- package/dist/tools/monitoring/get-trace-id.js.map +1 -0
- package/dist/tools/monitoring/index.js +10 -1
- package/dist/tools/monitoring/index.js.map +1 -1
- package/dist/tools/monitoring/new-trace-id.js +32 -0
- package/dist/tools/monitoring/new-trace-id.js.map +1 -0
- package/dist/tools/monitoring/set-trace-id.js +28 -0
- package/dist/tools/monitoring/set-trace-id.js.map +1 -0
- package/dist/tools/tool-executor.js +26 -4
- package/dist/tools/tool-executor.js.map +1 -1
- package/dist/utils.js +38 -0
- package/dist/utils.js.map +1 -1
- package/package.json +7 -2
- package/dist/tools/content/take-aria-snapshot.js.map +0 -1
package/README.md
CHANGED
|
@@ -16,6 +16,7 @@ Browser DevTools MCP exposes a Playwright-powered browser runtime to AI agents,
|
|
|
16
16
|
- **DOM & Code-Level Debugging**: Element inspection, computed styles, accessibility data
|
|
17
17
|
- **Browser Automation**: Navigation, input, clicking, scrolling, viewport control
|
|
18
18
|
- **Execution Monitoring**: Console message capture, HTTP request/response tracking
|
|
19
|
+
- **OpenTelemetry Integration**: Automatic trace injection into web pages, UI trace collection, and backend trace correlation via trace context propagation
|
|
19
20
|
- **JavaScript Evaluation**: Execute code in page context
|
|
20
21
|
- **Session Management**: Long-lived, session-based debugging with automatic cleanup
|
|
21
22
|
- **Multiple Transport Modes**: Supports both stdio and HTTP transports
|
|
@@ -23,10 +24,9 @@ Browser DevTools MCP exposes a Playwright-powered browser runtime to AI agents,
|
|
|
23
24
|
## Features
|
|
24
25
|
|
|
25
26
|
### Content Tools
|
|
26
|
-
- **Screenshots**: Capture full page or specific elements (PNG/JPEG)
|
|
27
|
-
- **
|
|
28
|
-
- **
|
|
29
|
-
- **PDF Export**: Save pages as PDF documents
|
|
27
|
+
- **Screenshots**: Capture full page or specific elements (PNG/JPEG) with image data
|
|
28
|
+
- **HTML/Text Extraction**: Get page content with filtering, cleaning, and minification options
|
|
29
|
+
- **PDF Export**: Save pages as PDF documents with customizable format and margins
|
|
30
30
|
|
|
31
31
|
### Interaction Tools
|
|
32
32
|
- **Click**: Click elements by CSS selector
|
|
@@ -45,6 +45,12 @@ Browser DevTools MCP exposes a Playwright-powered browser runtime to AI agents,
|
|
|
45
45
|
### Monitoring Tools
|
|
46
46
|
- **Console Messages**: Capture and filter browser console logs with advanced filtering (level, search, timestamp, sequence number)
|
|
47
47
|
- **HTTP Requests**: Monitor network traffic with detailed request/response data, filtering by resource type, status code, and more
|
|
48
|
+
- **OpenTelemetry Tracing**: Automatic trace injection into web pages, UI trace collection (document load, fetch, XMLHttpRequest, user interactions), and trace context propagation for backend correlation
|
|
49
|
+
- **Trace ID Management**: Get, set, and generate OpenTelemetry compatible trace IDs for distributed tracing across API calls
|
|
50
|
+
|
|
51
|
+
### Accessibility (A11Y) Tools
|
|
52
|
+
- **ARIA Snapshots**: Capture semantic structure and accessibility roles in YAML format
|
|
53
|
+
- **AX Tree Snapshots**: Combine Chromium's Accessibility tree with runtime visual diagnostics (bounding boxes, visibility, occlusion detection, computed styles)
|
|
48
54
|
|
|
49
55
|
## Prerequisites
|
|
50
56
|
|
|
@@ -360,7 +366,19 @@ The server can be configured using environment variables:
|
|
|
360
366
|
| `SESSION_CLOSE_ON_SOCKET_CLOSE` | Close session when socket closes | `false` |
|
|
361
367
|
| `CONSOLE_MESSAGES_BUFFER_SIZE` | Maximum console messages to buffer | `1000` |
|
|
362
368
|
| `HTTP_REQUESTS_BUFFER_SIZE` | Maximum HTTP requests to buffer | `1000` |
|
|
369
|
+
| `BROWSER_HEADLESS_ENABLE` | Run browser in headless mode | `true` |
|
|
370
|
+
| `BROWSER_PERSISTENT_ENABLE` | Use persistent browser context (preserves cookies, localStorage, etc.) | `false` |
|
|
371
|
+
| `BROWSER_PERSISTENT_USER_DATA_DIR` | Directory for persistent browser context user data | `./browser-devtools-mcp` |
|
|
372
|
+
| `BROWSER_USE_INSTALLED_ON_SYSTEM` | Use system-installed Chrome browser instead of Playwright's bundled browser | `false` |
|
|
363
373
|
| `BROWSER_EXECUTABLE_PATH` | Custom browser executable path | (uses Playwright default) |
|
|
374
|
+
| `OTEL_ENABLE` | Enable OpenTelemetry integration | `false` |
|
|
375
|
+
| `OTEL_SERVICE_NAME` | OpenTelemetry service name | `frontend` |
|
|
376
|
+
| `OTEL_SERVICE_VERSION` | OpenTelemetry service version | (none) |
|
|
377
|
+
| `OTEL_ASSETS_DIR` | Directory containing OpenTelemetry bundle files | (uses default) |
|
|
378
|
+
| `OTEL_EXPORTER_TYPE` | OpenTelemetry exporter type: "otlp/http", "console", or "none" | `none` |
|
|
379
|
+
| `OTEL_EXPORTER_HTTP_URL` | OpenTelemetry collector base URL (e.g., "http://localhost:4318") | (none) |
|
|
380
|
+
| `OTEL_EXPORTER_HTTP_HEADERS` | OpenTelemetry exporter HTTP headers (comma-separated key=value pairs) | (none) |
|
|
381
|
+
| `OTEL_INSTRUMENTATION_USER_INTERACTION_EVENTS` | User interaction events to instrument (comma-separated, e.g., "click,submit") | `click` |
|
|
364
382
|
|
|
365
383
|
## Available Tools
|
|
366
384
|
|
|
@@ -370,7 +388,7 @@ The server can be configured using environment variables:
|
|
|
370
388
|
Takes a screenshot of the current page or a specific element.
|
|
371
389
|
|
|
372
390
|
**Parameters:**
|
|
373
|
-
- `outputPath` (string,
|
|
391
|
+
- `outputPath` (string, optional): Directory path where screenshot will be saved (default: OS temp directory)
|
|
374
392
|
- `name` (string, optional): Screenshot name (default: "screenshot")
|
|
375
393
|
- `selector` (string, optional): CSS selector for element to capture
|
|
376
394
|
- `fullPage` (boolean, optional): Capture full scrollable page (default: false)
|
|
@@ -378,41 +396,43 @@ Takes a screenshot of the current page or a specific element.
|
|
|
378
396
|
|
|
379
397
|
**Returns:**
|
|
380
398
|
- `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
|
|
399
|
+
- `image` (object): Screenshot image data with mimeType
|
|
390
400
|
|
|
391
401
|
#### `content_get-as-html`
|
|
392
402
|
Retrieves the HTML content of the current page or a specific element.
|
|
393
403
|
|
|
394
404
|
**Parameters:**
|
|
395
|
-
- `selector` (string, optional): CSS selector
|
|
405
|
+
- `selector` (string, optional): CSS selector to limit the HTML content to a specific container
|
|
406
|
+
- `removeScripts` (boolean, optional): Remove all script tags from the HTML (default: true)
|
|
407
|
+
- `removeComments` (boolean, optional): Remove all HTML comments (default: false)
|
|
408
|
+
- `removeStyles` (boolean, optional): Remove all style tags from the HTML (default: false)
|
|
409
|
+
- `removeMeta` (boolean, optional): Remove all meta tags from the HTML (default: false)
|
|
410
|
+
- `cleanHtml` (boolean, optional): Perform comprehensive HTML cleaning (default: false)
|
|
411
|
+
- `minify` (boolean, optional): Minify the HTML output (default: false)
|
|
412
|
+
- `maxLength` (number, optional): Maximum number of characters to return (default: 50000)
|
|
396
413
|
|
|
397
414
|
**Returns:**
|
|
398
|
-
- `
|
|
415
|
+
- `output` (string): The requested HTML content of the page
|
|
399
416
|
|
|
400
417
|
#### `content_get-as-text`
|
|
401
|
-
Retrieves the text content of the current page or a specific element.
|
|
418
|
+
Retrieves the visible text content of the current page or a specific element.
|
|
402
419
|
|
|
403
420
|
**Parameters:**
|
|
404
|
-
- `selector` (string, optional): CSS selector
|
|
421
|
+
- `selector` (string, optional): CSS selector to limit the text content to a specific container
|
|
422
|
+
- `maxLength` (number, optional): Maximum number of characters to return (default: 50000)
|
|
405
423
|
|
|
406
424
|
**Returns:**
|
|
407
|
-
- `
|
|
425
|
+
- `output` (string): The requested text content of the page
|
|
408
426
|
|
|
409
427
|
#### `content_save-as-pdf`
|
|
410
428
|
Saves the current page as a PDF document.
|
|
411
429
|
|
|
412
430
|
**Parameters:**
|
|
413
|
-
- `outputPath` (string,
|
|
431
|
+
- `outputPath` (string, optional): Directory path where PDF will be saved (default: OS temp directory)
|
|
414
432
|
- `name` (string, optional): PDF name (default: "page")
|
|
415
|
-
-
|
|
433
|
+
- `format` (enum, optional): Page format - "Letter", "Legal", "Tabloid", "Ledger", "A0" through "A6" (default: "A4")
|
|
434
|
+
- `printBackground` (boolean, optional): Whether to print background graphics (default: false)
|
|
435
|
+
- `margin` (object, optional): Page margins with top, right, bottom, left (default: "1cm" for each)
|
|
416
436
|
|
|
417
437
|
**Returns:**
|
|
418
438
|
- `filePath` (string): Full path of the saved PDF file
|
|
@@ -524,6 +544,90 @@ Retrieves HTTP requests from the browser with detailed filtering.
|
|
|
524
544
|
**Returns:**
|
|
525
545
|
- `requests` (array): Array of HTTP requests with URL, method, headers, body, response, timing, and metadata
|
|
526
546
|
|
|
547
|
+
#### `monitoring_get-trace-id`
|
|
548
|
+
Gets the OpenTelemetry compatible trace id of the current session.
|
|
549
|
+
|
|
550
|
+
**Parameters:**
|
|
551
|
+
- No input parameters
|
|
552
|
+
|
|
553
|
+
**Returns:**
|
|
554
|
+
- `traceId` (string, optional): The OpenTelemetry compatible trace id of the current session if available
|
|
555
|
+
|
|
556
|
+
**Note:** Requires OpenTelemetry to be enabled (`OTEL_ENABLE=true`).
|
|
557
|
+
|
|
558
|
+
#### `monitoring_new-trace-id`
|
|
559
|
+
Generates a new OpenTelemetry compatible trace id and sets it to the current session.
|
|
560
|
+
|
|
561
|
+
**Parameters:**
|
|
562
|
+
- No input parameters
|
|
563
|
+
|
|
564
|
+
**Returns:**
|
|
565
|
+
- `traceId` (string): The generated new OpenTelemetry compatible trace id
|
|
566
|
+
|
|
567
|
+
**Note:** Requires OpenTelemetry to be enabled (`OTEL_ENABLE=true`). The new trace ID is automatically set and will be used for all subsequent traces in the session.
|
|
568
|
+
|
|
569
|
+
#### `monitoring_set-trace-id`
|
|
570
|
+
Sets the OpenTelemetry compatible trace id of the current session.
|
|
571
|
+
|
|
572
|
+
**Parameters:**
|
|
573
|
+
- `traceId` (string, optional): The OpenTelemetry compatible trace id to be set. Leave it empty to clear the session trace id, so no OpenTelemetry trace header will be propagated from browser throughout the API calls
|
|
574
|
+
|
|
575
|
+
**Returns:**
|
|
576
|
+
- No return value
|
|
577
|
+
|
|
578
|
+
**Note:** Requires OpenTelemetry to be enabled (`OTEL_ENABLE=true`). When a trace ID is set, it will be propagated in HTTP headers (traceparent) for all API calls, enabling correlation with backend traces.
|
|
579
|
+
|
|
580
|
+
### Accessibility (A11Y) Tools
|
|
581
|
+
|
|
582
|
+
#### `a11y_take-aria-snapshot`
|
|
583
|
+
Captures an ARIA (accessibility) snapshot of the current page or a specific element.
|
|
584
|
+
|
|
585
|
+
**Parameters:**
|
|
586
|
+
- `selector` (string, optional): CSS selector for element to snapshot
|
|
587
|
+
|
|
588
|
+
**Returns:**
|
|
589
|
+
- `output` (string): Includes the page URL, title, and a YAML-formatted accessibility tree
|
|
590
|
+
|
|
591
|
+
**Usage:**
|
|
592
|
+
- Use in combination with `accessibility_take-ax-tree-snapshot` for comprehensive UI analysis
|
|
593
|
+
- Provides semantic structure and accessibility roles
|
|
594
|
+
- Helps identify accessibility issues and page hierarchy problems
|
|
595
|
+
|
|
596
|
+
#### `accessibility_take-ax-tree-snapshot`
|
|
597
|
+
Captures a UI-focused snapshot by combining Chromium's Accessibility (AX) tree with runtime visual diagnostics.
|
|
598
|
+
|
|
599
|
+
**Parameters:**
|
|
600
|
+
- `roles` (array, optional): Optional role allowlist (button, link, textbox, checkbox, radio, combobox, switch, tab, menuitem, dialog, heading, listbox, listitem, option). If omitted, a built-in set of interactive roles is used
|
|
601
|
+
- `includeStyles` (boolean, optional): Whether to include computed CSS styles for each node (default: true)
|
|
602
|
+
- `includeRuntimeVisual` (boolean, optional): Whether to compute runtime visual information (bounding box, visibility, viewport) (default: true)
|
|
603
|
+
- `checkOcclusion` (boolean, optional): If true, checks whether each element is visually occluded by another element using elementFromPoint() sampled at multiple points (default: false)
|
|
604
|
+
- `onlyVisible` (boolean, optional): If true, only visually visible nodes are returned (default: false)
|
|
605
|
+
- `onlyInViewport` (boolean, optional): If true, only nodes intersecting the viewport are returned (default: false)
|
|
606
|
+
- `textPreviewMaxLength` (number, optional): Maximum length of the text preview extracted from each element (default: 80)
|
|
607
|
+
- `styleProperties` (array, optional): List of CSS computed style properties to extract (default: includes display, visibility, opacity, position, z-index, colors, fonts, etc.)
|
|
608
|
+
|
|
609
|
+
**Returns:**
|
|
610
|
+
- `url` (string): The current page URL at the time the AX snapshot was captured
|
|
611
|
+
- `title` (string): The document title of the page at the time of the snapshot
|
|
612
|
+
- `axNodeCount` (number): Total number of nodes returned by Chromium Accessibility.getFullAXTree before filtering
|
|
613
|
+
- `candidateCount` (number): Number of DOM-backed AX nodes that passed role filtering before enrichment
|
|
614
|
+
- `enrichedCount` (number): Number of nodes included in the final enriched snapshot output
|
|
615
|
+
- `truncatedBySafetyCap` (boolean): Indicates whether the result set was truncated by an internal safety cap
|
|
616
|
+
- `nodes` (array): List of enriched DOM-backed AX nodes combining accessibility metadata with visual diagnostics, including:
|
|
617
|
+
- `axNodeId`, `parentAxNodeId`, `childAxNodeIds`: Tree structure
|
|
618
|
+
- `role`, `name`, `ignored`: Accessibility properties
|
|
619
|
+
- `backendDOMNodeId`, `domNodeId`, `frameId`: DOM references
|
|
620
|
+
- `localName`, `id`, `className`, `selectorHint`: Element identification
|
|
621
|
+
- `textPreview`: Short preview of rendered text content
|
|
622
|
+
- `styles`: Computed CSS styles (if includeStyles is true)
|
|
623
|
+
- `runtime`: Visual diagnostics including boundingBox, isVisible, isInViewport, and optional occlusion data
|
|
624
|
+
|
|
625
|
+
**Usage:**
|
|
626
|
+
- Use to detect UI issues like elements that exist semantically but are visually hidden or off-screen
|
|
627
|
+
- Identify wrong layout/geometry, styling issues, and overlap/stacking/occlusion problems
|
|
628
|
+
- ALWAYS use `checkOcclusion: true` when investigating UI/layout problems
|
|
629
|
+
- Use alongside `a11y_take-aria-snapshot` tool for complete UI analysis
|
|
630
|
+
|
|
527
631
|
## Architecture
|
|
528
632
|
|
|
529
633
|
### Session Management
|
|
@@ -541,7 +645,24 @@ The server supports multiple browser engines:
|
|
|
541
645
|
- **Firefox**
|
|
542
646
|
- **WebKit**
|
|
543
647
|
|
|
544
|
-
Browser
|
|
648
|
+
**Browser Configuration:**
|
|
649
|
+
- **Headless Mode**: By default, browsers run in headless mode (`BROWSER_HEADLESS_ENABLE=true`). Set to `false` to see the browser window.
|
|
650
|
+
- **Persistent Context**: When enabled (`BROWSER_PERSISTENT_ENABLE=true`), browser contexts persist across sessions, preserving:
|
|
651
|
+
- Cookies and session data
|
|
652
|
+
- LocalStorage and IndexedDB
|
|
653
|
+
- Browser extensions and settings
|
|
654
|
+
- User preferences
|
|
655
|
+
|
|
656
|
+
Persistent contexts are shared across sessions and are not automatically closed when sessions end.
|
|
657
|
+
|
|
658
|
+
- **System Browser**: When enabled (`BROWSER_USE_INSTALLED_ON_SYSTEM=true`), the server uses the system-installed Chrome browser instead of Playwright's bundled browser. This is useful for:
|
|
659
|
+
- Testing with the exact browser version users have
|
|
660
|
+
- Using browser extensions installed on the system
|
|
661
|
+
- Better compatibility with certain web applications
|
|
662
|
+
|
|
663
|
+
**Note:** System browser support is currently only available for Chromium/Chrome.
|
|
664
|
+
|
|
665
|
+
Browser instances are shared across sessions for efficiency. Each session gets its own isolated browser context, unless persistent context is enabled (in which case contexts are shared).
|
|
545
666
|
|
|
546
667
|
### Buffering & Filtering
|
|
547
668
|
|
|
@@ -553,6 +674,31 @@ Console messages and HTTP requests are buffered in memory with configurable buff
|
|
|
553
674
|
- **Incremental retrieval**: Use sequence numbers to fetch only new items
|
|
554
675
|
- **Pagination**: Limit results with start/end trimming
|
|
555
676
|
|
|
677
|
+
### OpenTelemetry Integration
|
|
678
|
+
|
|
679
|
+
When enabled (`OTEL_ENABLE=true`), the server automatically injects OpenTelemetry instrumentation into all web pages navigated by the browser. This enables:
|
|
680
|
+
|
|
681
|
+
- **Automatic Trace Collection**: UI traces are automatically collected for:
|
|
682
|
+
- Document load events
|
|
683
|
+
- Fetch/XHR requests
|
|
684
|
+
- User interactions (clicks, form submissions, etc.)
|
|
685
|
+
|
|
686
|
+
- **Trace Context Propagation**: Trace IDs are automatically propagated in HTTP headers (traceparent) for all API calls, enabling:
|
|
687
|
+
- Correlation between frontend and backend traces
|
|
688
|
+
- End-to-end distributed tracing across the entire application stack
|
|
689
|
+
|
|
690
|
+
- **Trace ID Management**: Tools allow you to:
|
|
691
|
+
- Get the current session's trace ID
|
|
692
|
+
- Generate new trace IDs
|
|
693
|
+
- Set custom trace IDs (e.g., from backend trace context)
|
|
694
|
+
|
|
695
|
+
- **Exporter Configuration**: Traces can be exported to:
|
|
696
|
+
- **OTLP/HTTP**: Send to OpenTelemetry collector (configure via `OTEL_EXPORTER_HTTP_URL`)
|
|
697
|
+
- **Console**: Log traces to browser console (for debugging)
|
|
698
|
+
- **None**: Collect traces but don't export (for testing)
|
|
699
|
+
|
|
700
|
+
The OpenTelemetry integration uses a proxy mechanism (`/__mcp_otel/`) to forward traces from the browser to the configured collector, ensuring proper CORS handling and trace context propagation.
|
|
701
|
+
|
|
556
702
|
## Development
|
|
557
703
|
|
|
558
704
|
### Prerequisites
|
|
@@ -585,28 +731,6 @@ npm run build
|
|
|
585
731
|
- `npm run lint:check` - Check code formatting
|
|
586
732
|
- `npm run lint:format` - Format code
|
|
587
733
|
|
|
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
734
|
## Use Cases
|
|
611
735
|
|
|
612
736
|
### For AI Coding Assistants
|
|
@@ -615,10 +739,12 @@ This server enables AI assistants to:
|
|
|
615
739
|
|
|
616
740
|
1. **Debug Web Applications**: Capture screenshots, inspect DOM, check console errors
|
|
617
741
|
2. **Monitor Network Activity**: Track API calls, analyze request/response patterns
|
|
618
|
-
3. **
|
|
619
|
-
4. **
|
|
620
|
-
5. **
|
|
621
|
-
6. **
|
|
742
|
+
3. **Distributed Tracing**: Enable OpenTelemetry to correlate frontend and backend traces for end-to-end debugging
|
|
743
|
+
4. **Test User Flows**: Automate navigation and interactions
|
|
744
|
+
5. **Visual Verification**: Compare visual states, verify UI changes
|
|
745
|
+
6. **Content Extraction**: Get HTML/text content with filtering and cleaning options
|
|
746
|
+
7. **Accessibility Analysis**: Use ARIA and AX tree snapshots to understand page structure and detect UI issues
|
|
747
|
+
8. **Performance Analysis**: Monitor HTTP request timing and failures
|
|
622
748
|
|
|
623
749
|
### Example Workflow
|
|
624
750
|
|
|
@@ -626,9 +752,10 @@ This server enables AI assistants to:
|
|
|
626
752
|
2. Take a screenshot with `content_take-screenshot` to see the current state
|
|
627
753
|
3. Check console messages with `monitoring_get-console-messages` for errors
|
|
628
754
|
4. Monitor HTTP requests with `monitoring_get-http-requests` to see API calls
|
|
629
|
-
5.
|
|
630
|
-
6.
|
|
755
|
+
5. Capture accessibility snapshots with `a11y_take-aria-snapshot` and `accessibility_take-ax-tree-snapshot` to understand page structure
|
|
756
|
+
6. Interact with elements using `interaction_click`, `interaction_fill`, etc.
|
|
631
757
|
7. Extract content using `content_get-as-html` or `content_get-as-text`
|
|
758
|
+
8. Save the page as PDF using `content_save-as-pdf` for documentation
|
|
632
759
|
|
|
633
760
|
## Contributing
|
|
634
761
|
|
package/dist/browser.js
CHANGED
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.BrowserType = void 0;
|
|
4
|
-
exports.getBrowser = getBrowser;
|
|
6
|
+
exports.DEFAULT_BROWSER_TYPE = exports.BrowserType = void 0;
|
|
5
7
|
exports.newBrowserContext = newBrowserContext;
|
|
6
8
|
exports.newPage = newPage;
|
|
9
|
+
exports.closeBrowserContext = closeBrowserContext;
|
|
7
10
|
const config_1 = require("./config");
|
|
11
|
+
const fs_1 = __importDefault(require("fs"));
|
|
8
12
|
const playwright_1 = require("playwright");
|
|
9
13
|
var BrowserType;
|
|
10
14
|
(function (BrowserType) {
|
|
@@ -12,14 +16,35 @@ var BrowserType;
|
|
|
12
16
|
BrowserType["FIREFOX"] = "firefox";
|
|
13
17
|
BrowserType["WEBKIT"] = "webkit";
|
|
14
18
|
})(BrowserType || (exports.BrowserType = BrowserType = {}));
|
|
19
|
+
exports.DEFAULT_BROWSER_TYPE = BrowserType.CHROMIUM;
|
|
15
20
|
const browsers = new Map();
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
21
|
+
const persistenceBrowserContexts = new Map();
|
|
22
|
+
////////////////////////////////////////////////////////////////////////////////
|
|
23
|
+
function _browserKey(browserOptions) {
|
|
24
|
+
return JSON.stringify(browserOptions);
|
|
25
|
+
}
|
|
26
|
+
function _browserLaunchOptions(browserOptions) {
|
|
27
|
+
const launchOptions = {
|
|
28
|
+
headless: browserOptions.headless,
|
|
29
|
+
executablePath: browserOptions.executablePath,
|
|
30
|
+
handleSIGINT: false,
|
|
31
|
+
handleSIGTERM: false,
|
|
20
32
|
};
|
|
33
|
+
if (browserOptions.useInstalledOnSystem) {
|
|
34
|
+
switch (browserOptions.browserType) {
|
|
35
|
+
case BrowserType.CHROMIUM:
|
|
36
|
+
launchOptions.channel = 'chrome';
|
|
37
|
+
launchOptions.args = [
|
|
38
|
+
'--disable-blink-features=AutomationControlled',
|
|
39
|
+
];
|
|
40
|
+
break;
|
|
41
|
+
default:
|
|
42
|
+
throw new Error(`Browser type ${browserOptions.browserType} is not supported to be used from the one installed on the system`);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
return launchOptions;
|
|
21
46
|
}
|
|
22
|
-
async function _createBrowser(browserOptions
|
|
47
|
+
async function _createBrowser(browserOptions) {
|
|
23
48
|
// Use the appropriate browser engine
|
|
24
49
|
let browserInstance;
|
|
25
50
|
switch (browserOptions.browserType) {
|
|
@@ -34,34 +59,149 @@ async function _createBrowser(browserOptions = {}) {
|
|
|
34
59
|
browserInstance = playwright_1.chromium;
|
|
35
60
|
break;
|
|
36
61
|
}
|
|
37
|
-
return browserInstance.launch(
|
|
38
|
-
executablePath: browserOptions.executablePath,
|
|
39
|
-
handleSIGINT: false,
|
|
40
|
-
handleSIGTERM: false,
|
|
41
|
-
});
|
|
62
|
+
return browserInstance.launch(_browserLaunchOptions(browserOptions));
|
|
42
63
|
}
|
|
43
|
-
async function
|
|
44
|
-
|
|
64
|
+
async function _getBrowser(browserOptions) {
|
|
65
|
+
const browserKey = _browserKey(browserOptions);
|
|
66
|
+
let browserInstance = browsers.get(browserKey);
|
|
45
67
|
if (browserInstance && !browserInstance.isConnected()) {
|
|
46
68
|
try {
|
|
47
69
|
await browserInstance.close().catch(() => { });
|
|
48
70
|
}
|
|
49
|
-
catch
|
|
50
|
-
// Ignore errors when closing disconnected browser
|
|
51
|
-
}
|
|
52
|
-
// Reset browser and page references
|
|
71
|
+
catch { }
|
|
53
72
|
browserInstance = undefined;
|
|
54
73
|
}
|
|
55
74
|
if (!browserInstance) {
|
|
56
|
-
browserInstance = await _createBrowser(
|
|
57
|
-
browsers.set(
|
|
75
|
+
browserInstance = await _createBrowser(browserOptions);
|
|
76
|
+
browsers.set(browserKey, browserInstance);
|
|
58
77
|
}
|
|
59
78
|
return browserInstance;
|
|
60
79
|
}
|
|
61
|
-
|
|
62
|
-
|
|
80
|
+
////////////////////////////////////////////////////////////////////////////////
|
|
81
|
+
function _persistentBrowserContextKey(browserContextOptions) {
|
|
82
|
+
// There can be one active persistent browser context in a user data directory
|
|
83
|
+
return browserContextOptions.persistent.userDataDir;
|
|
84
|
+
}
|
|
85
|
+
function _persistentBrowserContextLaunchOptions(browserContextOptions) {
|
|
86
|
+
const browserOptions = browserContextOptions.browserOptions;
|
|
87
|
+
const launchOptions = {
|
|
88
|
+
headless: browserOptions.headless,
|
|
89
|
+
executablePath: browserOptions.executablePath,
|
|
90
|
+
bypassCSP: true,
|
|
91
|
+
};
|
|
92
|
+
if (browserOptions.useInstalledOnSystem) {
|
|
93
|
+
switch (browserOptions.browserType) {
|
|
94
|
+
case BrowserType.CHROMIUM:
|
|
95
|
+
launchOptions.channel = 'chrome';
|
|
96
|
+
launchOptions.args = [
|
|
97
|
+
'--disable-blink-features=AutomationControlled',
|
|
98
|
+
];
|
|
99
|
+
break;
|
|
100
|
+
default:
|
|
101
|
+
throw new Error(`Browser type ${browserOptions.browserType} is not supported to be used from the one installed on the system`);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
return launchOptions;
|
|
105
|
+
}
|
|
106
|
+
async function _createPersistentBrowserContext(browserContextOptions) {
|
|
107
|
+
// Use the appropriate browser engine
|
|
108
|
+
let browserInstance;
|
|
109
|
+
switch (browserContextOptions.browserOptions.browserType) {
|
|
110
|
+
case BrowserType.FIREFOX:
|
|
111
|
+
browserInstance = playwright_1.firefox;
|
|
112
|
+
break;
|
|
113
|
+
case BrowserType.WEBKIT:
|
|
114
|
+
browserInstance = playwright_1.webkit;
|
|
115
|
+
break;
|
|
116
|
+
case BrowserType.CHROMIUM:
|
|
117
|
+
default:
|
|
118
|
+
browserInstance = playwright_1.chromium;
|
|
119
|
+
break;
|
|
120
|
+
}
|
|
121
|
+
const userDataDir = browserContextOptions.persistent.userDataDir;
|
|
122
|
+
// Be sure that user data dir is available
|
|
123
|
+
fs_1.default.mkdirSync(userDataDir, { recursive: true });
|
|
124
|
+
const browserContext = await browserInstance.launchPersistentContext(userDataDir, _persistentBrowserContextLaunchOptions(browserContextOptions));
|
|
125
|
+
// Be sure that any restored pages are closed if there is any
|
|
126
|
+
for (const p of browserContext.pages()) {
|
|
127
|
+
try {
|
|
128
|
+
await p.close();
|
|
129
|
+
}
|
|
130
|
+
catch { }
|
|
131
|
+
}
|
|
132
|
+
return browserContext;
|
|
133
|
+
}
|
|
134
|
+
async function _getPersistentBrowserContext(browserContextOptions) {
|
|
135
|
+
const persistentBrowserContextKey = _persistentBrowserContextKey(browserContextOptions);
|
|
136
|
+
let browserContext = persistenceBrowserContexts.get(persistentBrowserContextKey);
|
|
137
|
+
if (browserContext && !browserContext.browser()?.isConnected()) {
|
|
138
|
+
try {
|
|
139
|
+
await browserContext.close().catch(() => { });
|
|
140
|
+
}
|
|
141
|
+
catch { }
|
|
142
|
+
browserContext = undefined;
|
|
143
|
+
}
|
|
144
|
+
if (!browserContext) {
|
|
145
|
+
browserContext = await _createPersistentBrowserContext(browserContextOptions);
|
|
146
|
+
persistenceBrowserContexts.set(persistentBrowserContextKey, browserContext);
|
|
147
|
+
}
|
|
148
|
+
else {
|
|
149
|
+
// There can be one active persistent browser context in a user data directory
|
|
150
|
+
throw new Error(`There is already active persistent browser context in the user data directory: ${browserContextOptions.persistent?.userDataDir}`);
|
|
151
|
+
}
|
|
152
|
+
return browserContext;
|
|
153
|
+
}
|
|
154
|
+
////////////////////////////////////////////////////////////////////////////////
|
|
155
|
+
async function newBrowserContext(browserContextOptions = {
|
|
156
|
+
browserOptions: {
|
|
157
|
+
browserType: exports.DEFAULT_BROWSER_TYPE,
|
|
158
|
+
headless: config_1.BROWSER_HEADLESS_ENABLE,
|
|
159
|
+
executablePath: config_1.BROWSER_EXECUTABLE_PATH,
|
|
160
|
+
useInstalledOnSystem: config_1.BROWSER_USE_INSTALLED_ON_SYSTEM,
|
|
161
|
+
},
|
|
162
|
+
persistent: config_1.BROWSER_PERSISTENT_ENABLE
|
|
163
|
+
? {
|
|
164
|
+
userDataDir: config_1.BROWSER_PERSISTENT_USER_DATA_DIR,
|
|
165
|
+
}
|
|
166
|
+
: undefined,
|
|
167
|
+
}) {
|
|
168
|
+
if (browserContextOptions.persistent) {
|
|
169
|
+
const browserContext = await _getPersistentBrowserContext(browserContextOptions);
|
|
170
|
+
return {
|
|
171
|
+
browserContext,
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
else {
|
|
175
|
+
const browser = await _getBrowser(browserContextOptions.browserOptions);
|
|
176
|
+
const browserContext = await browser.newContext({
|
|
177
|
+
bypassCSP: true,
|
|
178
|
+
});
|
|
179
|
+
return {
|
|
180
|
+
browserContext,
|
|
181
|
+
};
|
|
182
|
+
}
|
|
63
183
|
}
|
|
64
184
|
async function newPage(browserContext, pageOptions = {}) {
|
|
185
|
+
// TODO Design page options and take care of it here for the newly created page
|
|
65
186
|
return await browserContext.newPage();
|
|
66
187
|
}
|
|
188
|
+
async function closeBrowserContext(browserContext) {
|
|
189
|
+
await browserContext.close();
|
|
190
|
+
let deleted = false;
|
|
191
|
+
for (const [key, val] of persistenceBrowserContexts.entries()) {
|
|
192
|
+
if (browserContext === val) {
|
|
193
|
+
persistenceBrowserContexts.delete(key);
|
|
194
|
+
deleted = true;
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
return deleted;
|
|
198
|
+
}
|
|
199
|
+
////////////////////////////////////////////////////////////////////////////////
|
|
200
|
+
async function getElementFailFast(page, selector) {
|
|
201
|
+
const element = page.locator(selector);
|
|
202
|
+
if ((await element.count()) === 0) {
|
|
203
|
+
throw new Error(`Could not find element with selector "${selector}"`);
|
|
204
|
+
}
|
|
205
|
+
return element;
|
|
206
|
+
}
|
|
67
207
|
//# sourceMappingURL=browser.js.map
|
package/dist/browser.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"browser.js","sourceRoot":"","sources":["../src/browser.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"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,11 +1,56 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.BROWSER_EXECUTABLE_PATH = exports.HTTP_REQUESTS_BUFFER_SIZE = exports.CONSOLE_MESSAGES_BUFFER_SIZE = exports.SESSION_CLOSE_ON_SOCKET_CLOSE = exports.SESSION_IDLE_CHECK_SECONDS = exports.SESSION_IDLE_SECONDS = exports.PORT = void 0;
|
|
6
|
+
exports.OTEL_EXPORTER_HTTP_HEADERS = exports.OTEL_EXPORTER_HTTP_URL = exports.OTEL_EXPORTER_TYPE = exports.OTEL_INSTRUMENTATION_USER_INTERACTION_EVENTS = exports.OTEL_ASSETS_DIR = exports.OTEL_SERVICE_VERSION = exports.OTEL_SERVICE_NAME = exports.OTEL_ENABLE = exports.BROWSER_EXECUTABLE_PATH = exports.BROWSER_USE_INSTALLED_ON_SYSTEM = exports.BROWSER_PERSISTENT_USER_DATA_DIR = exports.BROWSER_PERSISTENT_ENABLE = exports.BROWSER_HEADLESS_ENABLE = exports.HTTP_REQUESTS_BUFFER_SIZE = exports.CONSOLE_MESSAGES_BUFFER_SIZE = exports.SESSION_CLOSE_ON_SOCKET_CLOSE = exports.SESSION_IDLE_CHECK_SECONDS = exports.SESSION_IDLE_SECONDS = exports.PORT = void 0;
|
|
7
|
+
const path_1 = __importDefault(require("path"));
|
|
4
8
|
exports.PORT = Number(process.env.PORT) || 3000;
|
|
5
9
|
exports.SESSION_IDLE_SECONDS = Number(process.env.SESSION_IDLE_SECONDS) || 300;
|
|
6
10
|
exports.SESSION_IDLE_CHECK_SECONDS = Number(process.env.SESSION_IDLE_CHECK_SECONDS) || 30;
|
|
7
11
|
exports.SESSION_CLOSE_ON_SOCKET_CLOSE = process.env.SESSION_CLOSE_ON_SOCKET_CLOSE === 'true';
|
|
8
12
|
exports.CONSOLE_MESSAGES_BUFFER_SIZE = Number(process.env.CONSOLE_MESSAGES_BUFFER_SIZE) || 1_000;
|
|
9
13
|
exports.HTTP_REQUESTS_BUFFER_SIZE = Number(process.env.HTTP_REQUESTS_BUFFER_SIZE) || 1_000;
|
|
14
|
+
exports.BROWSER_HEADLESS_ENABLE = (process.env.BROWSER_HEADLESS_ENABLE || 'true') === 'true';
|
|
15
|
+
exports.BROWSER_PERSISTENT_ENABLE = process.env.BROWSER_PERSISTENT_ENABLE === 'true';
|
|
16
|
+
exports.BROWSER_PERSISTENT_USER_DATA_DIR = process.env.BROWSER_PERSISTENT_USER_DATA_DIR ||
|
|
17
|
+
path_1.default.join(process.cwd(), 'browser-devtools-mcp');
|
|
18
|
+
exports.BROWSER_USE_INSTALLED_ON_SYSTEM = process.env.BROWSER_USE_INSTALLED_ON_SYSTEM === 'true';
|
|
10
19
|
exports.BROWSER_EXECUTABLE_PATH = process.env.BROWSER_EXECUTABLE_PATH;
|
|
20
|
+
exports.OTEL_ENABLE = process.env.OTEL_ENABLE === 'true';
|
|
21
|
+
exports.OTEL_SERVICE_NAME = process.env.OTEL_SERVICE_NAME || 'frontend';
|
|
22
|
+
exports.OTEL_SERVICE_VERSION = process.env.OTEL_SERVICE_VERSION;
|
|
23
|
+
exports.OTEL_ASSETS_DIR = process.env.OTEL_ASSETS_DIR;
|
|
24
|
+
exports.OTEL_INSTRUMENTATION_USER_INTERACTION_EVENTS = process
|
|
25
|
+
.env.OTEL_INSTRUMENTATION_USER_INTERACTION_EVENTS
|
|
26
|
+
? process.env.OTEL_INSTRUMENTATION_USER_INTERACTION_EVENTS.split(',')
|
|
27
|
+
: ['click'];
|
|
28
|
+
exports.OTEL_EXPORTER_TYPE = process.env.OTEL_EXPORTER_TYPE || 'none';
|
|
29
|
+
exports.OTEL_EXPORTER_HTTP_URL = process.env.OTEL_EXPORTER_HTTP_URL;
|
|
30
|
+
exports.OTEL_EXPORTER_HTTP_HEADERS = _parseKeyValueFromEnv(process.env.OTEL_EXPORTER_HTTP_HEADERS);
|
|
31
|
+
function _parseKeyValueFromEnv(envValue) {
|
|
32
|
+
const headers = {};
|
|
33
|
+
if (!envValue) {
|
|
34
|
+
return headers;
|
|
35
|
+
}
|
|
36
|
+
const pairs = envValue.split(',');
|
|
37
|
+
for (const pair of pairs) {
|
|
38
|
+
const trimmed = pair.trim();
|
|
39
|
+
if (!trimmed) {
|
|
40
|
+
continue;
|
|
41
|
+
}
|
|
42
|
+
const eqIndex = trimmed.indexOf('=');
|
|
43
|
+
if (eqIndex === -1) {
|
|
44
|
+
// Invalid entry, skip
|
|
45
|
+
continue;
|
|
46
|
+
}
|
|
47
|
+
const key = trimmed.slice(0, eqIndex).trim();
|
|
48
|
+
const value = trimmed.slice(eqIndex + 1).trim();
|
|
49
|
+
if (!key || !value) {
|
|
50
|
+
continue;
|
|
51
|
+
}
|
|
52
|
+
headers[key] = value;
|
|
53
|
+
}
|
|
54
|
+
return headers;
|
|
55
|
+
}
|
|
11
56
|
//# sourceMappingURL=config.js.map
|
package/dist/config.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":";;;;;;AAAA,gDAAwB;AAEX,QAAA,IAAI,GAAW,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC;AAChD,QAAA,oBAAoB,GAC7B,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,oBAAoB,CAAC,IAAI,GAAG,CAAC;AACvC,QAAA,0BAA0B,GACnC,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,0BAA0B,CAAC,IAAI,EAAE,CAAC;AAC5C,QAAA,6BAA6B,GACtC,OAAO,CAAC,GAAG,CAAC,6BAA6B,KAAK,MAAM,CAAC;AAC5C,QAAA,4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