Browser and computer use with the SDK toolsets

Open original

This is a technical guide for implementing browser automation using Anthropic's Python and TypeScript SDKs. You subclass the provided toolset, implement methods for browser actions like navigation and clicking, and let Claude control the browser through your automation backend.

  • You must provide your own browser automation backend (like Playwright) and URL policy — the SDK doesn't include a browser or ready-made driver, only the framework to wire them together.
  • Each browser method you implement returns structured results that Claude reads as natural language (e.g., "Navigated to {url} — {title}"), plus a state report of open tabs and changes since the last action.
  • The SDK enforces policies at call time: URL policies block navigation, file policies restrict file access, and you can add hooks to log, modify inputs, or refuse calls before they execute.

The Anthropic SDK gives you tools to build AI agents that control browsers or desktops through Python or TypeScript. You don't get a pre-built browser—you write a subclass that wraps your own automation library (like Playwright) and implements methods for actions like navigate, screenshot, and left_click. The SDK handles routing calls to Claude, running security policies you define, and asking for approval if you set that up. Four companies (Browser Use, Browserbase, Daytona, E2B) publish their own integrations if you'd rather not build it yourself. The quick start shows a concrete example: you subclass `BetaAbstractBrowserToolset20260801`, implement the methods your browser supports, and define a URL policy that blocks access to domains you don't want. The policy runs before Claude even sees the URL, so you control what sites the agent can visit. You also need to report browser state after each action—tabs, their titles, URLs, and any changes since the last call. The SDK uses this state to give Claude accurate context for its next decision. You can customize behavior with configs to enable or disable specific methods, and by overriding the `execute` method to add logging, modify inputs, or catch errors. The SDK won't close your toolset instance after a run ends, so you can reuse it across multiple agent conversations. What Claude sees as the result of each action depends on the method: screenshots return images, navigate returns a confirmation with the new URL and status code, clicks return a simple "Clicked" message, and text extraction returns the raw string.

Ask about this article