Agent-native, low-trace Chrome, Chromium, and Edge automation over the Chrome DevTools Protocol (CDP), with zero WebDriver, zero Runtime.enable, zero DOM.getDocument, a clean stealthcdp/raw subpath, a 6-tool Model Context Protocol server (stealthcdp-mcp), and a zero-token stealthcdp CLI.
If you like StealthCDP, please give it a ⭐ on GitHub: it helps others find the project and keeps it going.
- Quiet CDP. Never sends
Runtime.enable,Runtime.addBinding,Console.enable,Debugger.enable, orDOM.getDocumenton default paths. Resolves main and isolated execution worlds viaDOM.describeNode+DOM.resolveNode, scopesTarget.setAutoAttachwithout leaking page-observable inspector agents, and leaves Chrome's sandbox and site isolation on. - Frames and Shadow DOM. Same-process and out-of-process iframes (OOPIFs) route through dedicated CDP sessions. CSS (including the
>>>shadow-piercing combinator), XPath, text, and native ARIA{ role, name }queries pierce open and closed Shadow DOM. - Trusted, realistic input. Actions verify visibility, stability, and hit-testing without replaying already-dispatched input. Optional seeded
humanmode drives Mulberry32 reproducible Fitts/minimum-jerk trajectories, micro-tremor, HTML5 & pointer drags, and grapheme-segmented keyboard typing. - Agent-native 6-tool MCP & zero-token CLI.
stealthcdpexposes 6 orthogonal MCP tools (browser_navigate,browser_observe,browser_act,browser_evaluate,browser_devtools,browser_handoff), automatically negotiates both MCP2026-07-28and2025-11-25/2025-06-18onstdio,/mcp, andsocket, and provides 25 shell subcommands (stealthcdp open|snap|fill|batch|...) plusdaemonlifecycle controls for zero-schema-token CLI workflows.
flowchart TD
app["Your code"] --> api["stealthcdp<br/>Browser · Context · Tab · Element · Locator"]
agent["AI agent"] -->|"6-tool MCP or CLI"| mcp["stealthcdp / stealthcdp-mcp"]
mcp --> api
rawApp["Protocol code"] --> raw["stealthcdp/raw<br/>TargetSession · IsolatedWorld · InputScope"]
api --> input["Input layer<br/>queue · checks · cleanup"]
api --> conn["CDP connection<br/>sessions · deadlines · drain"]
input --> conn
raw --> conn
conn -->|"Pipe or WebSocket"| chrome["Chrome · Chromium · Edge"]
chrome --- pages["Pages, OOPIFs, Dedicated/Shared/Service Workers"]
- Node.js
>=24.22.0. - Chrome, Chromium, or Microsoft Edge on Windows, macOS, or Linux (auto-detected or configured via
CHROME_PATH/executablePath). - A display for headed mode,
headless: true(--headless) on headless servers, orXvfbSession(--virtual-display) on Linux.
npm install stealthcdpimport { Browser } from 'stealthcdp';
await using browser = await Browser.launch({ headless: true });
const tab = await browser.newTab('https://example.com');
console.log(await (await tab.waitForSelector('h1')).text());
await tab.screenshot({ path: 'page.png', fullPage: true });Key capabilities across package subpaths:
stealthcdp: High-levelBrowser,BrowserContext,Tab,TabScope,Frame,Element(click,fill,type,select,setChecked,dragTo,readControlValue),Locator,Network,Route,Download, and AES-256-GCM state encryption (encryptState/decryptState). See Core API Guide.stealthcdp/raw: Unmanagedattach: 'none'sessions,TargetSession,IsolatedWorldPool,withClosedShadowRoots,parseDOMSnapshot,hitTestPoint,inspectScrollContext,getNodeEventListeners,InputScope,Composition, andcreateCommandGuard. See Raw CDP Sessions.stealthcdp/testing: OfflineScriptedChromeharness for deterministic unit tests without launching Chrome. See Core API Guide.
Configure stealthcdp for any MCP client (2026-07-28, 2025-11-25, or 2025-06-18 are negotiated automatically):
{
"mcpServers": {
"browser": {
"command": "npx",
"args": ["-y", "--package=stealthcdp", "stealthcdp-mcp"]
}
}
}Or run as a multi-lease authenticated HTTP server or zero-token local CLI daemon:
# Authenticated Streamable HTTP service (serves both modern and legacy MCP clients on /mcp)
export STEALTHCDP_MCP_TOKEN="$(openssl rand -hex 32)"
stealthcdp --http --port 3100 --input-mode human --remote-handoff
# Zero-token local CLI workflow backed by an authenticated local socket daemon
stealthcdp daemon start --input-mode human
stealthcdp open https://example.com --snap
stealthcdp batch '[{"action":"fill","ref":"e3","text":"hello"},{"action":"click","ref":"e5"}]' --snap
stealthcdp daemon stopThe 6 orthogonal MCP tools (BROWSER_MCP_TOOLS):
browser_navigate:open,goto,back,forward,reload,tabs,close_tab,close_browser(with optionalsnapshot: true).browser_observe:snapshot(interactive,diff,viewport,full),find(CSS/>>>/XPath/text/ARIArole),wait(selector/ref/closed-shadow text/URL/loadState),screenshot(includingmarks: 'interactive' | 'all').browser_act: Single action (click,click_at,hover,drag,fill,type,press_key,select,check,scroll,upload,dialog) or sequential fail-faststeps: [...]batch (stops on error/navigation/dialog without rollback) with post-write control value readback.browser_evaluate: Runs async JS inworld: 'isolated'by default (passworld: 'main'explicitly for page globals), with optionalrefbound asel.browser_devtools:network,console,input_policy,environment,downloads, andstorage_state.browser_handoff:request,wait,cancel(elicitvisible window orremoteviewer link; registered only when handoff is enabled).
See MCP & CLI Guide.
- Default launches use
transport: 'pipe'(no open TCP debugging port), disableAutomationControlled, and keepRuntime,Console,Debugger, and whole-documentDOMdomains off. Tab.setEnvironment()preserves native HiDPIdevicePixelRatiowhendeviceScaleFactoris omitted (0) and—together withmaskHeadless: true—synchronizes UA, UA-CH, locale, and timezone across pages, OOPIFs, Dedicated Workers, Shared Workers, and Service Workers before script execution.- See Environment & Protocol Hygiene and Trusted Input & Pacing.
npm ci
npm run check # tsc (src + test), browser-runtime AST check, and bilingual docs check
npm test # offline unit tests powered by ScriptedChrome
npm run test:integration # real Chrome integration suite (run in CI or non-locked workstations)
npm run test:dist # package build + smoke & HTTP/raw-session verification
npm run format:checkAll guides are maintained in English and Simplified Chinese with automated parity checks:
| Guide | Topics |
|---|---|
| Core API (中文) | Browser, BrowserContext, Tab, TabScope, Frame, >>> & ARIA queries, Element, Locator, Network, ScriptedChrome |
| Trusted Input (中文) | InputPolicy, Mulberry32 human trajectories, Mouse, Keyboard, IME Composition, PresentationLease |
| Environment & Workers (中文) | Protocol hygiene, HiDPI viewport, Dedicated/Shared/Service Worker alignment, ProxyForwarder, XvfbSession, diagnostics |
| Raw CDP Sessions (中文) | stealthcdp/raw, attach: 'none', TargetSession, IsolatedWorldPool, closed Shadow DOM, DOMSnapshot, hitTestPoint |
| MCP & CLI (中文) | 6-tool MCP surface, automatic dual-era /mcp & stdio & socket, zero-token CLI subcommands, security guards |
| Benchmarks & Audits (中文) | bench:mcp, bench:audit, bench:worker-environment, bench:ax-subtree, test:soak |
Release history is recorded in CHANGELOG.md.
Apache-2.0. See LICENSE.