Claude Agent SDK connector: targeted version and verified APIs¶
Package: claude-agent-sdk (published by Anthropic). Targeted: 0.2.188 (extra
credencestack[claude-agent-sdk], pinned >=0.2.188,<0.3). Checked against the installed
source on 2026-11-24.
APIs used, as found in 0.2.188¶
| Need | API in 0.2.188 | Where |
|---|---|---|
| Custom tools | SdkMcpTool(name, description, input_schema, handler) with an async handler(args) -> {"content": [...], "is_error": bool}; create_sdk_mcp_server(name, tools=[...]) returns an in-process MCP server config |
claude_agent_sdk/__init__.py |
| Session | ClaudeSDKClient(options, transport=None); async with client, client.query(prompt), client.receive_response() yielding AssistantMessage (TextBlock, ToolUseBlock) and ResultMessage |
client.py, types.py |
| Options | ClaudeAgentOptions(system_prompt, model, tools, allowed_tools, mcp_servers, hooks, can_use_tool, max_turns, ...) |
types.py |
| Approvals | can_use_tool(tool_name, input, ToolPermissionContext) -> PermissionResultAllow | PermissionResultDeny(message, interrupt); PreToolUse hooks (HookMatcher(matcher, hooks)) returning hookSpecificOutput.permissionDecision (allow, deny, ask) |
types.py, _internal/query.py |
| Stop | a hook output with continue_: False and stopReason (sent as continue) |
types.py |
| Transport | Transport (abstract: connect, write, read_messages, close, is_ready, end_input) and the control protocol: control_request subtypes initialize, hook_callback, can_use_tool, mcp_message |
_internal/transport/__init__.py, _internal/query.py |
Notes¶
- Offline model: the SDK has no scripted model, so the connector supplies a
Transport(ScriptedTransport) that answersinitialize, sendshook_callback,can_use_toolandmcp_messagerequests as the CLI would, and replays the scripted policy. The SDK'sTransportdocstring warns that it is an internal API that may change; the connector is pinned to 0.2.x for that reason. - Allow rules shadow
can_use_tool: the SDK warns (CanUseToolShadowedWarning) that a tool inallowed_toolsis approved before the callback is consulted. The connector therefore leaves CredenceStack's tools out ofallowed_toolsand allows calls incan_use_toolunless anask_forhook marked them. - Live runs: the wheel bundles the Claude Code CLI (
_bundled/claude), which the default transport starts. Not exercised here (no keys, no network in tests).