Claude Agent SDK
Anthropic's Python and TypeScript libraries for building your own agents on the same loop, tools, permissions and MCP support that run Claude Code.
Install
-
Python
pip install claude-agent-sdkPython 3.10+. Bundles the Claude Code CLI. The SDK is free, but its model calls bill to your API key or Claude plan.
-
TypeScript
npm install @anthropic-ai/claude-agent-sdk
The agent loop behind Claude Code, as a library. You get file, shell and web tools, subagents, hooks, permission callbacks and in-process MCP servers. You supply the prompt, the tool policy and whatever custom tools your agent needs.
When to use it
- You want an agent in your own app, script or CI job rather than in a terminal session.
- You need custom tools, as plain Python or TypeScript functions exposed over MCP.
- You want control over every tool call through
can_use_toolor hooks.
Before you build
Decide the tool policy first. Use disallowed_tools to take away tools the agent shouldn’t
have, and allowed_tools only for tools that are safe to run without asking. Don’t use
permission_mode="bypassPermissions" outside a sandbox.
- Publisher
- Anthropic
- Works with
- Claude Code, Any agent
- Categories
- Agent building
- License
- MIT (Python); Anthropic Commercial Terms (TypeScript)
- Cost
- Paid