Skip to content

API Reference parrot.mcp.obscura

github-actions[bot] edited this page Dec 2, 2026 · 4 revisions

parrot.mcp.obscura

View source

Supervised process management for the Obscura headless browser.

Obscura (v0.2.2, Linux-only in this feature) exposes a CDP server that the existing PlaywrightDriver can connect to over chromium.connect_over_cdp() (see parrot_tools.scraping.drivers.playwright_driver), and a native MCP server (obscura mcp) that agents/Codex can use directly.

ObscuraProcessManager supervises the CDP-serving process only — it follows the readiness-probing and subprocess-supervision pattern of parrot.mcp.chrome.ChromeManager, but adds explicit ownership tracking: a process this manager did not start (either adopted via attach_only, or never successfully launched) is never terminated by stop().

See sdd/specs/obscura-new-browser-headless.spec.md (FEAT-530), Module 1.

Class ObscuraProcessConfig

Configuration for a supervised Obscura v0.2.2 Linux process.

Parameter Type Default Description
binary_path str
port int 9222
host str '127.0.0.1'
stealth bool False
allow_private_network bool False
attach_only bool False
startup_timeout float 10.0

Fields:

Field Type Default Description
binary_path str Path to (or PATH-resolvable name of) the pinned Obscura v0.2.2 binary.
port int 9222 CDP port Obscura should listen on.
host str '127.0.0.1' Host Obscura should bind its CDP endpoint to.
stealth bool False Enable Obscura's stealth mode.
allow_private_network bool False Enable --allow-private-network. Required for local fixture pages, but must not be enabled silently in general deployments (see spec Known Risks / Gotchas).
attach_only bool False When True, the manager never spawns a process — it only probes readiness of an externally managed Obscura instance and refuses to stop() a process it never started.
startup_timeout float 10.0 Max seconds to wait for the CDP endpoint to become responsive after spawning the process.

Class ObscuraProcessManager

Supervises a Linux Obscura v0.2.2 process's CDP server lifecycle.

All I/O-bearing operations (readiness probing, launching, and stopping the managed process) are coroutines, following ChromeManager (parrot.mcp.chrome.ChromeManager): the readiness probe uses aiohttp, and the process itself is supervised with asyncio.subprocess, so none of this class blocks the event loop.

Parameter Type Default Description
config ObscuraProcessConfig Validated Obscura process configuration.
logger Optional[logging.Logger] None Optional logger to use. Defaults to a module logger named "ObscuraProcessManager".

Attributes:

Attribute Type Description
process Optional[asyncio.subprocess.Process]
endpoint str The CDP endpoint URL this manager supervises.

Method ObscuraProcessManager.is_running

Check whether Obscura is running and responding on the CDP port.

Performs a GET request to the /json/version endpoint with a short total timeout so the caller never blocks the event loop for long.

is_running() -> bool

Returns: bool — True iff the endpoint responds with HTTP 200, False on any connection error, timeout, or OS-level failure.

Method ObscuraProcessManager.start

Start (or adopt) Obscura and wait for CDP readiness.

In the normal (non attach_only) mode, this manager starts and owns the process — stop() will later terminate it. If a CDP endpoint is already responding but this manager did not start it and attach_only is not set, start() refuses to silently adopt an unknown process (e.g. Chrome DevTools or another tool happening to listen on the same port) — ownership must be explicit. In attach_only mode, an already-responding endpoint is adopted without spawning anything, and stop() will never terminate it; if nothing is responding, attach_only mode raises instead of spawning a process it would not be allowed to stop.

start() -> str

Returns: str — The CDP endpoint URL once ready.

Raises:

  • RuntimeError — If the binary cannot be found (non attach_only mode), if a CDP endpoint is already responding but is neither owned by this manager nor explicitly adopted via attach_only, if attach_only mode finds nothing listening, if the spawned process exits before its CDP endpoint becomes ready (captured stderr included when available), or if the CDP endpoint does not become ready within config.startup_timeout seconds.

Method ObscuraProcessManager.stop

Stop the managed Obscura process — only if this manager owns it.

An adopted process (attach_only) or a process this manager never successfully started is left untouched. Sends terminate() and waits up to 5 seconds for the process to exit; if it does not exit in time, sends kill(). Always resets ownership state when done.

stop() -> None

Method ObscuraProcessManager.status

Report this manager's current view of the Obscura process.

status() -> dict[str, object]

Returns: dict[str, object] — dict[str, object]: A status snapshot with keys running (whether the CDP endpoint currently responds), owned (whether this manager started the process), host, port, endpoint, and pid (the owned process id, or None).

Function default_pid_file

Default PID-file path for a supervised Obscura process on port.

default_pid_file(port: int) -> Path

Parameter Type Default Description
port int The CDP port the process was started on.

Returns: Path — {tempdir}/obscura-{port}.pid.

Function read_pid_file

Read a previously written PID.

read_pid_file(path: Path) -> Optional[int]

Parameter Type Default Description
path Path PID-file path to read.

Returns: Optional[int] — Optional[int]: The recorded PID, or None if path does not exist or does not contain a valid integer.

Function remove_pid_file

Remove path if present.

remove_pid_file(path: Path) -> None

Parameter Type Default Description
path Path PID-file path to remove. A missing file is not an error.

Function write_pid_file

Persist pid to path for a later CLI stop/status invocation.

write_pid_file(path: Path, pid: int) -> None

Parameter Type Default Description
path Path PID-file path (typically default_pid_file(port)).
pid int Process id to record.

Architecture

Clients

Bots & Agents

Memory

Knowledge

Tools & Toolkits

Flows

Experts

Skills

Stores & Loaders

MCP & A2A

Server & APIs

Integrations

Outputs & A2UI

Prompts

Security

Operations

Migration

SDD Tooling

LLM Wiki

Deployment

Decisions

API Reference

Clone this wiki locally