a2aproject/a2a-go
Golang SDK for A2A Protocol
What is A2A Go SDK?
The A2A Go SDK is a Go library that lets you build and consume agentic services that speak the Agent‑to‑Agent (A2A) Protocol v1.0. In practice, an agent is a piece of software that can receive a request (e.g., a user message), run some logic—often an LLM or other AI model—and return a response. The SDK provides the plumbing so you can focus on the agent’s core logic while handling networking, message formatting, and protocol compliance for you.
Core Components
| Component | What it does | Typical use |
|---|---|---|
a2asrv (Server SDK) |
Builds a transport‑agnostic request handler and wraps it for gRPC, REST, or JSON‑RPC. | Deploy an AI‑powered agent as a service that other agents can call. |
a2aclient (Client SDK) |
Resolves an AgentCard (metadata describing how to reach an agent) and creates a client that can send messages. | Call another agent from your Go program, or from a CLI tool. |
Transport bindings (a2agrpc, a2asrv.NewRESTHandler, etc.) |
Convert the generic handler into concrete network servers/clients. | Choose the protocol that fits your environment (high‑performance gRPC, simple HTTP, etc.). |
| Extension points | Plug‑in custom transports, authentication middleware, message stores, etc. | Integrate with existing auth systems, databases, or custom networking layers. |
Getting Started (Step‑by‑step)
Install the SDK
go get github.com/a2aproject/a2a-go/v2Requires Go 1.25+.
Write a server
// Create your own executor that knows how to run the agent logic. agentExec := newMyAgentExecutor() handler := a2asrv.NewHandler(agentExec) // Choose a transport – here gRPC. grpcHandler := a2agrpc.NewHandler(handler) srv := grpc.NewServer() grpcHandler.RegisterWith(srv) srv.Serve(lis) // lis is a net.ListenerReplace
newMyAgentExecutorwith code that calls an LLM, runs a script, etc.Write a client
card, _ := agentcard.DefaultResolver.Resolve(ctx) // discovers the remote agent client, _ := a2aclient.NewFromCard(ctx, card) msg := a2a.NewMessage(a2a.MessageRoleUser, a2a.NewTextPart("Hello!")) resp, _ := client.SendMessage(ctx, &a2a.SendMessageRequest{Message: msg}) fmt.Println(resp)Run the example The repository ships a minimal
examples/helloworldthat demonstrates both sides.
Why Use A2A?
- Standardised communication – By following the A2A spec, different agents (even from other languages) can interoperate without custom adapters.
- Transport flexibility – Same business logic can be exposed over gRPC, plain HTTP, or JSON‑RPC with only a few lines of glue code.
- Pluggable architecture – Swap in your own auth, persistence, or transport layers without rewriting the core.
- CLI companion – The separate
a2a-clitool lets you test agents, discover them, or expose a local script as an A2A endpoint without writing Go code.
Ecosystem & Resources
- Documentation – Full API reference at https://pkg.go.dev/github.com/a2aproject/a2a-go/v2.
- CLI tool –
a2a-cli(repo:a2aproject/a2a-cli) for quick experimentation. - Sample projects – A collection of more elaborate use‑cases lives in
a2aproject/a2a-samples. - Specification – The protocol definition is published at https://a2a-protocol.org.
- Contribution – Guidelines are in
CONTRIBUTING.md; open an issue before large changes.
TL;DR
The A2A Go SDK is a production‑ready library for building AI‑oriented agent services that speak a common, versioned protocol. It abstracts networking (gRPC/REST/JSON‑RPC), provides ready‑made client and server helpers, and is extensible for custom authentication or storage needs. If you’re writing Go code that needs to expose or consume an LLM‑backed agent in a standards‑compliant way, this SDK gives you the boilerplate so you can focus on the model logic itself.
Related
- Project
- Project
- Project
- Project
- Project