--cdp
- CLI
- --cdp
- REST
- CLI only
Start a server using the Chrome DevTools Protocol, so a Playwright, Puppeteer or other CDP client can control ZShot.
| Form | Behavior |
|---|---|
--cdp HOST:PORT | Prints the endpoint, ws:/, on stdout and serves until ZShot is stopped |
--cdp -- COMMAND | Serves on a loopback port the system picks, runs COMMAND with ZSHOT_ set to the endpoint, and exits with its exit code, or 127 when it cannot start |
--cdp HOST:PORT -- COMMAND | As above, on HOST:PORT |
The endpoint’s path carries a random token, and a client needs the whole URL to connect. The command receives the environment ZShot started with; Ctrl-C reaches it directly, and a SIGTERM sent to ZShot is passed on. --cdp-webdriver adds chromedriver’s attach for WebDriver clients.
Cannot be combined with --server, --mcp-local-server, a URL, -f, -t or --navigate. Each new browser context starts from the storage flags given at startup.
Warning: Window Resizing Is Poorly Supported
The browser has no window. Size a page with the client’s viewport call, such as Playwright’s page.setViewportSize, rather than by resizing its window.
Example
Serve on port 9222:
zshot --cdp 127.0.0.1:9222Run a Playwright script against ZShot, with capture.mjs:
import { chromium } from "playwright-core";
const browser = await chromium.connectOverCDP(process.env.ZSHOT_CDP_URL);
const page = await browser.contexts()[0].newPage();
await page.goto("https://zshot-cli.com/example_assets/hello_zshot/");
await page.screenshot({ path: "hello.png" });
console.log(await page.title());
await browser.close();zshot --cdp -- node capture.mjs