stagehand-cdp
Connects to an existing Chrome browser via Chrome DevTools Protocol (CDP), enabling Stagehand MCP to automate a visible browser session, reuse browser profiles and settings, and load/use Chrome extensions during automation.
This server does not currently have a deployable release on Glama. Follow the repository's setup instructions to install and configure it for your MCP client, including any required credentials and local dependencies.
Stagehand MCP with CDP Support
A modified version of stagehand-mcp-local that adds support for connecting to an existing Chrome browser via Chrome DevTools Protocol (CDP).
šÆ What's This For?
This fork enables Stagehand MCP to control a visible Chrome browser with extensions loaded, instead of launching a new headless browser. Perfect for:
š§© Using Chrome extensions during automation
š Visual debugging - see what's happening in real-time
š Reusing browser sessions with your settings and extensions
š® Full control over browser launch parameters
š Cross-platform - works on Windows, macOS, and Linux
Related MCP server: Chrome DevTools MCP
⨠Features
ā Connect to existing Chrome via CDP
ā Load and use Chrome extensions during automation
ā Persistent Chrome profile with saved extensions and settings
ā Fallback to local browser launch if CDP_URL not set
ā Full Stagehand MCP functionality
ā Works with any Chromium-based browser
ā Cross-platform support (Windows, macOS, Linux)
š Prerequisites
Node.js 18 or higher
npm or pnpm
Google Chrome or any Chromium-based browser
OpenAI API key (for GPT models) or Gemini API key (for Gemini models)
MCP Client (e.g., Claude Desktop, Abacus AI Desktop)
š Installation
1. Clone the Repository
git clone https://github.com/prince-lonestar/stagehand-mcp-local-cdp.git
cd stagehand-mcp-local-cdp2. Install Dependencies
npm install3. Build the Project
npm run buildThis compiles the TypeScript code to JavaScript in the dist/ directory.
4. Configure Your MCP Client
Add the following configuration to your MCP client's config file:
For Claude Desktop
Windows: %APPDATA%\Claude\claude_desktop_config.json
macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
Linux: ~/.config/Claude/claude_desktop_config.json
{
"mcpServers": {
"stagehand-cdp": {
"command": "node",
"args": ["/path/to/stagehand-mcp-local-cdp/cli.js"],
"env": {
"OPENAI_API_KEY": "your-openai-api-key-here",
"STAGEHAND_MODEL": "gpt-4o",
"STAGEHAND_ENV": "LOCAL",
"HEADLESS": "false",
"CDP_URL": "http://localhost:9222"
}
}
}
}For Abacus AI Desktop
Add via Settings ā Integrations ā MCP Servers using the same configuration.
Path Examples by Platform
Windows:
"args": ["C:/Users/YourName/stagehand-mcp-local-cdp/cli.js"]macOS:
"args": ["/Users/YourName/stagehand-mcp-local-cdp/cli.js"]Linux:
"args": ["/home/yourname/stagehand-mcp-local-cdp/cli.js"]Important Notes:
Use forward slashes (
/) in paths - they work on all platforms including WindowsReplace the path with the actual location where you cloned this repository
Replace
your-openai-api-key-herewith your actual OpenAI API keyFor Gemini models, use
GEMINI_API_KEYinstead and setSTAGEHAND_MODELtogemini-2.0-flashor similar
š® Usage
Step 1: Launch Chrome with Remote Debugging
Windows
Run the provided PowerShell script:
.\launch-chrome-debug.ps1macOS / Linux
Run the provided bash script:
./launch-chrome-debug.shNote: On first run, you may need to make the script executable:
chmod +x launch-chrome-debug.shBoth scripts will:
Launch Chrome with remote debugging on port 9222
Create a persistent profile directory
Allow you to install and use Chrome extensions
Open Google as the starting page
First Time Setup:
After launching Chrome, install any extensions you need from the Chrome Web Store
Extensions will persist between sessions in the profile directory
Configuring Extensions:
Windows: Edit
$extensionPathinlaunch-chrome-debug.ps1macOS/Linux: Edit
EXTENSION_PATHinlaunch-chrome-debug.sh
Step 2: Start Your MCP Client
Launch your MCP client (Claude Desktop, Abacus AI Desktop, etc.). It will automatically connect to the running Chrome instance.
Step 3: Use Stagehand Commands
You can now use Stagehand MCP tools to automate the visible Chrome browser:
browserbase_stagehand_navigate- Navigate to a URLbrowserbase_stagehand_act- Perform actions (click, type, etc.)browserbase_stagehand_extract- Extract data from pagesbrowserbase_stagehand_observe- Find elements on the pagebrowserbase_screenshot- Take screenshots
ā ļø Known Issues
Act Tool - DISABLED BY DEFAULT
The browserbase_stagehand_act tool has been disabled by default in this fork due to intermittent Zod schema validation errors with Stagehand 3.0.8 (latest stable version). This is a known upstream issue in the Stagehand library.
Status: 4 out of 5 tools fully functional
ā Navigate - Working
ā Observe - Working
ā Extract - Working
ā Screenshot - Working
ā Act - DISABLED (intermittent failures)
Recommended Workaround:
Use the Observe tool (which works perfectly) combined with direct Playwright commands. See ACT_TOOL_TROUBLESHOOTING.md for detailed solutions.
š§ Configuration Options
Environment Variables
Variable | Description | Default | Required |
| Environment mode |
| Yes |
| Chrome DevTools Protocol URL |
| Yes (for CDP mode) |
| Run browser in headless mode |
| No |
| AI model to use |
| Yes |
| OpenAI API key | - | Yes (for GPT models) |
| Google Gemini API key | - | Yes (for Gemini models) |
Chrome Launch Options
Both launch scripts support customization:
Debug Port: Change 9222 to another port if needed (update both script and MCP config)
Profile Directory:
Windows:
$userDataDirin PowerShell scriptmacOS/Linux:
USER_DATA_DIRin bash script
Extension Loading:
Set the extension path variable to load extensions on startup
Leave as placeholder to launch without extensions
š Troubleshooting
Chrome Won't Launch
Windows:
Error: "Chrome executable not found"
Solution: Update
$chromePathinlaunch-chrome-debug.ps1
macOS:
Error: "Chrome not found at /Applications/Google Chrome.app"
Solution: Install Chrome or update
CHROME_PATHinlaunch-chrome-debug.sh
Linux:
Error: "Chrome/Chromium not found"
Solution: Install Chrome or Chromium:
# Ubuntu/Debian sudo apt install google-chrome-stable # or sudo apt install chromium-browser # Fedora sudo dnf install google-chrome-stable # or sudo dnf install chromium
Extension Issues
Error: "Extension path does not exist"
Solution: Update the extension path in the launch script to point to your extension directory
Note: Extensions must be unpacked (not .crx files)
MCP Server Errors
Error: "Cannot connect to CDP"
Solution: Make sure Chrome is running with remote debugging enabled
Check: Visit
http://localhost:9222/jsonin a browser to verify CDP is accessible
Error: "OPENAI_API_KEY not set"
Solution: Add your API key to the MCP configuration
Port Already in Use
Error: "Port 9222 is already in use"
Solution: Close any existing Chrome instances with debugging enabled, or change the port in both the launch script and your MCP config
Platform-Specific Issues
macOS: "Cannot be opened because the developer cannot be verified"
Solution: Right-click the script ā Open, or run:
xattr -d com.apple.quarantine launch-chrome-debug.sh
Linux: Permission denied
Solution: Make the script executable:
chmod +x launch-chrome-debug.sh
Windows: Script execution disabled
Solution: Run PowerShell as Administrator and execute:
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
š Project Structure
stagehand-mcp-local-cdp/
āāā launch-chrome-debug.ps1 # Windows Chrome launcher
āāā launch-chrome-debug.sh # macOS/Linux Chrome launcher
āāā mcp-config-template.json # MCP configuration template
āāā cli.js # MCP server entry point
āāā index.js # Main module
āāā src/ # TypeScript source files
ā āāā sessionManager.ts # Modified for CDP support
ā āāā ...
āāā dist/ # Compiled JavaScript (after build)
āāā package.json
āāā tsconfig.json
āāā README.md # This file
āāā LICENSE # Apache-2.0 license
āāā CONTRIBUTING.md # Contribution guidelines
āāā .gitignoreš Development
Rebuilding After Changes
If you modify the source code:
npm run buildRunning in Watch Mode
For active development:
npm run watchLinting and Formatting
npm run lint
npm run formatš¤ Contributing
Contributions are welcome! Please see CONTRIBUTING.md for guidelines.
š Credits
Original project: stagehand-mcp-local by weijiafu14
Stagehand framework: Browserbase Stagehand
CDP support and cross-platform enhancements by Jay Farr
š License
Apache-2.0 (same as original project)
š¬ Support
For issues specific to CDP support or cross-platform functionality:
Check that Chrome is running with
--remote-debugging-port=9222Verify
CDP_URLenvironment variable is set correctlyEnsure no firewall is blocking localhost:9222
Confirm extension paths are correct and accessible
For general Stagehand issues, refer to the official Stagehand documentation.
š Why This Fork?
The original stagehand-mcp-local launches its own browser instance, which doesn't support Chrome extensions. This fork:
Connects to existing Chrome via CDP instead of launching a new instance
Supports extensions by using a real Chrome browser with full extension support
Provides visibility - you can watch the automation happen in real-time
Maintains persistence - browser profile, extensions, and settings are saved
Works everywhere - cross-platform scripts for Windows, macOS, and Linux
Perfect for development, testing, and automation workflows that need Chrome extensions!
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelogā¦
This server cannot be deployed
Maintenance
Related MCP Connectors
Cloud browser, web extraction, screenshots, and remote CDP tools for AI agents.
Give AI agents a real cloud Chrome: open sessions, navigate, read pages, click, type and screenshot.
Control a real browser from AI agents: navigate, click, type, screenshot, read the page.
Let AI agents use your real, signed-in Chrome: tabs, clicks, forms, screenshots and video.
Related MCP Servers
- AlicenseBqualityDmaintenanceEnables LLMs to perform browser automation through the Playwright framework with Chrome DevTools Protocol support, connecting to existing Chrome instances for advanced web interactions and JavaScript execution.1252MIT
- AlicenseAqualityCmaintenanceEnables AI coding assistants to control and inspect a live Chrome browser for automation, debugging, performance analysis, and screenshot capture through Chrome DevTools.262,036,574 npm3Apache 2.0
- AlicenseNot gradedqualityDmaintenanceEnables AI coding assistants to control and inspect a live Chrome browser for automation, debugging, performance analysis, network monitoring, and DOM interaction through Chrome DevTools Protocol.Apache 2.0
- AlicenseNot gradedqualityAmaintenanceConnects to your running Chrome browser, enabling AI agents to automate it via Playwright API with existing logins and extensions.4,118MIT