claude-agent-sdk-python: Anthropic's embeddable agent runtime for Python apps
Project Overview
Anthropic’s decision to ship a Python SDK for their Claude Agent marks an interesting strategic shift in how they’re approaching developer tooling. Rather than treating Claude Code as a standalone CLI product, they’re positioning it as an embeddable agent runtime that Python applications can integrate directly. The SDK bundles the Claude Code CLI automatically, which means developers don’t need to manage a separate installation — a design choice that lowers the friction for getting started but also raises questions about version pinning and upgrade strategies for production deployments. With over 6,700 stars on GitHub[1], the project has clearly struck a chord with the Python community, though it’s worth noting that the SDK is still in its early stages at v0.1.76[2], so API stability isn’t guaranteed yet. The architecture leans heavily on async patterns via the anyio library, which feels appropriate given the streaming nature of agent responses, but does mean developers working in synchronous codebases will need to adapt their patterns.
What It’s For
This SDK is designed for Python developers who want to programmatically interact with Claude Code’s agent capabilities — think automated code review pipelines, AI-assisted refactoring tools, or custom development workflows that need an agent that can read, write, and execute code in a sandboxed environment. Unlike calling the Claude API directly, which gives you a language model response, this SDK gives you access to Claude’s full toolset: file operations, bash commands, and the ability to iterate on tasks across multiple turns. The tradeoff is that you’re trading raw API control for agent autonomy — you get a system that can actually execute code and modify files, but you lose fine-grained control over individual model calls. It competes most directly with OpenAI’s Code Interpreter and Codex patterns, though Anthropic’s approach differs by giving developers more explicit permission controls through allowed_tools and permission_mode rather than relying on system prompts alone. Where this SDK really shines is in scenarios where you need an agent that can work within an existing codebase — setting a working directory and letting Claude navigate, read, and modify files autonomously.
How to Use It
The core workflow revolves around the query() function, which streams responses as an async iterator — a design that makes sense for long-running agent tasks where you want to see intermediate results rather than waiting for a final answer. The more interesting capability lives in ClaudeSDKClient, which adds support for custom tools and hooks defined as Python functions. These custom tools are implemented as in-process MCP servers, which is a pragmatic architectural choice: instead of spinning up separate subprocesses for each tool (the standard MCP approach), tools run directly in your application’s process. This eliminates IPC overhead and simplifies deployment, but it also means a misbehaving tool could crash your entire application. The permission model deserves attention: allowed_tools is an allowlist for auto-approval, not a tool availability filter — tools not in the list still appear to Claude but require explicit permission. This is a subtle but important distinction that could catch developers off guard if they expect allowed_tools to restrict what Claude can see.
Installs the SDK along with the bundled Claude Code CLI
pip install claude-agent-sdk
Basic streaming query pattern using anyio for async execution
async for message in query(prompt="What is 2 + 2?"):
Decorator-based custom tool definition that runs as an in-process MCP server
@tool("greet", "Greet a user", {"name": str})
Recent Updates
Latest Release: v0.1.76 (Not specified in provided data)
Latest release in the v0.1.x series, indicating active development with frequent iterations
The SDK is moving rapidly through v0.1.x releases, suggesting Anthropic is iterating based on early adopter feedback rather than stabilizing for a major release. The release notes aren’t provided in the README, which makes it harder to track what’s changing between versions — a documentation gap that matters when you’re building on pre-release software. The community response has been strong with over 6,700 stars, but the lack of clear versioning strategy or changelog could become a pain point for teams evaluating this for production use.
Sources & Attributions
[1] Star count as of analysis — anthropics/claude-agent-sdk-python [2] Current version as of latest release data — anthropics/claude-agent-sdk-python@v0.1.76