Metadata-Version: 2.5
Name: stagehand-claude-sdk
Version: 0.1.0rc1
Summary: Stagehand driver for Anthropic's browser toolset: give Claude a browser through the Anthropic SDK.
Project-URL: Homepage, https://github.com/browserbase/claude-cua-toolset
Project-URL: Repository, https://github.com/browserbase/claude-cua-toolset
Author: Browserbase
License-Expression: MIT
License-File: LICENSE
Keywords: anthropic,browser,browser-toolset,browserbase,claude,computer-use,stagehand
Classifier: Framework :: AsyncIO
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Typing :: Typed
Requires-Python: >=3.11
Requires-Dist: anthropic>=1.9.0
Requires-Dist: browserbase<2,>=1.15
Requires-Dist: opentelemetry-api<2,>=1.35
Requires-Dist: pydantic<3,>=2.12
Requires-Dist: websockets>=16.1.1
Description-Content-Type: text/markdown

# stagehand-claude-sdk

Give Claude a browser through the Anthropic SDK. `StagehandBrowser` implements Anthropic's browser toolset
(`browser_toolset_20260801`) on top of Stagehand: all 31 members (navigation, screenshots, clicks and
keyboard, page reading, forms, tabs, uploads, console and network), against a local Chrome, a Chromium you
already run, or a Browserbase session. The Anthropic SDK runs the model's tool loop; this package runs the
browser.

Quickstarts for TypeScript and Python, with local Chrome and Browserbase variants:
[browserbase/claude-cua-toolset](https://github.com/browserbase/claude-cua-toolset).

## Install

```bash
pip install stagehand-claude-sdk
```

Python 3.11 or later. The distribution is `stagehand-claude-sdk`; the import is `stagehand_claude_sdk`. It
depends on an `anthropic` release that ships the browser toolset helpers. The Stagehand runtime this driver
needs is bundled in the package (Stagehand `4.2.0a2`), so there is nothing else to install.
Local browsers must be Chromium-based (Chrome, Chromium, Edge).

## Quick start

The driver is async, so it pairs with `AsyncAnthropic`.

```python
import asyncio

from anthropic import AsyncAnthropic
from stagehand_claude_sdk import StagehandBrowser


async def main() -> None:
    browser = await StagehandBrowser.launch(headless=True, allowed_domains=["example.com", "iana.org"])
    async with browser:  # closes the browser when the block exits; the tool runner never does
        runner = AsyncAnthropic().beta.messages.tool_runner(
            model="claude-sonnet-5-5",
            max_tokens=1024,
            tools=[browser],  # the toolset instance is the tools[] entry
            messages=[{"role": "user", "content": "Open example.com and tell me the page heading."}],
        )
        async for message in runner:
            print(message)


asyncio.run(main())
```

Other browsers:

```python
await StagehandBrowser.browserbase(api_key=os.environ["BROWSERBASE_API_KEY"], allowed_domains=[...])  # a Browserbase session
await StagehandBrowser.connect(cdp_url="ws://127.0.0.1:9222/devtools/browser/...", allowed_domains=[...])  # a running Chromium
```

Without the runner, `await browser.tool_result(tool_use)` answers one browser `tool_use` block.

## Options

The SDK's own toolset options pass through: `configs`, `confirm`, `url_policy`, `file_policy`,
`tool_configs`. `javascript_exec`, `file_upload`, `read_console` and `read_network` are off unless enabled in
`configs`, and `javascript_exec` / `file_upload` need a `confirm` callback.

| Option | What it does |
| --- | --- |
| `allowed_domains` / `blocked_domains` | Hosts, IP literals or CIDR ranges. A domain entry includes its subdomains and the block list wins. Enforced inside the browser on every HTTP(S) request (navigations, sub-resources, redirects, popups) and checked on `navigate` before anything is sent. |
| `upload_roots` / `download_dir` | Where `file_upload` may read from and downloads are written to (local browsers). |
| `headless`, `chrome_path` | Local launch settings. |

## Limitations

- Domain lists cover the browser's HTTP(S) requests and WebSocket handshakes, but they are not complete
  network isolation. Run untrusted tasks in an isolated browser and treat page content as untrusted.
- Local browsers must be Chromium-based. Firefox and WebKit are not supported.
- Downloads are not available in Browserbase sessions.
- If the browser connection is lost, close the toolset and create a new instance.

## Examples

See [browserbase/claude-cua-toolset](https://github.com/browserbase/claude-cua-toolset) for runnable examples.

## License

MIT. Includes Stagehand (MIT, Browserbase) under `stagehand_claude_sdk/_vendor/stagehand`.
