Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/opensandbox-group/OpenSandbox/llms.txt

Use this file to discover all available pages before exploring further.

OpenSandbox supports two approaches to browser automation in isolated containers. The Chrome example launches a full Chromium instance with VNC access and the Chrome DevTools Protocol (CDP) exposed on port 9222, making it possible to connect any DevTools client or MCP tool directly to the browser. The Playwright example uses a prebuilt image with Chromium binaries and the Playwright Python library pre-installed, suitable for headless scraping, screenshot capture, and automated testing workflows.
The opensandbox/chrome image starts a VNC server (Xtigervnc :1) and launches Chromium with remote debugging enabled. Once the sandbox is running, you can connect a native VNC client to port 5901 or attach any CDP-compatible tool to port 9222.

Get the image

cd examples/chrome
docker build -t opensandbox/chrome .

Start the OpenSandbox server

uv pip install opensandbox-server
opensandbox-server init-config ~/.sandbox.toml --example docker
opensandbox-server

Create and access the Chrome sandbox

uv pip install opensandbox
uv run python examples/chrome/main.py
import asyncio
from datetime import timedelta

from opensandbox.sandbox import Sandbox
from opensandbox.config import ConnectionConfig
from opensandbox.exceptions import SandboxException


async def main():
    try:
        sandbox = await Sandbox.create(
            image="opensandbox/chrome:latest",
            timeout=timedelta(minutes=5),
            entrypoint=["/entrypoint"],
            metadata={"examples.opensandbox.io": "chrome"},
            connection_config=ConnectionConfig(domain="localhost:8080"),
        )

        # Get the execd process endpoint
        execd = await sandbox.get_endpoint(44772)
        print(f"execd daemon running with {execd.endpoint}")

        vnc = await sandbox.get_endpoint(5901)
        print(f"VNC running with {vnc.endpoint}")

        devtools = await sandbox.get_endpoint(9222)
        print(f"DevTools running with {devtools.endpoint}/json")

    except SandboxException as e:
        print(f"Sandbox Error: [{e.error.code}] {e.error.message}")
    except Exception as e:
        print(f"Error: {e}")


if __name__ == "__main__":
    asyncio.run(main())

Expected output

execd daemon running with endpoint='127.0.0.1:48379/proxy/44772'
VNC running with endpoint='127.0.0.1:48379/proxy/5901'
DevTools running with endpoint='127.0.0.1:48379/proxy/9222'/json
Fetch the DevTools JSON endpoint to list open pages:
[
  {
    "description": "",
    "devtoolsFrontendUrl": "https://chrome-devtools-frontend.appspot.com/...",
    "id": "2215AF60AC345E4BA6D822389CFC743B",
    "title": "Google",
    "type": "page",
    "url": "https://www.google.com.hk/",
    "webSocketDebuggerUrl": "ws://127.0.0.1:52302/devtools/page/2215AF60AC345E4BA6D822389CFC743B"
  }
]
You can also connect the Chrome sandbox to an MCP client using chrome-devtools-mcp for agent-driven browser control.

References

Build docs developers (and LLMs) love