New Features
- MCP 2.x support for in-process SDK MCP servers: The SDK now supports
mcp2.x alongside 1.x (dependency widened tomcp>=1.23.0,<3.0.0). In-process servers are served over mcp's own in-memory transport instead of hand-rolled JSON-RPC dispatch, so hand-builtmcp.server.Serverinstances now work at full fidelity — resources, prompts, and all result content types reach the CLI verbatim. Tool cancellation on interrupt is supported on mcp 2.x.claude_agent_sdk.ToolAnnotationsaccepts both camelCase and snake_case hint names on every mcp version (#1218) forward_subagent_textoption: Newforward_subagent_textboolean onClaudeAgentOptionsforwards a subagent's text and thinking blocks as messages in the stream, so consumers can render the full nested transcript. Matches the TypeScript SDK'sforwardSubagentText(#1206)ResultErrorexception with structured error payload: When the CLI exits after a terminal error result, the SDK now raisesResultError(a subclass ofProcessError) instead of a bare "exit code 1" error. Carriessubtype,errors,result,api_error_status,terminal_reason,session_id, and the rawdatadict so callers can branch on failure reason without string matching. New exported types:ResultError(#1205)can_use_toolcallback support forquery()and string prompts: Thecan_use_toolpermission callback now works with string prompts (not justClaudeSDKClient), and stdin is kept open so the CLI can send permission requests over the control protocol (#1204)
Bug Fixes
- Recover
parent_tool_use_idwhen reading subagent transcripts:get_subagent_messages()andget_subagent_messages_from_store()now recover theparent_tool_use_idfrom the subagent's metadata, linking each subagent's messages to the Agenttool_useblock in the parent session.SessionMessagealso gains aparent_agent_idfield for the spawning agent's id (#1207)
Internal/Other Changes
- Updated bundled Claude CLI to version 2.1.235
PyPI: https://pypi.org/project/claude-agent-sdk/0.2.140/
pip install claude-agent-sdk==0.2.140