Skip to content

Connect your browser code

If you already have automation code, you don’t need to rewrite it: it connects to a Geksy profile over the Chrome DevTools Protocol (CDP), just like to a regular Chromium. The Geksy app launches the browser, with the fingerprint, proxy and sync, and your code only connects to it.

There are two addresses:

AddressWhat it isFor
Permanent http://127.0.0.1:47800/cdp/{ws}/{id}doesn’t change between launches; access with an at_… token; the app starts the profile itself when you connectPlaywright, Puppeteer, Patchright, browser MCP servers, browser-use, Stagehand: the main path
Direct cdp_http from the start responsea random port that changes on every launch, no tokenSelenium (ChromeDriver can’t send a token), see Playwright, Puppeteer, Selenium

47800 is the default local API port; the actual one is in agent.json.

Connect every tool except Selenium to the permanent address: the app sits between your code and the browser and hides signs of a connected automation client from the page. The direct port doesn’t have this protection. The direct address (cdp_http, cdp_ws) is returned in the start response to the app’s main token and to a scoped token with the automation.cdp scope, if the member may export profiles; for everyone else it’s null. Some profiles have no direct debugging address (null for everyone) — connect through the permanent address with a token.

The app’s local API issues the token (with the main token or a restricted token that has the automation.cdp scope):

POST http://127.0.0.1:47800/api/v1/cdp-tokens
Authorization: Bearer <token from agent.json>
Content-Type: application/json
{"workspace_id": "1b7e…", "profile_id": "8f0c…", "ttl_minutes": 10, "headless": false, "idle_timeout_minutes": 5}
{
"token": "at_…",
"expires_at": 1760000000,
"http_endpoint": "http://127.0.0.1:47800/cdp/1b7e…/8f0c…",
"ws_endpoint": "ws://127.0.0.1:47800/cdp/1b7e…/8f0c…/devtools/browser",
"headers": {"Authorization": "Bearer at_…"}
}

In Python it’s one line: t = Agent().cdp_token(WS, PROFILE) (Python SDK).

  • Permissions. Your role needs “export profiles” (profile.export) and “connect Playwright/Puppeteer” (automation.cdp). Every token issued is recorded in the workspace log.
  • Lifetime. ttl_minutes (1–60, 10 by default) is the time you have to connect; an open connection keeps working after that. A new token is the same request; earlier tokens live out their time. After the app restarts, issue the token again.
  • Send the token in the header Authorization: Bearer at_…. If a tool can’t send headers, add ?token=at_… to the address.
  • Start and close. If the profile isn’t running, the app starts it when you connect (in the token’s headless mode) and closes it after idle_timeout_minutes (0–1440, 5 by default; 0 means never) without requests. A profile opened by hand or through start is never closed by the app. A second connection goes to the same browser.
  • Errors come in the usual {"error": {"code", "params"}} format: 401 unauthorized (no token or it expired), 403 agent_permission_denied (no permission); launch codes are in Error codes.

In all examples below, WS and PROFILE are the workspace and profile IDs, and T is the cdp-tokens response.

Every recipe was tested on the Geksy engine through the permanent address (2026-10-10: app 2.1.3, engine 154 on Linux). Since app 2.2.1, fingerprint check sites with Playwright connected through the permanent address show the same result as without a connection.

ToolTested versionConnectionWhat was tested
Playwright (Python)1.63.0connect_over_cdp + headers or ?token=navigation, click, title, request interception, iframe, tracing, screenshot
Playwright (Node.js)1.63.0connectOverCDP + headersnavigation, click, request interception, iframe
Patchright (Python)1.63.0connect_over_cdp + headersnavigation, click, interception, iframe, exposeBinding
Puppeteer25.13.0browserWSEndpoint + headersnavigation, click, interception, iframe, exposeFunction, screenshot
Selenium + ChromeDriver4.51, ChromeDriver with the engine’s major versiondirect port, debuggerAddressnavigation, click, iframe
Playwright MCP0.0.83--cdp-endpoint + --cdp-headernavigation, snapshot, click by ref
Chrome DevTools MCP1.10.1--wsEndpoint + --wsHeadersnavigation, snapshot, running a script
browser-use0.13.11BrowserProfile(cdp_url, headers)connection, navigation, page state for the agent
Stagehand3.7.3cdpUrl with ?token=init, navigation, title
Stagehand4.x—doesn’t work: it connects to the browser through its own extension
scrapy-playwright0.0.48 (Scrapy 2.19.0)browser provider, connect_over_cdp + headersrequest through the browser, profile context (cookies), the profile stays open
Crawlee (Python)1.11.0custom PlaywrightBrowserPlugincrawl, data, profile context, the profile stays open
Crawlee (Node.js)3.18.2custom launchercrawl, data, profile context, the profile stays open
Playwright CLI0.1.22attach --cdp + cdpHeaders in the configattach, goto, snapshot, eval, detach
n8n + the n8n-nodes-playwright-cdp noden8n 2.43.6, node 1.0.2HTTP Request → cdp-tokens, address with ?token=Playwright code in a workflow, profile context
Celery + RedisCelery 5.6.3, redis-py 6.4.0pool + Agent.connect (Python SDK)3 tasks on 1 profile in the pool: retry on an empty pool, profile context, every profile returned
BullMQ + RedisBullMQ 6.3.15, ioredis 6.0.0pool + cdp-tokens from Node.jsthe same
Temporal (Python SDK)temporalio 1.34.0, Temporal CLI 1.9.1 (server 1.32.0)pool + Agent.connect in an activitythe same, retries via RetryPolicy

scrapy-playwright, Crawlee, Playwright CLI and n8n were tested on 2026-10-15 (app 2.2.1, engine 155 on Linux), task queues on 2026-10-16 (engine 155 on Linux).

AI tools were tested without model keys: connection and basic steps. In every tool, page console events don’t arrive, and Playwright exposeBinding/exposeFunction don’t work; workarounds are in What works differently.

import json, os, requests
from playwright.sync_api import sync_playwright
cfg = json.load(open(os.path.expandvars(r"%LOCALAPPDATA%\Geksy\agent.json"))) # Linux: ~/.local/share/Geksy/agent.json
API = f"http://127.0.0.1:{cfg['port']}/api/v1"
WS, PROFILE = "1b7e…", "8f0c…"
T = requests.post(f"{API}/cdp-tokens", json={"workspace_id": WS, "profile_id": PROFILE},
headers={"Authorization": f"Bearer {cfg['token']}"}).json()
with sync_playwright() as pw:
browser = pw.chromium.connect_over_cdp(T["http_endpoint"], headers=T["headers"])
ctx = browser.contexts[0] # the profile's context, not new_context()
page = ctx.pages[0] if ctx.pages else ctx.new_page()
page.goto("https://example.com")
print(page.title())
browser.close() # disconnect; the profile keeps running

With the SDK: T = Agent().cdp_token(WS, PROFILE) instead of the request. Without headers: connect_over_cdp(f'{T["http_endpoint"]}?token={T["token"]}').

import { readFileSync } from "node:fs";
import { chromium } from "playwright";
const cfg = JSON.parse(readFileSync(`${process.env.LOCALAPPDATA}\\Geksy\\agent.json`, "utf8"));
const API = `http://127.0.0.1:${cfg.port}/api/v1`;
const WS = "1b7e…", PROFILE = "8f0c…";
const T = await (await fetch(`${API}/cdp-tokens`, {
method: "POST",
headers: { Authorization: `Bearer ${cfg.token}`, "Content-Type": "application/json" },
body: JSON.stringify({ workspace_id: WS, profile_id: PROFILE }),
})).json();
const browser = await chromium.connectOverCDP(T.http_endpoint, { headers: T.headers });
const ctx = browser.contexts()[0];
const page = ctx.pages()[0] ?? (await ctx.newPage());
await page.goto("https://example.com");
console.log(await page.title());
await browser.close(); // disconnect; the profile keeps running

Tests get a page in the profile’s context instead of a new empty one. The fixture uses the same connectOverCDP tested above (Playwright 1.63.0). Pass the address and token in environment variables (GEKSY_CDP_URL = http_endpoint, GEKSY_CDP_TOKEN = token; with ttl_minutes up to 60 the token is enough to start a test run).

geksy.fixture.ts
import { test as base, chromium, type Browser } from "@playwright/test";
export const test = base.extend<{}, { geksy: Browser }>({
geksy: [async ({}, use) => {
const browser = await chromium.connectOverCDP(process.env.GEKSY_CDP_URL!, {
headers: { Authorization: `Bearer ${process.env.GEKSY_CDP_TOKEN}` },
});
await use(browser);
await browser.close(); // disconnect only
}, { scope: "worker" }],
context: async ({ geksy }, use) => { await use(geksy.contexts()[0]); },
page: async ({ context }, use) => {
const page = await context.newPage();
await use(page);
await page.close();
},
});
export { expect } from "@playwright/test";

One profile is one browser: run with workers: 1 or give each worker its own profile. use options such as viewport, userAgent, locale, timezoneId don’t apply to the profile’s context, and they shouldn’t.

The API is the same as Playwright’s; only the import changes:

from patchright.sync_api import sync_playwright
with sync_playwright() as pw:
browser = pw.chromium.connect_over_cdp(T["http_endpoint"], headers=T["headers"])
page = browser.contexts[0].pages[0]
page.goto("https://example.com")
import puppeteer from "puppeteer-core";
const browser = await puppeteer.connect({
browserWSEndpoint: T.ws_endpoint, // not browserURL: Puppeteer drops the address path
headers: T.headers,
defaultViewport: null, // the real window size, as in the fingerprint
});
const [page] = await browser.pages();
await page.goto("https://example.com");
console.log(await page.title());
await browser.disconnect();

Install puppeteer-core: the browser is already there. Without headers: browserWSEndpoint: `${T.ws_endpoint}?token=${T.token}`.

ChromeDriver doesn’t send the token, so Selenium connects to the direct address: start the profile with start and take cdp_http without http://; the example is on Playwright, Puppeteer, Selenium. The ChromeDriver major version must match the engine (engine_version in GET /api/v1/status). When you’re done, disconnect with driver.service.stop(): driver.quit() closes the browser windows.

This browser MCP server for AI clients connects to a profile like this:

Окно терминала
npx @playwright/[email protected] --cdp-endpoint "http://127.0.0.1:47800/cdp/WS/PROFILE" --cdp-header "Authorization: Bearer at_…"

In the MCP client configuration:

{
"mcpServers": {
"browser": {
"command": "npx",
"args": ["@playwright/[email protected]", "--cdp-endpoint", "http://127.0.0.1:47800/cdp/WS/PROFILE",
"--cdp-header", "Authorization: Bearer at_…"]
}
}
}

The server connects to the browser on the first tool call, so issue the token with ttl_minutes: 60 and refresh it in the configuration. Don’t pass flags that change the device, User-Agent or window size (--device, --user-agent, --viewport-size). browser_console_messages returns an empty list.

Geksy also has its own MCP server for AI clients with page actions without CDP, see AI via MCP.

Окно терминала
npx [email protected] --wsEndpoint "ws://127.0.0.1:47800/cdp/WS/PROFILE/devtools/browser" --wsHeaders '{"Authorization":"Bearer at_…"}'

Page tools need a pageId from list_pages. list_console_messages returns an empty list.

from browser_use import BrowserProfile, BrowserSession
session = BrowserSession(browser_profile=BrowserProfile(
cdp_url=T["http_endpoint"], headers=T["headers"], keep_alive=True))
await session.start()
await session.navigate_to("https://example.com")
# then your browser-use agent with browser_session=session
  • The tab title in browser-use state may stay equal to the page address: that’s browser-use’s tab cache.
  • After the work, browser-use background tasks may keep the process alive; exit it explicitly.
  • To read the page, browser-use runs its own scripts on it: that’s the tool’s behavior, not the profile’s.
Окно терминала
npm install @browserbasehq/stagehand@3
import { Stagehand } from "@browserbasehq/stagehand";
const sh = new Stagehand({
env: "LOCAL",
localBrowserLaunchOptions: { cdpUrl: `${T.ws_endpoint}?token=${T.token}` },
});
await sh.init();
const page = sh.context.pages()[0] ?? (await sh.context.newPage());
await page.goto("https://example.com");

Stagehand 4 connects to the browser through its own extension and doesn’t work with a Geksy profile; stay on 3.x.

Connecting through PLAYWRIGHT_CDP_URL works, but scrapy-playwright opens a new empty context there (without the profile’s cookies) with a 1280×720 window, which doesn’t match the profile’s fingerprint. To make the spider work in the profile itself, set a custom browser provider. The address and token go in the GEKSY_CDP_URL (T["http_endpoint"]) and GEKSY_CDP_TOKEN (T["token"]) variables.

# geksy_provider.py, next to settings.py
import os
from playwright.async_api import async_playwright
class GeksyProvider:
"""scrapy-playwright in the Geksy profile's context (cookies, storage), not a new empty one."""
def __init__(self, config):
self.config = config
async def start(self):
self.pw = await async_playwright().start()
async def launch_browser(self):
self.browser = await self.pw.chromium.connect_over_cdp(
os.environ["GEKSY_CDP_URL"], headers={"Authorization": f"Bearer {os.environ['GEKSY_CDP_TOKEN']}"})
return self.browser
async def launch_persistent_context(self, context_kwargs):
if not getattr(self, "browser", None):
await self.launch_browser()
ctx = self.browser.contexts[0] # the profile's context
ctx.close = self.browser.close # at the end, only disconnect; don't close the profile
return ctx
async def close(self):
await self.pw.stop()
settings.py
DOWNLOAD_HANDLERS = {
"http": "scrapy_playwright.handler.ScrapyPlaywrightDownloadHandler",
"https": "scrapy_playwright.handler.ScrapyPlaywrightDownloadHandler",
}
TWISTED_REACTOR = "twisted.internet.asyncioreactor.AsyncioSelectorReactor"
PLAYWRIGHT_BROWSER_PROVIDER = "myproject.geksy_provider.GeksyProvider"
PLAYWRIGHT_CONTEXTS = {"default": {"user_data_dir": "geksy"}} # any value: this makes scrapy-playwright take the context from the provider
# in the spider
async def start(self):
yield scrapy.Request("https://example.com", meta={"playwright": True})

A custom browser plugin: Crawlee opens tabs in the profile’s context and only disconnects at the end.

from crawlee.browsers import BrowserPool, PlaywrightBrowserController, PlaywrightBrowserPlugin
from crawlee.crawlers import PlaywrightCrawler, PlaywrightCrawlingContext
class GeksyController(PlaywrightBrowserController):
async def close(self, *, force: bool = False) -> None:
await self._browser.close() # at the end, only disconnect; don't close the profile
class GeksyPlugin(PlaywrightBrowserPlugin):
async def new_browser(self):
browser = await self._playwright.chromium.connect_over_cdp(T["http_endpoint"], headers=T["headers"])
return GeksyController(browser, header_generator=None, max_open_pages_per_browser=5)
crawler = PlaywrightCrawler(browser_pool=BrowserPool(plugins=[GeksyPlugin()]))
@crawler.router.default_handler
async def handler(ctx: PlaywrightCrawlingContext) -> None:
await ctx.push_data({"url": ctx.request.url, "title": await ctx.page.title()})
await crawler.run(["https://example.com"])
import { PlaywrightCrawler } from "crawlee";
import { chromium } from "playwright";
const geksy = { // for Crawlee, "launching" the browser = connecting to the running profile
name: () => "chromium",
launch: () => chromium.connectOverCDP(T.http_endpoint, { headers: T.headers }),
async launchPersistentContext() {
const browser = await chromium.connectOverCDP(T.http_endpoint, { headers: T.headers });
const ctx = browser.contexts()[0]; // the profile's context
ctx.close = () => browser.close(); // at the end, only disconnect; don't close the profile
return ctx;
},
};
const crawler = new PlaywrightCrawler({
launchContext: { launcher: geksy, useIncognitoPages: false },
browserPoolOptions: { useFingerprints: false }, // the profile sets the fingerprint
async requestHandler({ page, request, pushData }) {
await pushData({ url: request.url, title: await page.title() });
},
});
await crawler.run(["https://example.com"]);

Install crawlee and playwright (Playwright browsers aren’t needed: PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1).

The token is sent as a header from the .playwright/cli.config.json config file in the working folder:

Окно терминала
npm install -g @playwright/[email protected]
{
"browser": {
"cdpEndpoint": "http://127.0.0.1:47800/cdp/WS/PROFILE",
"cdpHeaders": { "Authorization": "Bearer at_…" }
}
}
Окно терминала
playwright-cli attach --cdp=http://127.0.0.1:47800/cdp/WS/PROFILE
playwright-cli goto https://example.com
playwright-cli snapshot
playwright-cli detach

detach disconnects the CLI; the profile keeps running. Don’t use open --device, --mobile or other parameters that change the device.

n8n must run on the same computer as the Geksy app (or in the same Docker network as the runner).

  1. Install the n8n-nodes-playwright-cdp community node: Settings → Community Nodes → Install.
  2. HTTP Request node: POST http://127.0.0.1:47800/api/v1/cdp-tokens, header Authorization: Bearer <token from agent.json>, JSON body {"workspace_id": "…", "profile_id": "…"}.
  3. Playwright CDP node: CDP Endpoint URL {{ $json.http_endpoint }}?token={{ $json.token }}, code:
const page = await $context.newPage();
await page.goto("https://example.com");
const title = await page.title();
await page.close();
return { json: { title } };

The node works in the profile’s context and only disconnects after running, so the profile stays open. To close it, add another HTTP Request node that calls stop in the local API.

A queue worker doesn’t hold profiles: for each task it takes a free profile from the workspace pool, connects Playwright to it through the permanent address, does the work and returns the profile. The pool is the profiles with the given tags (or in a folder); while a profile is reserved, other workers and computers won’t get it.

  • POST /api/v1/pool/reserve {"workspace_id", "tags": [...] | "folder_id", "ttl_seconds": 300} → {"items": [{"profile_id", "reservation_id", "expires_at"}]}; the app renews the reservation while you hold it.
  • POST /api/v1/pool/release {"workspace_id", "profile_ids": [...], "stop": true} — close the profiles and return them to the pool.
  • No free profiles — 409 conflict with params.reason = "pool_empty": retry the task later with the queue’s own retries (below).

In Python the same is with Agent().pool.reserve(tags=[...]) as r: (Python SDK): leaving the with block closes the profile and returns it. The workspace is an argument or GEKSY_WORKSPACE. Workers run on the same computer as the Geksy app (or in the same Docker network as the runner); keep worker concurrency within the number of profiles in the pool and the plan’s concurrent launches limit.

# tasks.py — celery -A tasks worker --pool threads -c 2
from celery import Celery
from playwright.sync_api import sync_playwright
from geksy import Agent, GeksyError
app = Celery("geksy", broker="redis://127.0.0.1:6379/0", backend="redis://127.0.0.1:6379/1")
@app.task(bind=True, max_retries=60)
def scrape(self, url: str) -> dict:
agent = Agent() # port and token come from the app's agent.json
try:
with agent.pool.reserve(tags=["farm"], ttl_seconds=300) as r, sync_playwright() as pw:
ctx = agent.connect(r.workspace_id, r.profile_id).context(pw) # the profile's context
page = ctx.pages[0] if ctx.pages else ctx.new_page()
page.goto(url)
return {"profile_id": r.profile_id, "title": page.title()}
except GeksyError as e:
if e.code == "conflict": # the pool is empty — retry later
raise self.retry(countdown=5)
raise

Queue a task with scrape.delay("https://example.com").

// npm install bullmq ioredis playwright
import { Queue, Worker } from "bullmq";
import { chromium } from "playwright";
const WS = process.env.GEKSY_WORKSPACE, TOKEN = "<token from agent.json>";
const API = "http://127.0.0.1:47800/api/v1";
const call = async (path, body) => {
const r = await fetch(API + path, { method: "POST", body: JSON.stringify(body),
headers: { Authorization: `Bearer ${TOKEN}`, "Content-Type": "application/json" } });
const j = await r.json();
if (!r.ok) throw Object.assign(new Error(j.error?.code ?? r.status), { code: j.error?.code });
return j;
};
const connection = { host: "127.0.0.1", port: 6379 };
new Worker("geksy", async (job) => {
// the pool is empty → a conflict error → BullMQ retries the job (attempts/backoff)
const [r] = (await call("/pool/reserve", { workspace_id: WS, tags: ["farm"], ttl_seconds: 300 })).items;
try {
const t = await call("/cdp-tokens", { workspace_id: WS, profile_id: r.profile_id, ttl_minutes: 10 });
const browser = await chromium.connectOverCDP(t.http_endpoint, { headers: t.headers });
try {
const ctx = browser.contexts()[0]; // the profile's context
const page = ctx.pages()[0] ?? (await ctx.newPage());
await page.goto(job.data.url);
return { profile_id: r.profile_id, title: await page.title() };
} finally {
await browser.close(); // only disconnects
}
} finally {
await call("/pool/release", { workspace_id: WS, profile_ids: [r.profile_id], stop: true });
}
}, { connection, concurrency: 2 });
const queue = new Queue("geksy", { connection });
await queue.add("scrape", { url: "https://example.com" }, { attempts: 60, backoff: { type: "fixed", delay: 5000 } });
import asyncio
from concurrent.futures import ThreadPoolExecutor
from datetime import timedelta
from temporalio import activity, workflow
from temporalio.client import Client
from temporalio.common import RetryPolicy
from temporalio.worker import Worker
with workflow.unsafe.imports_passed_through():
from geksy import Agent
from playwright.sync_api import sync_playwright
@activity.defn
def scrape(url: str) -> dict:
agent = Agent()
# the pool is empty → GeksyError (conflict) → Temporal retries the activity per RetryPolicy
with agent.pool.reserve(tags=["farm"], ttl_seconds=300) as r, sync_playwright() as pw:
ctx = agent.connect(r.workspace_id, r.profile_id).context(pw)
page = ctx.pages[0] if ctx.pages else ctx.new_page()
page.goto(url)
return {"profile_id": r.profile_id, "title": page.title()}
@workflow.defn
class Scrape:
@workflow.run
async def run(self, url: str) -> dict:
return await workflow.execute_activity(
scrape, url, start_to_close_timeout=timedelta(minutes=5),
retry_policy=RetryPolicy(initial_interval=timedelta(seconds=5), backoff_coefficient=1.0,
maximum_attempts=60))
async def main(urls: list[str]) -> list[dict]:
client = await Client.connect("127.0.0.1:7233")
with ThreadPoolExecutor(max_workers=2) as ex:
async with Worker(client, task_queue="geksy", workflows=[Scrape], activities=[scrape],
activity_executor=ex):
return await asyncio.gather(*(client.execute_workflow(Scrape.run, u, id=f"scrape-{i}", task_queue="geksy")
for i, u in enumerate(urls)))

The activity is synchronous (Playwright sync API), so it needs an activity_executor. Keep the workflow and activity module in its own file: Temporal re-imports it in the workflow sandbox.

  • The profile’s context is contexts[0]. A new context (new_context(), browser.newContext()) is created empty: no cookies, storage or profile data. Opening new tabs in the profile’s context is fine.
  • Don’t override the User-Agent, window size, time zone, language or geolocation with the tool (Emulation.set…Override, viewport, userAgent, locale, timezoneId, --device). The profile’s fingerprint sets all of these, and manual overrides create mismatches; the app flags such a command with a warning on the profile.
  • Console and exposeBinding. Page console events don’t reach any tool; Playwright exposeBinding and exposeFunction don’t work (Puppeteer exposeFunction and Patchright exposeBinding do). Workarounds are in What works differently.
  • Downloads are saved on the computer where the browser runs; the script gets the event and the file name.
  • Disconnecting isn’t closing. browser.close() over CDP and disconnect() only disconnect your code. To close the profile and send its data to the cloud, call the local API stop.
  • Permanent address, not the direct port. Protection against detecting a connected client works only through the permanent address; the direct port is for Selenium.
  • Selenium: direct port only, ChromeDriver with the engine’s major version.
  • Stagehand: 3.x only.
  • scrapy-playwright with PLAYWRIGHT_CDP_URL: a new empty context with a 1280×720 window; to work in the profile, use a custom browser provider (see above).
  • The permanent address /cdp/{ws}/{id}, the POST /api/v1/cdp-tokens call and its response are part of local API v1: breaking changes only come with a new API version, and we announce them in advance in the changelog. New response fields may appear without a version change.
  • The geksy Python SDK follows semantic versioning: breaking changes only with a new major version.
  • With every engine update, the tested versions table is re-checked and updated on this page; new limitations also appear here and in the changelog.