Claude Agent SDK
A toolkit for building custom agents on the same harness that powers Claude Code.
The Claude Agent SDK is a toolkit for building custom AI agents on the same harness that powers Claude Code. Official Python and TypeScript SDKs expose the core agent loop — reading files, running commands, calling tools, iterating on feedback — as a programmable library, with MCP support, configurable permissions, streaming, and multi-turn sessions.
The Claude Agent SDK is a toolkit for building custom AI agents on the same agent harness that powers Claude Code. It exposes the core agent loop — reading files, running shell commands, calling tools, and iterating against feedback — as a programmable library, so you can embed that behavior in your own applications instead of driving it through the terminal.
It is aimed at developers building agentic products: coding assistants, automation pipelines, internal developer tools, or any workflow where an agent needs to operate over a filesystem and a set of tools with minimal scaffolding.
Highlights
- Official Python and TypeScript SDKs that wrap the Claude Code agent loop
- Built-in file operations, command execution, and tool calling
- Extensible with custom tools and Model Context Protocol (MCP) servers
- Configurable permissions and system prompts to scope what an agent can do
- Supports streaming responses and multi-turn sessions
How it fits an AI-assisted workflow
Install the SDK and run a single-shot query:
import { query } from "@anthropic-ai/claude-agent-sdk";
for await (const message of query({
prompt: "Summarize the open TODOs in this repository",
})) {
console.log(message);
}Use it when you want the agent's autonomy under your own control flow — wiring it into CI, a web backend, or a custom CLI — rather than interacting through Claude Code directly. You define the tools and permissions, and the SDK handles the loop.
Good to know
NOTE
The SDK is free to use, but it calls the Anthropic API and requires an API key, so usage is billed per token. Because agents can run commands and edit files, scope permissions carefully and run in sandboxed or version-controlled environments.
Frequently asked questions
- What is the Claude Agent SDK?
- It's a toolkit for building custom AI agents on the same agent harness that powers Claude Code. The SDK exposes the core agent loop — reading files, running shell commands, calling tools, and iterating against feedback — as a programmable Python or TypeScript library you can embed in your own applications instead of driving it through the terminal.
- Is the Claude Agent SDK free?
- The SDK is free to use, but it calls the Anthropic API and requires an API key, so usage is billed per token. Because agents can run commands and edit files, scope permissions carefully and run in sandboxed or version-controlled environments.
- How do I use the Claude Agent SDK?
- Install the official Python or TypeScript SDK and run queries — for example, iterating over query({ prompt: 'Summarize the open TODOs in this repository' }) from @anthropic-ai/claude-agent-sdk streams back messages. You define the tools and permissions, and the SDK handles the loop, so you can wire it into CI, a web backend, or a custom CLI.
Related
- Building an MCP ServerAn accurate introduction to the Model Context Protocol: server anatomy, transports, and connecting a tool to Claude Code.
- Building Agents with the Claude Agent SDKA working tutorial for the Claude Agent SDK in TypeScript and Python — query(), tool permissions, custom in-process MCP tools, subagents, hooks, and auth.
- Which Agent Framework in 2026? LangGraph vs CrewAI vs AutoGen vs OpenAI Agents SDK vs Claude Agent SDKA decision guide to the major AI agent frameworks — control vs. abstraction, multi-agent models, state and durability, and which fits your project.