> ## Documentation Index
> Fetch the complete documentation index at: https://lab.pollack.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# ACP Spring Boot Autoconfiguration

> Spring Boot autoconfiguration for the ACP Java SDK — auto-configured clients, agents, and transports with property-driven configuration.

Spring Boot autoconfiguration for the [ACP Java SDK](/acp-java-sdk). Provides auto-configured clients, agents, and transports with property-driven configuration.

## Quick Start

Add the starter dependency:

```xml theme={null}
<dependency>
    <groupId>org.springaicommunity</groupId>
    <artifactId>acp-spring-boot-starter</artifactId>
    <version>0.11.0</version>
</dependency>
```

### Client

Configure the transport in `application.properties` and inject the client:

```properties theme={null}
spring.acp.client.transport.stdio.command=java
spring.acp.client.transport.stdio.args=-jar,my-agent.jar
```

```java theme={null}
@Component
public class MyService {

    private final AcpSyncClient client;

    public MyService(AcpSyncClient client) {
        this.client = client;
    }

    public void run() {
        client.initialize();
        var session = client.newSession(new NewSessionRequest(cwd, List.of()));
        var response = client.prompt(new PromptRequest(session.sessionId(), content));
    }
}
```

### Agent

Annotate a Spring bean with `@AcpAgent` and add handler methods:

```java theme={null}
@Component
@AcpAgent(name = "my-agent", version = "1.0")
public class MyAgent {

    @Initialize
    public InitializeResponse initialize(InitializeRequest request) {
        return InitializeResponse.ok();
    }

    @NewSession
    public NewSessionResponse newSession(NewSessionRequest request) {
        return new NewSessionResponse(UUID.randomUUID().toString(), null, null);
    }

    @Prompt
    public PromptResponse prompt(PromptRequest request, SyncPromptContext context) {
        context.sendMessage("Hello!");
        return PromptResponse.endTurn();
    }
}
```

For stdio agents, redirect logging to stderr and keep the JVM alive:

```properties theme={null}
spring.main.banner-mode=off
spring.main.keep-alive=true
```

## Configuration Properties

### Client

| Property                                                | Default     | Description                                    |
| ------------------------------------------------------- | ----------- | ---------------------------------------------- |
| `spring.acp.client.request-timeout`                     | `30s`       | Request timeout                                |
| `spring.acp.client.transport.type`                      | auto-detect | `stdio` or `websocket`                         |
| `spring.acp.client.transport.stdio.command`             | —           | Command to launch agent process                |
| `spring.acp.client.transport.stdio.args`                | —           | Command arguments (comma-separated)            |
| `spring.acp.client.transport.stdio.env.*`               | —           | Environment variables for the process          |
| `spring.acp.client.transport.websocket.uri`             | —           | WebSocket URI (e.g. `ws://localhost:8080/acp`) |
| `spring.acp.client.transport.websocket.connect-timeout` | `10s`       | WebSocket connection timeout                   |
| `spring.acp.client.capabilities.read-text-file`         | `true`      | Advertise file read capability                 |
| `spring.acp.client.capabilities.write-text-file`        | `true`      | Advertise file write capability                |
| `spring.acp.client.capabilities.terminal`               | `false`     | Advertise terminal capability                  |

### Agent

| Property                           | Default | Description                    |
| ---------------------------------- | ------- | ------------------------------ |
| `spring.acp.agent.enabled`         | `true`  | Enable agent autoconfiguration |
| `spring.acp.agent.request-timeout` | `60s`   | Request processing timeout     |
| `spring.acp.agent.transport.type`  | `stdio` | Transport type                 |

## Transport Selection

The client transport is selected automatically based on which properties are set:

* Set `spring.acp.client.transport.stdio.command` → stdio transport
* Set `spring.acp.client.transport.websocket.uri` → WebSocket transport
* Set `spring.acp.client.transport.type` → explicit selection (takes precedence)

The agent defaults to stdio transport. Set `spring.acp.agent.enabled=false` to disable.

## Overriding Beans

All auto-configured beans back off when you provide your own. Define a custom `AcpClientTransport`, `AcpSyncClient`, `AcpAsyncClient`, or `AcpAgentTransport` bean and the autoconfiguration will use yours instead.

## Tutorial

<CardGroup cols={2}>
  <Card title="Spring Boot Agent" icon="server" href="/acp-java-sdk/tutorial/23-spring-boot-agent">
    Build an ACP agent as a Spring Boot application
  </Card>

  <Card title="Spring Boot Client" icon="plug" href="/acp-java-sdk/tutorial/24-spring-boot-client">
    Use the autoconfigured ACP client in Spring Boot
  </Card>
</CardGroup>

## Requirements

* Java 21+
* Spring Boot 4.0+
* ACP Java SDK 0.14.0+

## Resources

* [GitHub Repository](https://github.com/spring-ai-community/acp-autoconfig) — Source code
* [ACP Java SDK](/acp-java-sdk) — The underlying SDK
* [Maven Central](https://central.sonatype.com/artifact/org.springaicommunity/acp-spring-boot-starter) — Published artifacts
