Go SDK for the Agent Client Protocol (ACP), offering typed requests, responses, and helpers so Go applications can build ACP-compliant agents, clients, and integrations
Go
239
31 commits
updated Jun 5, 2026
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.13.5
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:
acp.Agent interface (and optionally acp.AgentLoader for session/load).acp.NewAgentSideConnection(agent, os.Stdout, os.Stdin).If you're building a Client:
acp.Client interface (and optionally acp.ClientTerminal for
terminal features).acp.NewClientSideConnection(client, stdin, stdout).Initialize, NewSession, and Prompt to run a turn and stream updates.Helper constructors are provided to reduce boilerplate when working with union types:
acp.TextBlock, acp.ImageBlock, acp.AudioBlock,
acp.ResourceLinkBlock, acp.ResourceBlock.acp.ToolContent, acp.ToolDiffContent, acp.ToolTerminalRef.acp.Ptr[T] for pointer fields in request/update structs.ACP supports extension methods for custom JSON-RPC methods whose names start with _.
Use them to add functionality without conflicting with future ACP versions.
Implement acp.ExtensionMethodHandler on your Agent or Client. Your handler will be
invoked for any incoming method starting with _.
// HandleExtensionMethod handles ACP extension methods (names starting with "_").
func (a MyAgent) HandleExtensionMethod(ctx context.Context, method string, params json.RawMessage) (any, error) {
switch method {
case "_example.com/hello":
var p struct {
Name string `json:"name"`
}
if err := json.Unmarshal(params, &p); err != nil {
return nil, err
}
return map[string]any{"greeting": "hello " + p.Name}, nil
default:
return nil, acp.NewMethodNotFound(method)
}
}
Note: Per the ACP spec, unknown extension notifications should be ignored. This SDK suppresses noisy logs for unhandled extension notifications that return “Method not found”.
From either side, use CallExtension / NotifyExtension on the connection.
raw, err := conn.CallExtension(ctx, "_example.com/hello", map[string]any{"name": "world"})
if err != nil {
return err
}
var resp struct {
Greeting string `json:"greeting"`
}
if err := json.Unmarshal(raw, &resp); err != nil {
return err
}
if err := conn.NotifyExtension(ctx, "_example.com/progress", map[string]any{"pct": 50}); err != nil {
return err
}
_metaACP uses the _meta field inside capability objects as the negotiation/advertising
surface for extensions.
InitializeRequest.ClientCapabilities.MetaInitializeResponse.AgentCapabilities.MetaKeys traceparent, tracestate, and baggage are reserved in _meta for W3C trace
context/OpenTelemetry compatibility.
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.
907 followers · starred Nov 2025
174 followers · starred Dec 2025
373 followers · starred Feb 2026
343 followers · starred May 2026
Go SDK for the Agent Client Protocol (ACP), offering typed requests, responses, and helpers so Go applications can build ACP-compliant agents, clients, and integrations
Go
239
31 commits
updated Jun 5, 2026
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.13.5
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:
acp.Agent interface (and optionally acp.AgentLoader for session/load).acp.NewAgentSideConnection(agent, os.Stdout, os.Stdin).If you're building a Client:
acp.Client interface (and optionally acp.ClientTerminal for
terminal features).acp.NewClientSideConnection(client, stdin, stdout).Initialize, NewSession, and Prompt to run a turn and stream updates.Helper constructors are provided to reduce boilerplate when working with union types:
acp.TextBlock, acp.ImageBlock, acp.AudioBlock,
acp.ResourceLinkBlock, acp.ResourceBlock.acp.ToolContent, acp.ToolDiffContent, acp.ToolTerminalRef.acp.Ptr[T] for pointer fields in request/update structs.ACP supports extension methods for custom JSON-RPC methods whose names start with _.
Use them to add functionality without conflicting with future ACP versions.
Implement acp.ExtensionMethodHandler on your Agent or Client. Your handler will be
invoked for any incoming method starting with _.
// HandleExtensionMethod handles ACP extension methods (names starting with "_").
func (a MyAgent) HandleExtensionMethod(ctx context.Context, method string, params json.RawMessage) (any, error) {
switch method {
case "_example.com/hello":
var p struct {
Name string `json:"name"`
}
if err := json.Unmarshal(params, &p); err != nil {
return nil, err
}
return map[string]any{"greeting": "hello " + p.Name}, nil
default:
return nil, acp.NewMethodNotFound(method)
}
}
Note: Per the ACP spec, unknown extension notifications should be ignored. This SDK suppresses noisy logs for unhandled extension notifications that return “Method not found”.
From either side, use CallExtension / NotifyExtension on the connection.
raw, err := conn.CallExtension(ctx, "_example.com/hello", map[string]any{"name": "world"})
if err != nil {
return err
}
var resp struct {
Greeting string `json:"greeting"`
}
if err := json.Unmarshal(raw, &resp); err != nil {
return err
}
if err := conn.NotifyExtension(ctx, "_example.com/progress", map[string]any{"pct": 50}); err != nil {
return err
}
_metaACP uses the _meta field inside capability objects as the negotiation/advertising
surface for extensions.
InitializeRequest.ClientCapabilities.MetaInitializeResponse.AgentCapabilities.MetaKeys traceparent, tracestate, and baggage are reserved in _meta for W3C trace
context/OpenTelemetry compatibility.
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.
907 followers · starred Nov 2025
174 followers · starred Dec 2025
373 followers · starred Feb 2026
343 followers · starred May 2026