Note: articles are for educational purposes and are not professional security advice — consult an expert for your specific needs.
AI Agents

Claude Agent SDK: Build a Python Agent in 72 Lines

Video · 5:20On YouTube TrickyWorld

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

  1. 0:00The 72-line agent experiment
  2. 0:28SDK setup and custom tools
  3. 1:30Defaults that need attention
  4. 2:35Tool approval and denied requests
  5. 3:04Hooks that block tool calls
  6. 3:26Running the local-model experiment
  7. 4:04Comparing input-token use
  8. 4:41Cost estimates and API keys

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.

#Claude Agent SDK#Python#ai agents#MCP#local models#security

More videos

All videos →

More on AI Agents.

$ subscribe --weekly

Get the next tutorial in your inbox.

Programming, security and AI — the practical bits, no spam. Unsubscribe any time.