Skip to main content
What’s New β†’
This project has moved from the spring-ai-community GitHub organization to markpollack. New releases are published under the Maven groupId io.github.markpollack, and Java packages now use the io.github.markpollack namespace. If you previously used org.springaicommunity, update your dependency coordinates and imports to the current values shown below.
Java SDK for programmatic access to Claude Code. Three APIs at different abstraction levels: Query (one-liner fire-and-forget), ClaudeSyncClient (blocking sessions), and ClaudeAsyncClient (reactive with Project Reactor). Pure Java β€” no native dependencies, and no Spring dependency either: the SDK module depends only on zt-exec, Jackson, Reactor, SLF4J and the MCP Java SDK. Spring Boot auto-configuration for Claude lives in Agent Client, not here. This is the SDK that powers ClaudeStep in Agent Workflow β€” each step runs a full multi-turn Claude session internally. Current release: 1.5.1. 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. See What’s New β†’.

Using it

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.
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.

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:

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

Multi-Agent

Subagent definitions, parallel subagents, orchestrator pattern

Source

SDK Source

SDK implementation

Tutorial Code

23 runnable tutorial modules

Role in the Lab

  • Agent Workflow uses ClaudeStep which wraps ClaudeSyncClient β€” each workflow step runs a full multi-turn Claude session
  • Agent Client uses the SDK for Claude Code integration with Spring Boot lifecycle and sandbox isolation
  • All experiments invoke Claude through this SDK via the experiment driver’s ClaudeSdkInvoker