Skip to main content
Version 1.8.0 (2026-11-15) · on Maven Central · What’s New → Claude Code, programmable from plain Java. The SDK runs the Claude Code CLI as a child process and gives you three ways to talk to it over the same transport: Query for a one-shot answer, ClaudeSyncClient for blocking multi-turn sessions and ClaudeAsyncClient for reactive streams with Project Reactor. Hooks, permission callbacks, MCP servers, subagents and structured output come with it. Pure Java, with no native code and no Spring dependency: the SDK needs only zt-exec, Jackson, Reactor, SLF4J and the MCP Java SDK. Spring Boot auto-configuration for Claude lives in Agent Client, whose Claude provider, agent-claude, is built on this SDK.
Java 21 or later. Every published artifact is Java 21 bytecode (class-file major 65); there has never been a Java 17 build, and a Java 17 runtime cannot load the SDK. The claude CLI must be installed and authenticated.

What you get

Three APIs, one transport

Query.text, query, stream and execute for one-shot calls; ClaudeSyncClient for blocking turns; ClaudeAsyncClient returns Mono and Flux for text, text streams and messages.

Sessions you can steer

Resume, continue or fork a session. During a session, interrupt(), setModel(...) and setPermissionMode(...) change course without starting over.

Hooks that the CLI obeys

Register Java callbacks for all six hook events, PreToolUse to PreCompact, and allow, block or rewrite a tool call. From 1.8.0 a PreToolUse deny reaches the CLI in the nested form it reads.

Permission callbacks

A ToolPermissionCallback sees each tool request with its input and returns allow, allow with changed input, or deny with a message.

MCP servers

Attach stdio, SSE and HTTP MCP servers by name; their tools appear to Claude as mcp__{name}__{tool}.

Structured output

Pass a JSON schema and read the result back as your own type with getStructuredOutputAs(...), with cost and usage in the result metadata.

Record exactly what the CLI wrote

New in 1.8.0: every standard-output line before parsing, the original JSON of every message, and the raw process bytes of stdin, stdout and stderr, so a recorder can keep a session as it happened.

Shutdown you can check

New in 1.8.0: close() makes one bounded cleanup attempt of seven seconds, and transportResources() reports which observed processes, readers and temporary files actually ended.

1.8.0 in brief

1.8.0 fixes four Jackson vulnerabilities by moving to Jackson 2.22.3 and 3.2.3. Published 1.5.1, 1.6.0 and 1.7.0 declare Jackson 2.22.2 and 3.2.2, which carry CVE-2026-89407, CVE-2026-89425, CVE-2026-91776 and CVE-2026-91777 (CVSS 7.5), so upgrade to 1.8.0. It also repairs three wire defects: a required MCP configuration that cannot be written now fails before the CLI starts, control responses carry subtype once, and hook responses keep their nested fields. Builder users need no code change; direct new CLIOptions(...) calls and three ParsedMessage record constructors gain components, and the unused ClaudeCliPrototype class is removed. Release notes. 1.7.0: Closing or cancelling a session destroys the Claude CLI process tree before closing streams, unblocking readers and preventing the CLI from surviving cancellation. 1.5.0: A security, packaging and behaviour-correction release: it raises the Jackson floors so they reach standalone consumers, embeds the Apache licence in every archive, publishes a CycloneDX 1.6 SBOM, and stops a no-argument connect() from sending a prompt of its own. It follows 1.4.0, which bumped the MCP SDK from 0.15.0 to 2.0.0 (mcp-core 2.0.0), clearing CVE-2026-35568; 1.8.0 uses MCP SDK 2.0.1. See What’s New →.
Upgrade from 1.4.0. If you use 1.4.0 without importing a BOM that manages Jackson, your runtime closure resolves Jackson 2.21.2 and Jackson 3.0.3, which carry 23 known vulnerabilities (8 HIGH). 1.5.0 declares the Jackson 2.21.6 / 3.1.6 floors directly on the published module, so the same no-BOM consumer resolves zero findings. 1.4.0 stays published and stays exposed — Maven Central is immutable, and nothing repairs it retroactively.

How it operates

The SDK does not call the Anthropic API. It spawns the Claude Code CLI as a child process and speaks the stream-JSON control protocol to it over stdin and stdout. That shapes what you need to know:
  • The claude executable must be installed and authenticated on the machine that runs your code. The SDK discovers it on PATH and in the usual install locations.
  • ANTHROPIC_API_KEY is passed through to the child process when set. Environment inheritance is otherwise a whitelist, not a copy of your whole environment.
  • Every session consumes real model usage and is billed. That includes the integration test suite in the SDK repository. A no-argument connect() sends nothing on its own: from 1.5.0 it starts and initialises the session and leaves the first turn to your query(...). Before 1.5.0 it substituted a literal "Hello" and billed that turn.
  • The child process, and its descendants, are terminated on close.

MCP servers

McpServerConfig is a sealed interface with four server types (1.8.0): Register a server by name with CLIOptions.Builder.mcpServer(name, config), or on a client spec with ClaudeClient SyncSpec/AsyncSpec .mcpServer(name, config) and .mcpServers(Map). Its tools are named mcp__{name}__{tool}, for example mcp__fs__read_file, which is the name to use in an allowed-tools list.
In-process servers list tools but cannot yet run them. In 1.8.0 the SDK answers initialize and the list methods for an McpSdkServerConfig, but a tools/call, resources/read or prompts/get through it returns the JSON-RPC error “not yet implemented”. Use a stdio, SSE or HTTP server for tools Claude must call.
From 1.8.0, a requested --mcp-config that cannot be written fails before the CLI is launched, with TransportException("Failed to prepare required MCP configuration") (f555e72b). In 1.7.0 the SDK logs a warning and launches the CLI without the MCP servers.

Licence

Apache License 2.0 — see the repository LICENSE. This SDK is a supporting public project and is not part of the AgentWorks BSL set.

Tutorials

23 progressive modules from fundamentals to multi-agent orchestration. The tutorial builds against SDK 1.8.0 from Maven Central (tutorial feddc99).

Query & Clients

Query API, sync client, async client, message types

Configuration

CLI options, tool permissions, permission modes, structured outputs

Sessions

Multi-turn conversations, session resume, session fork

Safety & Hooks

Permission callbacks, pre/post tool-use hooks, interrupt handling

MCP Integration

External MCP servers, multiple servers, MCP with hooks (stdio servers only; see MCP servers above for SSE, HTTP and in-process)

Multi-Agent

Subagent definitions, parallel subagents, orchestrator pattern

Source

SDK Source

SDK implementation

Tutorial Code

23 runnable tutorial modules

Role in the Lab

  • Agent Client uses the SDK for Claude Code integration (agent-claude), with Spring Boot lifecycle and sandbox isolation
  • Agent Workflow does not depend on this SDK. Its ClaudeStep runs the claude CLI as a subprocess through Workflow’s own ClaudeSyncClient interface, whose default implementation an application can replace
  • Agent Experiment 0.9.0 invokes Claude through ClaudeSdkInvoker (experiment-claude). On main it is replaced by AgentClientInvoker, which reaches this SDK through Agent Client