Go library for the Agent Client Protocol (ACP) - a standardized communication protocol between code editors and AI‑powered coding agents.
Learn more about the protocol itself at https://agentclientprotocol.com.
go get github.com/coder/acp-go-sdk@v0.4.3
Start by reading the official ACP documentation to understand the core concepts and protocol specification.
The examples directory contains simple implementations of both Agents and Clients in Go. You can run them from your terminal or connect to external ACP agents.
go run ./example/agent
starts a minimal ACP agent over stdio.go run ./example/claude-code
demonstrates bridging to Claude Code.go run ./example/client
connects to a running agent and streams a sample turn.go run ./example/gemini
bridges to the Gemini CLI in ACP mode (flags: -model, -sandbox, -debug, -gemini /path/to/gemini).
You can watch the interaction by running go run ./example/client
locally.
Browse the Go package docs on pkg.go.dev for detailed API documentation:
If you're building an Agent:
- Implement the
acp.Agent
interface (and optionallyacp.AgentLoader
forsession/load
). - Create a connection with
acp.NewAgentSideConnection(agent, os.Stdout, os.Stdin)
. - Send updates and make client requests using the returned connection.
If you're building a Client:
- Implement the
acp.Client
interface (and optionallyacp.ClientTerminal
for terminal features). - Launch or connect to your Agent process (stdio), then create a connection with
acp.NewClientSideConnection(client, stdin, stdout)
. - Call
Initialize
,NewSession
, andPrompt
to run a turn and stream updates.
Helper constructors are provided to reduce boilerplate when working with union types:
- Content blocks:
acp.TextBlock
,acp.ImageBlock
,acp.AudioBlock
,acp.ResourceLinkBlock
,acp.ResourceBlock
. - Tool content:
acp.ToolContent
,acp.ToolDiffContent
,acp.ToolTerminalRef
. - Utility:
acp.Ptr[T]
for pointer fields in request/update structs.
For a complete, production‑ready integration, see the
Gemini CLI Agent which exposes an
ACP interface. The Go example client example/gemini
demonstrates connecting
to it via stdio.
Apache 2.0. See LICENSE.