Claude Agent SDK: Build a Python Agent in 72 Lines
The tutorial builds a 72-line Python agent with the Claude Agent SDK, which brings Claude Code’s agent loop, tools, and permission system into a program. Two Python functions become read-only tools through an in-process MCP server.
The walkthrough examines default tool access, inherited settings, model selection, and the minimal system prompt. It adds an approval function and a pre-tool-use hook that blocks files with secret in the name, while showing how a denied request can still produce a misleading answer.
An experimental local-model run, unsupported by Anthropic, finds the requested note in under two minutes. The tutorial compares its input-token use with an earlier Claude Code run and distinguishes SDK cost estimates from actual billing.
Key points
- The Claude Agent SDK embeds an agent loop in Python and exposes two custom functions through an in-process MCP server.
- The walkthrough restricts built-in tools, disables inherited settings, selects a model, and supplies its own system prompt.
- An approval function pauses tool execution, but the local model incorrectly describes the notes folder as empty after access is denied.
- A pre-tool-use hook blocks files with secret in the name before the permission prompt appears.
- An unsupported local-model experiment finds the requested note in under two minutes with fewer input tokens than the earlier Claude Code run.
- The SDK’s displayed cost is an estimate, and the tutorial notes Anthropic’s API-key requirement for apps built for other people.
Chapters
The description and key points were written with AI from the video's transcript and checked against it, then reviewed by Vishal on . The video plays from YouTube. How we write and check our work.





