package
Sugar for Chrome's devtools protocol
npm install chrome-tabGitHub-flavored package documentation.
Across all versions.
Download trend unavailable.
Runtime metadata.
Sugar for Chrome's devtools protocol.
chrome-devtools-mcp crashed my machine. The issue appears to worsen with the number of tabs, and I have far too many of those. Raw CDP isn't smooth either as there is currently no straightforward way to get a page session for an active tab, also Chrome's JSON-RPC layer diverged from spec (sessionId outside params, demanding numeric message IDs, etc).
import Chrome from 'chrome-tab'
// Connect to Chrome's root debugging port (auto-discovers port or defaults to 9222)
const browser = new Chrome()
await browser.connect()
// List open active tabs (default)
const tabs = await browser.listTabs()
const targetId = tabs[0].targetId
// Attach to the tab to obtain its page sessionId
const sessionId = await browser.attachTab(targetId)
// Run JavaScript in that tab session
const { result } = await browser.call('Runtime.evaluate', {
expression: 'document.title',
{
"mcpServers": {
"chrome-tab": {
"command": "npx",
"args": ["-y", "chrome-tab"]
}
}
}--browser, -b or CHROME_BROWSER: Target a specific browser flavor (chrome, canary, chromium, edge, brave, arc, vivaldi, opera).--user-data-dir or CHROME_USER_DATA_DIR: Discover the active port from a specific user data directory (overrides --browser).--port, -p or CHROME_PORT: Connect directly to an explicit port (overrides --user-data-dir and --browser).--host, -h or CHROME_HOST: Host to connect to (default: 127.0.0.1).--path or CHROME_PATH: Custom WebSocket path.list_tabs({ query? }) - Lists active tabs (one per window); pass query to search all including background tabs.attach_tab({ targetId?, url? }) - Attaches to a tab by targetId, or pass url to open and attach. Sets it as default target.eval({ expression, wait?, sessionId? }) - Evaluates JavaScript in REPL mode and returns the trailing expression value.screenshot({ format?, quality?, sessionId? }) - Captures a screenshot of the tab.call({ method, params?, sessionId? }) - Universal CDP passthrough for raw commands.Because chrome-tab attaches to your live browser and grants raw CDP access, it automatically inherits all of your authenticated sessions, cookies and other local storage along with full code execution privileges. Treat agent browser access like you would shell access. Hallucinations, mistakes and prompt injection are real, you've been warned!
MIT
Estimated unpacked size across 3 packages.
56.2 kB
Includes dependencies.
^1.0.0
1.0.0