browser-devtools-mcp 0.1.4 → 0.1.5
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 +535 -7
- package/SECURITY.md +136 -0
- package/dist/cli.js +1847 -0
- package/dist/cli.js.map +1 -0
- package/dist/config.js +5 -1
- package/dist/config.js.map +1 -1
- package/dist/context.js +7 -7
- package/dist/context.js.map +1 -1
- package/dist/daemon-server.js +338 -0
- package/dist/daemon-server.js.map +1 -0
- package/dist/index.js +3 -260
- package/dist/index.js.map +1 -1
- package/dist/mcp-server.js +401 -0
- package/dist/mcp-server.js.map +1 -0
- package/dist/tools/a11y/take-aria-snapshot.js.map +1 -1
- package/dist/tools/a11y/take-ax-tree-snapshot.js.map +1 -1
- package/dist/tools/content/get-as-html.js.map +1 -1
- package/dist/tools/content/get-as-text.js.map +1 -1
- package/dist/tools/content/save-as-pdf.js.map +1 -1
- package/dist/tools/content/take-screenshot.js.map +1 -1
- package/dist/tools/figma/compare-page-with-design.js.map +1 -1
- package/dist/tools/interaction/click.js.map +1 -1
- package/dist/tools/interaction/drag.js.map +1 -1
- package/dist/tools/interaction/fill.js.map +1 -1
- package/dist/tools/interaction/hover.js.map +1 -1
- package/dist/tools/interaction/press-key.js.map +1 -1
- package/dist/tools/interaction/resize-viewport.js.map +1 -1
- package/dist/tools/interaction/resize-window.js.map +1 -1
- package/dist/tools/interaction/scroll.js.map +1 -1
- package/dist/tools/interaction/select.js.map +1 -1
- package/dist/tools/navigation/go-back.js.map +1 -1
- package/dist/tools/navigation/go-forward.js.map +1 -1
- package/dist/tools/navigation/go-to.js.map +1 -1
- package/dist/tools/navigation/reload.js.map +1 -1
- package/dist/tools/o11y/get-console-messages.js.map +1 -1
- package/dist/tools/o11y/get-http-requests.js.map +1 -1
- package/dist/tools/o11y/get-trace-id.js.map +1 -1
- package/dist/tools/o11y/get-web-vitals.js.map +1 -1
- package/dist/tools/o11y/new-trace-id.js.map +1 -1
- package/dist/tools/o11y/set-trace-id.js.map +1 -1
- package/dist/tools/react/get-component-for-element.js.map +1 -1
- package/dist/tools/react/get-element-for-component.js.map +1 -1
- package/dist/tools/run/js-in-browser.js.map +1 -1
- package/dist/tools/run/js-in-sandbox.js.map +1 -1
- package/dist/tools/stub/clear.js.map +1 -1
- package/dist/tools/stub/intercept-http-request.js.map +1 -1
- package/dist/tools/stub/list.js.map +1 -1
- package/dist/tools/stub/mock-http-response.js.map +1 -1
- package/dist/tools/sync/wait-for-network-idle.js.map +1 -1
- package/dist/tools/tool-executor.js +1 -1
- package/dist/tools/tool-executor.js.map +1 -1
- package/dist/utils/cli-utils.js +253 -0
- package/dist/utils/cli-utils.js.map +1 -0
- package/package.json +6 -3
- package/dist/server.js +0 -154
- package/dist/server.js.map +0 -1
package/README.md
CHANGED
|
@@ -1,10 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
<p align="center">
|
|
2
|
+
<img src="public/icon.svg" alt="Browser DevTools MCP" width="128" height="128">
|
|
3
|
+
<br>
|
|
4
|
+
<strong style="font-size: 2em;">Browser DevTools MCP</strong>
|
|
5
|
+
</p>
|
|
6
|
+
|
|
7
|
+
<p align="center">
|
|
8
|
+
<a href="https://github.com/serkan-ozal/browser-devtools-mcp/actions/workflows/build.yml"><img src="https://github.com/serkan-ozal/browser-devtools-mcp/actions/workflows/build.yml/badge.svg" alt="Build Status"></a>
|
|
9
|
+
<a href="https://www.npmjs.com/package/browser-devtools-mcp"><img src="https://badge.fury.io/js/browser-devtools-mcp.svg" alt="NPM Version"></a>
|
|
10
|
+
<a href="https://github.com/serkan-ozal/browser-devtools-mcp/blob/main/LICENSE"><img src="https://img.shields.io/badge/license-MIT-blue" alt="License"></a>
|
|
11
|
+
</p>
|
|
12
|
+
|
|
13
|
+
<p align="center">
|
|
14
|
+
A powerful <a href="https://modelcontextprotocol.io">Model Context Protocol (MCP)</a> server that provides AI coding assistants with comprehensive browser automation and debugging capabilities using Playwright. This server enables both <strong>execution-level debugging</strong> (logs, network requests) and <strong>visual debugging</strong> (screenshots, ARIA snapshots) to help AI assistants understand and interact with web pages effectively.
|
|
15
|
+
</p>
|
|
8
16
|
|
|
9
17
|
## Overview
|
|
10
18
|
|
|
@@ -385,6 +393,526 @@ npx -y browser-devtools-mcp --transport=streamable-http --port=3000
|
|
|
385
393
|
npx -y @modelcontextprotocol/inspector http://localhost:3000/mcp --transport http
|
|
386
394
|
```
|
|
387
395
|
|
|
396
|
+
## CLI Tool
|
|
397
|
+
|
|
398
|
+
Browser DevTools MCP includes a standalone CLI tool (`browser-devtools-cli`) for direct command-line access to browser automation capabilities. This is particularly useful for:
|
|
399
|
+
|
|
400
|
+
- **Scripting and automation**: Use in shell scripts, CI/CD pipelines, or automated workflows
|
|
401
|
+
- **Session-based testing**: Maintain browser state across multiple commands with session IDs
|
|
402
|
+
- **Skill-based workflows**: Build reusable automation sequences
|
|
403
|
+
|
|
404
|
+
### Installation
|
|
405
|
+
|
|
406
|
+
The CLI is included with the npm package:
|
|
407
|
+
|
|
408
|
+
```bash
|
|
409
|
+
# Run directly with npx
|
|
410
|
+
npx -y browser-devtools-mcp browser-devtools-cli --help
|
|
411
|
+
|
|
412
|
+
# Or install globally
|
|
413
|
+
npm install -g browser-devtools-mcp
|
|
414
|
+
browser-devtools-cli --help
|
|
415
|
+
```
|
|
416
|
+
|
|
417
|
+
### Global Options
|
|
418
|
+
|
|
419
|
+
| Option | Description | Default |
|
|
420
|
+
|--------|-------------|---------|
|
|
421
|
+
| `--port <number>` | Daemon server port | `2020` |
|
|
422
|
+
| `--session-id <string>` | Session ID for maintaining browser state across commands | (none) |
|
|
423
|
+
| `--json` | Output results as JSON | `false` |
|
|
424
|
+
| `--quiet` | Suppress log messages, only show output | `false` |
|
|
425
|
+
| `--verbose` | Enable verbose/debug output for troubleshooting | `false` |
|
|
426
|
+
| `--timeout <ms>` | Timeout for operations in milliseconds | `30000` |
|
|
427
|
+
|
|
428
|
+
### Browser Options
|
|
429
|
+
|
|
430
|
+
| Option | Description | Default |
|
|
431
|
+
|--------|-------------|---------|
|
|
432
|
+
| `--headless` / `--no-headless` | Run browser in headless (no visible window) or headful mode | `true` |
|
|
433
|
+
| `--persistent` / `--no-persistent` | Use persistent browser context (preserves cookies, localStorage) | `false` |
|
|
434
|
+
| `--user-data-dir <path>` | Directory for persistent browser context user data | `./browser-devtools-mcp` |
|
|
435
|
+
| `--use-system-browser` | Use system-installed Chrome instead of bundled browser | `false` |
|
|
436
|
+
| `--browser-path <path>` | Custom browser executable path | (none) |
|
|
437
|
+
|
|
438
|
+
**Note:** Browser options are applied when the daemon server starts. If the daemon is already running, stop it first (`daemon stop`) then start with new options.
|
|
439
|
+
|
|
440
|
+
### Commands
|
|
441
|
+
|
|
442
|
+
The CLI organizes tools into domain-based subcommands:
|
|
443
|
+
|
|
444
|
+
```
|
|
445
|
+
browser-devtools-cli
|
|
446
|
+
├── daemon # Manage the daemon server
|
|
447
|
+
│ ├── start # Start the daemon server
|
|
448
|
+
│ ├── stop # Stop the daemon server
|
|
449
|
+
│ ├── restart # Restart the daemon server (stop + start)
|
|
450
|
+
│ ├── status # Check daemon server status
|
|
451
|
+
│ └── info # Get detailed daemon info (version, uptime, sessions)
|
|
452
|
+
├── session # Manage browser sessions
|
|
453
|
+
│ ├── list # List all active sessions
|
|
454
|
+
│ ├── info <session-id> # Get information about a session
|
|
455
|
+
│ └── delete <session-id> # Delete a specific session
|
|
456
|
+
├── tools # Inspect available tools
|
|
457
|
+
│ ├── list # List all tools (with --domain filter)
|
|
458
|
+
│ ├── info <tool-name> # Get detailed tool info and parameters
|
|
459
|
+
│ └── search <query> # Search tools by name or description
|
|
460
|
+
├── config # Show current configuration
|
|
461
|
+
├── completion # Generate shell completion scripts
|
|
462
|
+
│ ├── bash # Generate bash completion script
|
|
463
|
+
│ └── zsh # Generate zsh completion script
|
|
464
|
+
├── interactive (repl) # Start interactive REPL mode
|
|
465
|
+
├── update # Check for and install updates
|
|
466
|
+
├── navigation # Navigation commands
|
|
467
|
+
│ ├── go-to # Navigate to a URL
|
|
468
|
+
│ ├── go-back # Navigate backward
|
|
469
|
+
│ ├── go-forward # Navigate forward
|
|
470
|
+
│ └── reload # Reload the page
|
|
471
|
+
├── content # Content extraction commands
|
|
472
|
+
│ ├── take-screenshot # Take a screenshot
|
|
473
|
+
│ ├── get-as-html # Get HTML content
|
|
474
|
+
│ ├── get-as-text # Get text content
|
|
475
|
+
│ └── save-as-pdf # Save as PDF
|
|
476
|
+
├── interaction # Interaction commands
|
|
477
|
+
│ ├── click # Click an element
|
|
478
|
+
│ ├── fill # Fill a form field
|
|
479
|
+
│ ├── hover # Hover over an element
|
|
480
|
+
│ ├── press-key # Press a keyboard key
|
|
481
|
+
│ ├── select # Select from dropdown
|
|
482
|
+
│ ├── drag # Drag and drop
|
|
483
|
+
│ ├── scroll # Scroll the page
|
|
484
|
+
│ ├── resize-viewport # Resize viewport
|
|
485
|
+
│ └── resize-window # Resize browser window
|
|
486
|
+
├── a11y # Accessibility commands
|
|
487
|
+
│ └── take-aria-snapshot # Take ARIA snapshot
|
|
488
|
+
├── accessibility # Extended accessibility commands
|
|
489
|
+
│ └── take-ax-tree-snapshot # Take AX tree snapshot
|
|
490
|
+
├── o11y # Observability commands
|
|
491
|
+
│ ├── get-console-messages # Get console logs
|
|
492
|
+
│ ├── get-http-requests # Get HTTP requests
|
|
493
|
+
│ ├── get-web-vitals # Get Web Vitals metrics
|
|
494
|
+
│ ├── get-trace-id # Get current trace ID
|
|
495
|
+
│ ├── new-trace-id # Generate new trace ID
|
|
496
|
+
│ └── set-trace-id # Set trace ID
|
|
497
|
+
├── react # React debugging commands
|
|
498
|
+
│ ├── get-component-for-element
|
|
499
|
+
│ └── get-element-for-component
|
|
500
|
+
├── run # Script execution commands
|
|
501
|
+
│ ├── js-in-browser # Run JS in browser
|
|
502
|
+
│ └── js-in-sandbox # Run JS in sandbox
|
|
503
|
+
├── stub # HTTP stubbing commands
|
|
504
|
+
│ ├── mock-http-response # Mock HTTP responses
|
|
505
|
+
│ ├── intercept-http-request # Intercept requests
|
|
506
|
+
│ ├── list # List stubs
|
|
507
|
+
│ └── clear # Clear stubs
|
|
508
|
+
├── sync # Synchronization commands
|
|
509
|
+
│ └── wait-for-network-idle # Wait for network idle
|
|
510
|
+
└── figma # Figma integration commands
|
|
511
|
+
└── compare-page-with-design
|
|
512
|
+
```
|
|
513
|
+
|
|
514
|
+
### Usage Examples
|
|
515
|
+
|
|
516
|
+
#### Basic Navigation and Screenshot
|
|
517
|
+
|
|
518
|
+
```bash
|
|
519
|
+
# Navigate to a URL
|
|
520
|
+
browser-devtools-cli navigation go-to --url "https://example.com"
|
|
521
|
+
|
|
522
|
+
# Take a screenshot
|
|
523
|
+
browser-devtools-cli content take-screenshot --name "homepage"
|
|
524
|
+
```
|
|
525
|
+
|
|
526
|
+
#### Browser Options
|
|
527
|
+
|
|
528
|
+
Configure browser behavior when starting the daemon:
|
|
529
|
+
|
|
530
|
+
```bash
|
|
531
|
+
# Run browser in headful mode (visible window)
|
|
532
|
+
browser-devtools-cli --no-headless navigation go-to --url "https://example.com"
|
|
533
|
+
|
|
534
|
+
# Use persistent browser context
|
|
535
|
+
browser-devtools-cli --persistent --user-data-dir ./my-profile navigation go-to --url "https://example.com"
|
|
536
|
+
|
|
537
|
+
# Use system Chrome instead of bundled Chromium
|
|
538
|
+
browser-devtools-cli --use-system-browser navigation go-to --url "https://example.com"
|
|
539
|
+
|
|
540
|
+
# Use a custom browser executable
|
|
541
|
+
browser-devtools-cli --browser-path /path/to/chrome navigation go-to --url "https://example.com"
|
|
542
|
+
```
|
|
543
|
+
|
|
544
|
+
#### Session-Based Workflow
|
|
545
|
+
|
|
546
|
+
Maintain browser state across multiple commands using session IDs:
|
|
547
|
+
|
|
548
|
+
```bash
|
|
549
|
+
# Start a session and navigate
|
|
550
|
+
browser-devtools-cli --session-id my-session navigation go-to --url "https://example.com"
|
|
551
|
+
|
|
552
|
+
# Interact with the page (same session)
|
|
553
|
+
browser-devtools-cli --session-id my-session interaction click --selector "button.login"
|
|
554
|
+
|
|
555
|
+
# Fill a form
|
|
556
|
+
browser-devtools-cli --session-id my-session interaction fill --selector "#username" --value "user@example.com"
|
|
557
|
+
|
|
558
|
+
# Take a screenshot
|
|
559
|
+
browser-devtools-cli --session-id my-session content take-screenshot --name "after-login"
|
|
560
|
+
|
|
561
|
+
# Clean up session when done
|
|
562
|
+
browser-devtools-cli session delete my-session
|
|
563
|
+
```
|
|
564
|
+
|
|
565
|
+
#### JSON Output for Scripting
|
|
566
|
+
|
|
567
|
+
Use `--json` and `--quiet` flags for machine-readable output:
|
|
568
|
+
|
|
569
|
+
```bash
|
|
570
|
+
# Get page content as JSON
|
|
571
|
+
browser-devtools-cli --json --quiet --session-id test navigation go-to --url "https://api.example.com"
|
|
572
|
+
|
|
573
|
+
# Output:
|
|
574
|
+
# {
|
|
575
|
+
# "url": "https://api.example.com/",
|
|
576
|
+
# "status": 200,
|
|
577
|
+
# "statusText": "",
|
|
578
|
+
# "ok": true
|
|
579
|
+
# }
|
|
580
|
+
```
|
|
581
|
+
|
|
582
|
+
#### Daemon Management
|
|
583
|
+
|
|
584
|
+
```bash
|
|
585
|
+
# Check daemon status
|
|
586
|
+
browser-devtools-cli daemon status
|
|
587
|
+
|
|
588
|
+
# Start daemon manually
|
|
589
|
+
browser-devtools-cli daemon start
|
|
590
|
+
|
|
591
|
+
# Stop daemon
|
|
592
|
+
browser-devtools-cli daemon stop
|
|
593
|
+
|
|
594
|
+
# Restart daemon (useful when changing browser options)
|
|
595
|
+
browser-devtools-cli daemon restart
|
|
596
|
+
|
|
597
|
+
# Check status with JSON output
|
|
598
|
+
browser-devtools-cli daemon status --json
|
|
599
|
+
# Output: {"status":"running","port":2020}
|
|
600
|
+
|
|
601
|
+
# Get detailed daemon information
|
|
602
|
+
browser-devtools-cli daemon info
|
|
603
|
+
# Output:
|
|
604
|
+
# Daemon Server Information:
|
|
605
|
+
# Version: 0.5.0
|
|
606
|
+
# Port: 2020
|
|
607
|
+
# Uptime: 5m 23s
|
|
608
|
+
# Sessions: 2
|
|
609
|
+
```
|
|
610
|
+
|
|
611
|
+
#### Session Management
|
|
612
|
+
|
|
613
|
+
```bash
|
|
614
|
+
# List all active sessions
|
|
615
|
+
browser-devtools-cli session list
|
|
616
|
+
# Output:
|
|
617
|
+
# Active Sessions (2):
|
|
618
|
+
# my-session
|
|
619
|
+
# Created: 2025-01-26T10:00:00.000Z
|
|
620
|
+
# Last Active: 2025-01-26T10:05:30.000Z
|
|
621
|
+
# Idle: 30s
|
|
622
|
+
# #default
|
|
623
|
+
# Created: 2025-01-26T09:55:00.000Z
|
|
624
|
+
# Last Active: 2025-01-26T10:04:00.000Z
|
|
625
|
+
# Idle: 1m 30s
|
|
626
|
+
|
|
627
|
+
# Get info about a specific session
|
|
628
|
+
browser-devtools-cli session info my-session
|
|
629
|
+
|
|
630
|
+
# Delete a session
|
|
631
|
+
browser-devtools-cli session delete my-session
|
|
632
|
+
```
|
|
633
|
+
|
|
634
|
+
#### Tool Discovery
|
|
635
|
+
|
|
636
|
+
```bash
|
|
637
|
+
# List all available tools
|
|
638
|
+
browser-devtools-cli tools list
|
|
639
|
+
# Output:
|
|
640
|
+
# Available Tools (35 total):
|
|
641
|
+
#
|
|
642
|
+
# navigation:
|
|
643
|
+
# go-to Navigate the browser to the given URL...
|
|
644
|
+
# go-back Navigate back in browser history
|
|
645
|
+
# ...
|
|
646
|
+
|
|
647
|
+
# Filter tools by domain
|
|
648
|
+
browser-devtools-cli tools list --domain interaction
|
|
649
|
+
|
|
650
|
+
# Search for tools by keyword
|
|
651
|
+
browser-devtools-cli tools search click
|
|
652
|
+
# Output:
|
|
653
|
+
# Tools matching "click" (2 found):
|
|
654
|
+
#
|
|
655
|
+
# interaction/click
|
|
656
|
+
# Clicks an element on the page.
|
|
657
|
+
# ...
|
|
658
|
+
|
|
659
|
+
# Get detailed info about a specific tool
|
|
660
|
+
browser-devtools-cli tools info navigation_go-to
|
|
661
|
+
# Output:
|
|
662
|
+
# Tool: navigation_go-to
|
|
663
|
+
# Domain: navigation
|
|
664
|
+
#
|
|
665
|
+
# Description:
|
|
666
|
+
# Navigate the browser to the given URL...
|
|
667
|
+
#
|
|
668
|
+
# Parameters:
|
|
669
|
+
# --url <string> (required)
|
|
670
|
+
# The URL to navigate to
|
|
671
|
+
# --wait-until <load | domcontentloaded | networkidle> (optional)
|
|
672
|
+
# When to consider navigation succeeded
|
|
673
|
+
# Default: "load"
|
|
674
|
+
#
|
|
675
|
+
# Usage:
|
|
676
|
+
# browser-devtools-cli navigation go-to [options]
|
|
677
|
+
```
|
|
678
|
+
|
|
679
|
+
#### Configuration
|
|
680
|
+
|
|
681
|
+
```bash
|
|
682
|
+
# Show current configuration
|
|
683
|
+
browser-devtools-cli config
|
|
684
|
+
# Output:
|
|
685
|
+
# Current Configuration:
|
|
686
|
+
#
|
|
687
|
+
# Daemon:
|
|
688
|
+
# Port: 2020
|
|
689
|
+
# Session Idle (sec): 300
|
|
690
|
+
# Idle Check Interval: 30
|
|
691
|
+
#
|
|
692
|
+
# Browser:
|
|
693
|
+
# Headless: true
|
|
694
|
+
# Persistent: false
|
|
695
|
+
# ...
|
|
696
|
+
|
|
697
|
+
# Show config as JSON
|
|
698
|
+
browser-devtools-cli config --json
|
|
699
|
+
```
|
|
700
|
+
|
|
701
|
+
#### Verbose/Debug Mode
|
|
702
|
+
|
|
703
|
+
Enable verbose output for troubleshooting:
|
|
704
|
+
|
|
705
|
+
```bash
|
|
706
|
+
# Run any command with --verbose for detailed debug logs
|
|
707
|
+
browser-devtools-cli --verbose navigation go-to --url "https://example.com"
|
|
708
|
+
# Output:
|
|
709
|
+
# [2025-01-26T10:00:00.000Z] [DEBUG] Verbose mode enabled
|
|
710
|
+
# [2025-01-26T10:00:00.001Z] [DEBUG] CLI version: 0.5.0
|
|
711
|
+
# [2025-01-26T10:00:00.001Z] [DEBUG] Node version: v20.10.0
|
|
712
|
+
# [2025-01-26T10:00:00.001Z] [DEBUG] Platform: darwin
|
|
713
|
+
# [2025-01-26T10:00:00.002Z] [DEBUG] Checking if daemon is running on port 2020
|
|
714
|
+
# [2025-01-26T10:00:00.010Z] [DEBUG] Daemon health check result: running
|
|
715
|
+
# [2025-01-26T10:00:00.011Z] [DEBUG] Calling tool: navigation_go-to
|
|
716
|
+
# [2025-01-26T10:00:00.011Z] [DEBUG] Tool input: { url: "https://example.com" }
|
|
717
|
+
# ...
|
|
718
|
+
```
|
|
719
|
+
|
|
720
|
+
#### Tool Search
|
|
721
|
+
|
|
722
|
+
Find tools by keyword:
|
|
723
|
+
|
|
724
|
+
```bash
|
|
725
|
+
# Search for tools related to "screenshot"
|
|
726
|
+
browser-devtools-cli tools search screenshot
|
|
727
|
+
# Output:
|
|
728
|
+
# Tools matching "screenshot" (2 found):
|
|
729
|
+
#
|
|
730
|
+
# content/take-screenshot
|
|
731
|
+
# Takes a screenshot of the current page or a specific element.
|
|
732
|
+
#
|
|
733
|
+
# figma/compare-page-with-design
|
|
734
|
+
# Compares the CURRENT PAGE UI against a Figma design snapshot...
|
|
735
|
+
|
|
736
|
+
# Search for tools related to "network"
|
|
737
|
+
browser-devtools-cli tools search network
|
|
738
|
+
```
|
|
739
|
+
|
|
740
|
+
#### Shell Completions
|
|
741
|
+
|
|
742
|
+
Enable tab completion for faster command entry. Shell completions require a one-time setup:
|
|
743
|
+
|
|
744
|
+
**For Bash:**
|
|
745
|
+
```bash
|
|
746
|
+
# Option 1: Add to ~/.bashrc (recommended)
|
|
747
|
+
echo 'eval "$(browser-devtools-cli completion bash)"' >> ~/.bashrc
|
|
748
|
+
source ~/.bashrc
|
|
749
|
+
|
|
750
|
+
# Option 2: Or add manually to ~/.bashrc
|
|
751
|
+
eval "$(browser-devtools-cli completion bash)"
|
|
752
|
+
```
|
|
753
|
+
|
|
754
|
+
**For Zsh (macOS default):**
|
|
755
|
+
```bash
|
|
756
|
+
# Option 1: Add to ~/.zshrc (recommended)
|
|
757
|
+
echo 'eval "$(browser-devtools-cli completion zsh)"' >> ~/.zshrc
|
|
758
|
+
source ~/.zshrc
|
|
759
|
+
|
|
760
|
+
# Option 2: Or add manually to ~/.zshrc
|
|
761
|
+
eval "$(browser-devtools-cli completion zsh)"
|
|
762
|
+
```
|
|
763
|
+
|
|
764
|
+
**Using with npx:**
|
|
765
|
+
```bash
|
|
766
|
+
# If using npx instead of global install:
|
|
767
|
+
echo 'eval "$(npx -y browser-devtools-cli completion zsh)"' >> ~/.zshrc
|
|
768
|
+
source ~/.zshrc
|
|
769
|
+
```
|
|
770
|
+
|
|
771
|
+
After setup, press TAB for completions:
|
|
772
|
+
```bash
|
|
773
|
+
browser-devtools-cli dae<TAB> # Completes to "daemon"
|
|
774
|
+
browser-devtools-cli daemon st<TAB> # Shows "start", "stop", "status", "restart"
|
|
775
|
+
browser-devtools-cli --<TAB> # Shows all global options
|
|
776
|
+
```
|
|
777
|
+
|
|
778
|
+
#### Interactive REPL Mode
|
|
779
|
+
|
|
780
|
+
Start an interactive session for continuous command entry:
|
|
781
|
+
|
|
782
|
+
```bash
|
|
783
|
+
# Start in headless mode (default)
|
|
784
|
+
browser-devtools-cli interactive
|
|
785
|
+
|
|
786
|
+
# Start with visible browser window
|
|
787
|
+
browser-devtools-cli --no-headless interactive
|
|
788
|
+
|
|
789
|
+
# Start with persistent context (preserves cookies, localStorage)
|
|
790
|
+
browser-devtools-cli --no-headless --persistent interactive
|
|
791
|
+
|
|
792
|
+
# Aliases
|
|
793
|
+
browser-devtools-cli repl
|
|
794
|
+
browser-devtools-cli --no-headless repl
|
|
795
|
+
```
|
|
796
|
+
|
|
797
|
+
**Example session:**
|
|
798
|
+
|
|
799
|
+
```
|
|
800
|
+
Browser DevTools CLI - Interactive Mode
|
|
801
|
+
Type "help" for available commands, "exit" to quit
|
|
802
|
+
|
|
803
|
+
browser> navigation go-to --url "https://example.com"
|
|
804
|
+
url: https://example.com/
|
|
805
|
+
status: 200
|
|
806
|
+
ok: true
|
|
807
|
+
|
|
808
|
+
browser> content take-screenshot --name "homepage"
|
|
809
|
+
path: /path/to/homepage.png
|
|
810
|
+
|
|
811
|
+
browser> interaction click --ref "Login"
|
|
812
|
+
clicked: true
|
|
813
|
+
|
|
814
|
+
browser> interaction fill --ref "Email" --value "test@example.com"
|
|
815
|
+
filled: true
|
|
816
|
+
|
|
817
|
+
browser> tools search screenshot
|
|
818
|
+
Found 2 tools:
|
|
819
|
+
content_take-screenshot - Take a screenshot of the current page
|
|
820
|
+
content_take-pdf - Generate a PDF of the current page
|
|
821
|
+
|
|
822
|
+
browser> daemon info
|
|
823
|
+
Version: 0.5.0
|
|
824
|
+
Uptime: 5m 23s
|
|
825
|
+
Sessions: 1
|
|
826
|
+
Port: 2020
|
|
827
|
+
|
|
828
|
+
browser> session list
|
|
829
|
+
Active sessions: 1
|
|
830
|
+
#default (idle: 30s)
|
|
831
|
+
|
|
832
|
+
browser> config
|
|
833
|
+
Current Configuration:
|
|
834
|
+
port = 2020
|
|
835
|
+
headless = false
|
|
836
|
+
persistent = true
|
|
837
|
+
...
|
|
838
|
+
|
|
839
|
+
browser> exit
|
|
840
|
+
Goodbye!
|
|
841
|
+
```
|
|
842
|
+
|
|
843
|
+
**Available commands in interactive mode:**
|
|
844
|
+
|
|
845
|
+
| Command | Description |
|
|
846
|
+
|---------|-------------|
|
|
847
|
+
| `help` | Show available commands |
|
|
848
|
+
| `exit`, `quit` | Exit interactive mode |
|
|
849
|
+
| `status` | Show daemon status summary |
|
|
850
|
+
| `config` | Show current configuration |
|
|
851
|
+
| `daemon <cmd>` | Daemon management (start, stop, restart, status, info) |
|
|
852
|
+
| `session <cmd>` | Session management (list, info, delete) |
|
|
853
|
+
| `tools <cmd>` | Tool discovery (list, search, info) |
|
|
854
|
+
| `update` | Check for CLI updates |
|
|
855
|
+
| `<domain> <tool>` | Execute a tool |
|
|
856
|
+
|
|
857
|
+
#### Check for Updates
|
|
858
|
+
|
|
859
|
+
Keep your CLI up to date:
|
|
860
|
+
|
|
861
|
+
```bash
|
|
862
|
+
# Check for updates without installing
|
|
863
|
+
browser-devtools-cli update --check
|
|
864
|
+
# Output:
|
|
865
|
+
# Checking for updates...
|
|
866
|
+
#
|
|
867
|
+
# Current version: 0.5.0
|
|
868
|
+
# Latest version: 0.5.1
|
|
869
|
+
#
|
|
870
|
+
# ⚠ Update available: 0.5.0 → 0.5.1
|
|
871
|
+
#
|
|
872
|
+
# To update, run:
|
|
873
|
+
# npm install -g browser-devtools-mcp@latest
|
|
874
|
+
|
|
875
|
+
# Check and install updates interactively
|
|
876
|
+
browser-devtools-cli update
|
|
877
|
+
# Output:
|
|
878
|
+
# ...
|
|
879
|
+
# Do you want to update now? (y/N) y
|
|
880
|
+
# Updating...
|
|
881
|
+
# ✓ Update complete!
|
|
882
|
+
```
|
|
883
|
+
|
|
884
|
+
#### Shell Script Example
|
|
885
|
+
|
|
886
|
+
```bash
|
|
887
|
+
#!/bin/bash
|
|
888
|
+
SESSION="test-$(date +%s)"
|
|
889
|
+
CLI="browser-devtools-cli --json --quiet --session-id $SESSION"
|
|
890
|
+
|
|
891
|
+
# Navigate
|
|
892
|
+
$CLI navigation go-to --url "https://example.com"
|
|
893
|
+
|
|
894
|
+
# Get text content
|
|
895
|
+
CONTENT=$($CLI content get-as-text)
|
|
896
|
+
echo "Page content: $CONTENT"
|
|
897
|
+
|
|
898
|
+
# Take screenshot
|
|
899
|
+
$CLI content take-screenshot --name "test-result"
|
|
900
|
+
|
|
901
|
+
# Cleanup
|
|
902
|
+
browser-devtools-cli session delete $SESSION
|
|
903
|
+
```
|
|
904
|
+
|
|
905
|
+
### Daemon Architecture
|
|
906
|
+
|
|
907
|
+
The CLI uses a daemon server architecture for efficient browser management:
|
|
908
|
+
|
|
909
|
+
1. **Auto-start**: The daemon starts automatically when you run any tool command
|
|
910
|
+
2. **Shared browser**: Multiple CLI invocations share the same browser instance
|
|
911
|
+
3. **Session isolation**: Each session ID gets its own isolated browser context
|
|
912
|
+
4. **Auto-cleanup**: Idle sessions are automatically cleaned up after inactivity
|
|
913
|
+
|
|
914
|
+
The daemon listens on port 2020 by default. Use `--port` to specify a different port.
|
|
915
|
+
|
|
388
916
|
## Configuration
|
|
389
917
|
|
|
390
918
|
The server can be configured using environment variables:
|
package/SECURITY.md
ADDED
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
# Security Policy
|
|
2
|
+
|
|
3
|
+
## Supported Versions
|
|
4
|
+
|
|
5
|
+
| Version | Supported |
|
|
6
|
+
| ------- | ------------------ |
|
|
7
|
+
| 0.1.x | :white_check_mark: |
|
|
8
|
+
|
|
9
|
+
## Reporting a Vulnerability
|
|
10
|
+
|
|
11
|
+
If you discover a security vulnerability in Browser DevTools MCP, please report it responsibly.
|
|
12
|
+
|
|
13
|
+
### How to Report
|
|
14
|
+
|
|
15
|
+
1. **DO NOT** create a public GitHub issue for security vulnerabilities
|
|
16
|
+
2. Report via one of these methods:
|
|
17
|
+
- **GitHub Security Advisory** (preferred): [Create a security advisory](https://github.com/serkan-ozal/browser-devtools-mcp/security/advisories/new)
|
|
18
|
+
- **Email**: serkanozal86@gmail.com
|
|
19
|
+
3. Include the following information:
|
|
20
|
+
- Description of the vulnerability
|
|
21
|
+
- Steps to reproduce
|
|
22
|
+
- Potential impact
|
|
23
|
+
- Suggested fix (if any)
|
|
24
|
+
|
|
25
|
+
### What to Expect
|
|
26
|
+
|
|
27
|
+
- **Acknowledgment**: You will receive an acknowledgment within 48 hours
|
|
28
|
+
- **Updates**: We will keep you informed of our progress
|
|
29
|
+
- **Resolution**: We aim to resolve critical issues within 7 days
|
|
30
|
+
- **Credit**: With your permission, we will credit you in the release notes
|
|
31
|
+
|
|
32
|
+
## Security Considerations
|
|
33
|
+
|
|
34
|
+
### Browser Automation Risks
|
|
35
|
+
|
|
36
|
+
Browser DevTools MCP provides powerful browser automation capabilities. Users should be aware of:
|
|
37
|
+
|
|
38
|
+
1. **Code Execution**: The `run_js-in-browser` and `run_js-in-sandbox` tools execute arbitrary JavaScript code
|
|
39
|
+
- `run_js-in-browser`: Executes in the page context with full DOM access
|
|
40
|
+
- `run_js-in-sandbox`: Executes in a Node.js VM sandbox (NOT a security boundary)
|
|
41
|
+
- Only use with trusted code inputs
|
|
42
|
+
|
|
43
|
+
2. **Network Access**: The browser can make requests to any URL
|
|
44
|
+
- HTTP requests from the browser inherit the page's cookies and session
|
|
45
|
+
- Stubbing/mocking tools can intercept and modify requests
|
|
46
|
+
- Be cautious when automating authenticated sessions
|
|
47
|
+
|
|
48
|
+
3. **Persistent Context**: When `BROWSER_PERSISTENT_ENABLE=true`
|
|
49
|
+
- Browser state (cookies, localStorage) persists across sessions
|
|
50
|
+
- User data is stored in `BROWSER_PERSISTENT_USER_DATA_DIR`
|
|
51
|
+
- Sensitive data may be stored locally
|
|
52
|
+
|
|
53
|
+
4. **Screenshot/PDF Capture**: Content tools can capture sensitive information
|
|
54
|
+
- Screenshots may contain PII or credentials visible on screen
|
|
55
|
+
- PDFs preserve full page content
|
|
56
|
+
- Be mindful of what pages are captured
|
|
57
|
+
|
|
58
|
+
### API Keys and Secrets
|
|
59
|
+
|
|
60
|
+
The following environment variables may contain sensitive information:
|
|
61
|
+
|
|
62
|
+
| Variable | Sensitivity | Description |
|
|
63
|
+
|----------|-------------|-------------|
|
|
64
|
+
| `FIGMA_ACCESS_TOKEN` | High | Figma API access token |
|
|
65
|
+
| `OTEL_EXPORTER_HTTP_HEADERS` | High | May contain API keys for observability platforms |
|
|
66
|
+
| `AWS_PROFILE` | Medium | AWS credentials profile name |
|
|
67
|
+
|
|
68
|
+
**Best Practices:**
|
|
69
|
+
- Never commit secrets to version control
|
|
70
|
+
- Use environment variables or secret management tools
|
|
71
|
+
- Rotate API keys regularly
|
|
72
|
+
- Use minimal-permission API tokens
|
|
73
|
+
|
|
74
|
+
### Network Security
|
|
75
|
+
|
|
76
|
+
When using HTTP transport (`--transport=streamable-http`):
|
|
77
|
+
|
|
78
|
+
1. **Local Development**: The server binds to `localhost` by default
|
|
79
|
+
2. **Remote Deployment**:
|
|
80
|
+
- Always use HTTPS in production
|
|
81
|
+
- Implement authentication/authorization
|
|
82
|
+
- Consider network isolation
|
|
83
|
+
3. **CORS**: The server does not implement CORS restrictions by default
|
|
84
|
+
|
|
85
|
+
### Session Security
|
|
86
|
+
|
|
87
|
+
- Sessions are isolated per MCP client connection
|
|
88
|
+
- Session data is stored in memory (not persisted by default)
|
|
89
|
+
- Idle sessions are automatically cleaned up (`SESSION_IDLE_SECONDS`)
|
|
90
|
+
- Setting `SESSION_CLOSE_ON_SOCKET_CLOSE=true` closes sessions immediately on disconnect
|
|
91
|
+
|
|
92
|
+
## Security Features
|
|
93
|
+
|
|
94
|
+
### Sandbox Isolation
|
|
95
|
+
|
|
96
|
+
The `run_js-in-sandbox` tool provides limited isolation:
|
|
97
|
+
- Runs in Node.js VM context
|
|
98
|
+
- No access to `require`, `process`, `fs`, `Buffer`
|
|
99
|
+
- Limited built-in APIs available
|
|
100
|
+
- **Note**: This is NOT a security boundary - treat all input as trusted
|
|
101
|
+
|
|
102
|
+
### OpenTelemetry Security
|
|
103
|
+
|
|
104
|
+
When using OpenTelemetry integration:
|
|
105
|
+
- Trace data may contain sensitive URL paths and parameters
|
|
106
|
+
- Headers can be configured to authenticate with collectors
|
|
107
|
+
- Consider what data is being exported to observability platforms
|
|
108
|
+
|
|
109
|
+
## Responsible Disclosure
|
|
110
|
+
|
|
111
|
+
We kindly ask security researchers to:
|
|
112
|
+
|
|
113
|
+
1. Give us reasonable time to fix issues before public disclosure
|
|
114
|
+
2. Avoid accessing or modifying other users' data
|
|
115
|
+
3. Act in good faith to avoid privacy violations and service disruptions
|
|
116
|
+
|
|
117
|
+
We commit to:
|
|
118
|
+
|
|
119
|
+
1. Not pursuing legal action against researchers acting in good faith
|
|
120
|
+
2. Working with you to understand and resolve the issue
|
|
121
|
+
3. Acknowledging your contribution (with your permission)
|
|
122
|
+
|
|
123
|
+
## Security Updates
|
|
124
|
+
|
|
125
|
+
Security updates are released as patch versions. We recommend:
|
|
126
|
+
|
|
127
|
+
1. Always using the latest version
|
|
128
|
+
2. Subscribing to GitHub releases for notifications
|
|
129
|
+
3. Reviewing the changelog for security-related fixes
|
|
130
|
+
|
|
131
|
+
## Contact
|
|
132
|
+
|
|
133
|
+
For security-related inquiries:
|
|
134
|
+
- **GitHub Security Advisory**: [Report a vulnerability](https://github.com/serkan-ozal/browser-devtools-mcp/security/advisories/new)
|
|
135
|
+
- **Email**: serkanozal86@gmail.com
|
|
136
|
+
- **GitHub**: [@serkan-ozal](https://github.com/serkan-ozal)
|