Skip to main content

cdp-connect-kit

Playwright connect_over_cdp kit — parse MLX Launcher ports, health-check CDP, retry Playwright attach with metrics.

PyPI version Python versions License: MIT

pip install cdp-connect-kit
cdp-connect ping 127.0.0.1:9222

CLI: cdp-connect · Python 3.10+ · optional [mlx] for Launcher helpers

CDP connection toolkit — parse Chrome DevTools Protocol endpoints, validate WebSocket URLs, connect Playwright with retry + timeout + health metrics, and watch endpoint uptime.

Optional [mlx] extra: start Multilogin X profiles via Launcher API → auto connect_over_cdp.

Partner (optional): Production CDP attach goes through MLX Launcher (isolated profiles). Multilogin X · SAAS50 / MIN50 on eligible new purchases. ping / playwright work on any CDP server without MLX. Affiliate disclosure · Multilogin promo codes.

Problem

Connecting Playwright to a remote or antidetect browser over CDP fails for predictable reasons:

  • Wrong URL shape (ws:// vs http://127.0.0.1:PORT)
  • Browser not finished starting
  • Fragile one-shot connect_over_cdp with no metrics

cdp-connect normalizes endpoints, waits for /json/version, retries connections, and reports health.

Install

pip install cdp-connect-kit
playwright install chromium

MLX Launcher integration:

pip install cdp-connect-kit[mlx]

Quick start

# Ping a CDP endpoint (HTTP or WebSocket URL)
cdp-connect ping ws://127.0.0.1:9222/devtools/browser/abc

# Connect Playwright and screenshot
cdp-connect playwright --endpoint http://127.0.0.1:9222 --screenshot out.png

# Watch health — JSON Lines for farm-runner piping
cdp-connect watch --endpoint 127.0.0.1:9222 --interval 5 | tee health.jsonl

Connection flow

sequenceDiagram
    participant MLX as MLX Launcher
    participant CDP as CDP HTTP :PORT
    participant PW as Playwright

    MLX->>MLX: GET /profile/.../start
    MLX-->>CDP: data.port → http://127.0.0.1:PORT
    PW->>CDP: GET /json/version
    CDP-->>PW: webSocketDebuggerUrl
    PW->>PW: connect_over_cdp(http://127.0.0.1:PORT)

CLI

Command Description
cdp-connect ping ENDPOINT Validate /json/version, print WebSocket URL
cdp-connect playwright --endpoint URL [--screenshot FILE] Connect with retry, emit metrics JSON
cdp-connect watch --endpoint URL Poll health as JSON Lines (default)
cdp-connect watch --format plain Human-readable UP/DOWN lines
cdp-connect playwright --max-retries N Connect with exponential backoff
cdp-connect mlx-start --profile-id UUID [--print-cdp-url] Start MLX profile, wait for CDP ([mlx])
cdp-connect mlx-stop --profile-id UUID Stop MLX profile — idempotent ([mlx])
cdp-connect mlx-list List running Launcher sessions ([mlx])

Endpoint formats: http://127.0.0.1:9222, ws://127.0.0.1:9222/devtools/browser/…, 127.0.0.1:9222 (shorthand; default port 9222).

MLX launcher flow

  1. GET launcher.mlx.yt:45001/api/v2/profile/f/{folder}/p/{profile}/start?automation_type=playwright
  2. Read data.port from JSON response
  3. CDP HTTP base = http://127.0.0.1:{port}
  4. GET /json/version → webSocketDebuggerUrl
  5. playwright.chromium.connect_over_cdp(http://127.0.0.1:{port})

Canonical MLX bridge for the monorepo: docs/MLX_INTEGRATION.md · Env: docs/ENV.md

export MLX_TOKEN="..."
export MLX_FOLDER_ID="..."
export MLX_LAUNCHER_URL="https://launcher.mlx.yt:45001"   # optional

# Scripting: CDP URL on stdout
CDP_URL=$(cdp-connect mlx-start --profile-id PROFILE_UUID --print-cdp-url)

cdp-connect mlx-list
cdp-connect mlx-stop --profile-id PROFILE_UUID

API

from cdp_connect_kit import CdpClient, connect_playwright, parse_endpoint
import asyncio

async def main():
    client = CdpClient("127.0.0.1:9222")
    print(client.resolve_websocket_url())
    browser, pw, metrics = await connect_playwright("127.0.0.1:9222", max_retries=5)
    print(metrics.to_dict())
    await browser.close()
    await pw.stop()

asyncio.run(main())
Symbol Description
parse_endpoint(url) Normalize HTTP / WS / host:port
CdpClient /json/version, /json/list, health_snapshot()
connect_playwright(endpoint) Retry wrapper → (browser, playwright, ConnectMetrics)
watch_endpoint(endpoint) Async health polling

ConnectMetrics

{
  "endpoint": "http://127.0.0.1:9222",
  "web_socket_url": "ws://127.0.0.1:9222/devtools/browser/...",
  "attempts": 1,
  "connect_ms": 842.1,
  "ready_ms": 120.5,
  "target_count": 3
}

When connect_over_cdp keeps failing (playbook)

Most failures are endpoint shape or browser not ready — not Playwright bugs.

Error pattern Likely cause Fix
Connection refused Port not open yet cdp-connect ping in a loop; MLX: mlx-start --wait-timeout
Invalid URL / WS mismatch Passed raw ws://… without version fetch Use HTTP base http://127.0.0.1:PORT; let client resolve WS
Works once, flaky in farm Race on profile start watch --endpoint URL → JSONL for farm-runner; retry connect_playwright
Chrome 136+ local profile Default user-data-dir blocks CDP Custom profile dir or antidetect Launcher port
MLX 401 / timeout Agent not running or wrong token MLX_TOKEN, desktop agent up; see docs/ENV.md

MLX → Playwright pipeline:

export MLX_TOKEN=... MLX_FOLDER_ID=...
CDP_URL=$(cdp-connect mlx-start --profile-id PROFILE_UUID --print-cdp-url)
cdp-connect ping "$CDP_URL"
cdp-connect playwright --endpoint "$CDP_URL" --max-retries 5
# farm scripts: export CDP_URL for child processes
cdp-probe run --cdp-endpoint "$CDP_URL" --url https://example.com
cdp-connect mlx-stop --profile-id PROFILE_UUID

Coupon hub: Multilogin promo codes — guides for SAAS50 / MIN50, pricing comparisons, and workflow playbooks. Farm-scale partner note: Folder pools need stable Launcher CDP — Multilogin X is the [mlx] target stack. Code SAAS50 (browser) · coupons: cdp-connect --show-deal.

Canonical API details: docs/MLX_INTEGRATION.md.

Limitations

  • Chromium CDP only — connect_over_cdp targets Chromium-based browsers.
  • MLX requires local agent — Launcher API needs Multilogin desktop running.
  • Watch mode uses HTTP discovery only; JSONL output is designed for automation-farm-runner ingestion.
  • Not a fingerprint tool — connects to browsers; does not modify profiles.

Production

Use cdp-connect mlx-start → connect_playwright in farm scripts and probes; pair with farm-runner (automation-farm-runner) for folder pools. Export CDP_URL for human-input-kit warmup and playwright-cdp-probe checks on the same Launcher session.

Partner note (affiliate): When Playwright must attach to Multilogin X Launcher CDP ports (not vanilla --remote-debugging-port), isolated profiles are the intended production path. Eligible new browser purchases may accept code SAAS50 at multilogin.com — verify terms before checkout. ping / playwright / watch work on any CDP server without MLX. Full disclosure: docs/AFFILIATE.md. Deals hub: anti-detect.github.io. Coupon details only via cdp-connect --show-deal (never printed by default).

FAQ: docs/FAQ.md — Playwright connect_over_cdp, Multilogin Launcher, CDP health check.

Related tools (on PyPI)

Package CLI Role
playwright-cdp-probe cdp-probe CDP / WebDriver exposure score
cookie-jar-bridge cookie-bridge Netscape ↔ Playwright cookies
proxy-lane-checker proxy-lane Proxy TCP / HTTP / geo / DNSBL
fingerprint-coherence fp-coherence UA / screen / timezone lint

Toolkit pipeline: proxy-lane check → fp-coherence audit → automate → cdp-probe run → cookie-bridge validate

License

MIT


Production antidetect (partner): Multilogin X · Code SAAS50 (-50% browser) · MIN50 (-50% cloud phone)
Affiliate disclosure — we may earn a commission; offers change on the vendor site. More scripts: @Multilogin_Scripts_Bot · Multilogin promo codes

Metadata

Release files for cdp-connect-kit 0.3.6

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for cdp-connect-kit 0.3.6
File Size Uploaded Provenance Actions
cdp_connect_kit-0.3.6.tar.gz 26.2 kB Without provenance Details for cdp_connect_kit-0.3.6.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for cdp-connect-kit 0.3.6
File Interpreter ABI Platform Actions
cdp_connect_kit-0.3.6-py3-none-any.whl Python 3 none any Details for cdp_connect_kit-0.3.6-py3-none-any.whl

Total release size: 46.5 kB

Release files / cdp_connect_kit-0.3.6.tar.gz

Download URL cdp_connect_kit-0.3.6.tar.gz
Size 26.2 kB
Tags Source
SHA-256 checksum
How to use checksums
4fcafe0a681720f16ef3740f6a5260b53b4f813defe7eed51d5d9934b71072c2
BLAKE2b-256 checksum
How to use checksums
96b89e8dd3d47225e316f39ac0d67e910d16a1c4853726f0ce5eb309568c3c28
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.5

Release files / cdp_connect_kit-0.3.6-py3-none-any.whl

Download URL cdp_connect_kit-0.3.6-py3-none-any.whl
Size 20.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9a433b58685bdddda51d19934bebc45a41402dfb6cd8e7e01bed04b8d94938c6
BLAKE2b-256 checksum
How to use checksums
24e7a4750e9e8a6eecf19fcc08571bfb5df5c7f218616a6929f4efcf1cc5078b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.5

Security for cdp-connect-kit 0.3.6

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page