|
| 1 | +--- |
| 2 | +title: Claude Agent SDK |
| 3 | +sidebarTitle: Claude Agent SDK |
| 4 | +description: Build browser agents on Anthropic's first-party agent loop with in-process MCP tools. |
| 5 | +llm: true |
| 6 | +--- |
| 7 | + |
| 8 | +The Claude Agent SDK is the engine behind Claude Code, exposed as a Python and TypeScript library. You hand `query()` a prompt and an options object and iterate the typed messages it streams back. The Steel integration exposes a cloud browser as in-process MCP tools, so the SDK runs the agent loop and Steel handles the browser. |
| 9 | + |
| 10 | +Available in TypeScript and Python. |
| 11 | + |
| 12 | +### Requirements |
| 13 | + |
| 14 | +* **Steel API Key**: Active Steel subscription |
| 15 | +* **Anthropic API Key**: Access to a Claude 4 model |
| 16 | +* **Runtime**: Node.js 20+ or Python 3.10+ |
| 17 | +* **Packages**: `@anthropic-ai/claude-agent-sdk` or `claude-agent-sdk`, plus `steel-sdk` and `playwright` |
| 18 | + |
| 19 | +### Connect Steel to the Claude Agent SDK |
| 20 | + |
| 21 | +Wrap a Steel session in a `tool()` and bundle it into an in-process MCP server: |
| 22 | + |
| 23 | +```typescript Typescript -wc |
| 24 | +import { createSdkMcpServer, query, tool } from "@anthropic-ai/claude-agent-sdk"; |
| 25 | +import { chromium } from "playwright"; |
| 26 | +import Steel from "steel-sdk"; |
| 27 | + |
| 28 | +const steel = new Steel({ steelAPIKey: STEEL_API_KEY }); |
| 29 | + |
| 30 | +const openSession = tool( |
| 31 | + "open_session", |
| 32 | + "Open a Steel cloud browser session.", |
| 33 | + {}, |
| 34 | + async () => { |
| 35 | + const session = await steel.sessions.create({}); |
| 36 | + const browser = await chromium.connectOverCDP( |
| 37 | + `${session.websocketUrl}&apiKey=${STEEL_API_KEY}`, |
| 38 | + ); |
| 39 | + return { |
| 40 | + content: [ |
| 41 | + { type: "text", text: JSON.stringify({ sessionId: session.id }) }, |
| 42 | + ], |
| 43 | + }; |
| 44 | + }, |
| 45 | +); |
| 46 | + |
| 47 | +const steelServer = createSdkMcpServer({ |
| 48 | + name: "steel", |
| 49 | + version: "1.0.0", |
| 50 | + tools: [openSession], |
| 51 | +}); |
| 52 | +``` |
| 53 | + |
| 54 | +Pass the server into `query()` via `mcpServers` and pre-approve calls with `allowedTools: ["mcp__steel__*"]`. Drop the SDK's built-in tools with `tools: []` so the agent only sees Steel. |
| 55 | + |
| 56 | +Full runnable starter: [Steel + Claude Agent SDK recipe →](/cookbook/claude-agent-sdk) |
| 57 | + |
| 58 | +### Resources |
| 59 | + |
| 60 | +* [Claude Agent SDK documentation](https://platform.claude.com/docs/en/agent-sdk/overview) – Agent loop, custom MCP tools, hooks, subagents |
| 61 | +* [Steel Sessions API reference](/api-reference) – Programmatic session control for Steel browsers |
| 62 | +* [Steel Discord](https://discord.gg/steel-dev) – Get help and share what you build |
0 commit comments