CapabilityWire
// event · sdk

Claude Agent SDK for Python 0.2.166 adds typed hook outputs and SystemInitData

sdk
vendor: anthropicpublished: 2h agoconfidence: 0.85id: e40c7f97-5347-498c-af50-30b630f977b9

Anthropic's claude-agent-sdk-python 0.2.166 introduces hook-specific typed output classes and a fully-typed `SystemInitData` TypedDict (with nested `SystemInitMcpServer`, `SystemInitPlugin`, `FastModeState`, etc.) for the init system message. Also fixes `SandboxSettings.ignoreViolations` to be `dict[str, list[str]]` matching the CLI schema, and bumps bundled Claude CLI to 2.1.299.

capability delta

An agent can now read strongly-typed init payloads (model, capabilities, MCP servers, plugins) via SystemInitData and implement hooks with precise per-hook output types instead of untyped dicts.

curator note

Minor patch but meaningful typing surface additions for hook authors and anyone inspecting init metadata; also a correctness fix for sandbox ignoreViolations.

// install
pip install claude-agent-sdk==0.2.166
pypi · claude-agent-sdk @ 0.2.166
// example
python
from typing import cast
import anyio
from claude_agent_sdk import query, SystemInitData

async def main():
    async for msg in query(prompt="List my MCP servers"):
        if getattr(msg, "subtype", None) == "init":
            data = cast(SystemInitData, msg.data)
            print("model:", data["model"])
            for s in data["mcp_servers"]:
                print("mcp:", s["name"], s["status"])

anyio.run(main)
// links
anthropicclaudeagent-sdkpythonhookstypedmcp
source: github_release · https://github.com/anthropics/claude-agent-sdk-python/releases/tag/v0.2.166