feat(browser): add CDP remote connection support for server environments#23
Closed
ByteYue wants to merge 3 commits intojackwener:mainfrom
Closed
feat(browser): add CDP remote connection support for server environments#23ByteYue wants to merge 3 commits intojackwener:mainfrom
ByteYue wants to merge 3 commits intojackwener:mainfrom
Conversation
910aec8 to
19c3062
Compare
714027b to
0367673
Compare
This feature enables OpenCLI to connect to a Chrome browser running on a different machine (e.g., your local computer) from a headless server environment via Chrome DevTools Protocol (CDP). Server environments (CI, cloud VMs, headless Linux) cannot run Chrome with a GUI or install the Playwright MCP Bridge extension. This makes it impossible to use OpenCLI commands that require browser authentication. Add support for the `OPENCLI_CDP_ENDPOINT` environment variable, which tells OpenCLI to connect to a remote Chrome instance via CDP instead of using the local extension mode. 1. Start Chrome with remote debugging on local machine: ``` chrome --remote-debugging-port=9222 --user-data-dir="$HOME/chrome-debug" ``` 2. Create SSH tunnel to forward port to server: ``` ssh -R 9222:localhost:9222 your-server ``` 3. Run OpenCLI on server: ``` export OPENCLI_CDP_ENDPOINT="http://localhost:9222" opencli bilibili hot --limit 5 ``` - src/browser.ts: Add CDP endpoint detection in buildMcpArgs() - src/doctor.ts: Show CDP mode status in doctor report - README.md: Add "Remote Chrome (Server/Headless)" section - README.zh-CN.md: Add corresponding Chinese documentation 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This adds support for reading DevToolsActivePort (Chrome 144+) when OPENCLI_CDP_ENDPOINT=1, and fixes a bug where CDP connection failures were incorrectly reported as missing extension tokens.
0367673 to
b8ca5f3
Compare
…nd classic CDP modes - Document two connection methods: Chrome 144+ (no restart, ws://) and classic --remote-debugging-port (any version, http://) - Add DevToolsActivePort file paths for all platforms (macOS, Linux, Windows) and browsers (Chrome, Chromium, Edge) - Add environment variable reference table (OPENCLI_CDP_ENDPOINT, CHROME_USER_DATA_DIR) - Add buildMcpArgs CDP unit test covering ws:// and http:// endpoints - Update both README.md and README.zh-CN.md
Contributor
Author
|
#52 includes this pr |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This feature enables OpenCLI to connect to a Chrome browser running on a different machine (e.g., your local computer) from a headless server environment via Chrome DevTools Protocol (CDP).
Motivation
Server environments (CI, cloud VMs, headless Linux) cannot run Chrome with a GUI or install the Playwright MCP Bridge extension. This makes it impossible to use OpenCLI commands that require browser authentication.
Solution
Add support for the
OPENCLI_CDP_ENDPOINTenvironment variable, which tells OpenCLI to connect to a remote Chrome instance via CDP instead of using the local extension mode.Usage
Start Chrome with remote debugging on local machine:
chrome --remote-debugging-port=9222 --user-data-dir="$HOME/chrome-debug"Create SSH tunnel to forward port to server:
ssh -R 9222:localhost:9222 your-serverRun OpenCLI on server:
export OPENCLI_CDP_ENDPOINT="http://localhost:9222" opencli bilibili hot --limit 5Changes
🤖 Generated with Claude Code