C#/.NET SDK for A2A Protocol
261
stars
269
commits
C#
primary language
Sep 9, 2026
updated
A .NET library that helps run agentic applications as A2AServers following the Agent2Agent (A2A) Protocol.
The A2A .NET SDK provides a robust implementation of the Agent2Agent (A2A) protocol, enabling seamless communication between AI agents and applications. This library offers both high-level abstractions and fine-grained control, making it easy to build A2A-compatible agents while maintaining flexibility for advanced use cases.
Key features include:
This library implements the A2A v1.0 specification. It provides full support for the JSON-RPC binding and HTTP+JSON REST binding, including streaming via Server-Sent Events.
If you're upgrading from the v0.3 SDK, see the Migration Guide for a comprehensive list of breaking changes and before/after code examples. A backward-compatible A2A.V0_3 NuGet package is available during the transition:
dotnet add package A2A.V0_3
dotnet add package A2A
dotnet add package A2A.AspNetCore

This library contains the core A2A protocol implementation. It includes the following key classes:
A2AClient: Primary client for making A2A requests to agents. Supports both streaming and non-streaming communication, task management, and push notifications.A2ACardResolver: Resolves agent card information from A2A-compatible endpoints to discover agent capabilities and metadata.A2AServer: Core server that handles A2A JSON-RPC requests, manages task lifecycle via TaskProjection, and coordinates streaming/non-streaming responses. Implements IA2ARequestHandler.IAgentHandler: Interface that agents implement. Provides ExecuteAsync() for message handling and CancelAsync() for task cancellation.TaskUpdater: Convenience API for emitting task lifecycle events (Submit, StartWork, AddArtifact, Complete, Fail, Cancel, RequireInput).MessageResponder: Convenience API for stateless message replies without task lifecycle.RequestContext: Pre-resolved context provided to agents, containing the incoming message, task ID, context ID, and helper properties like UserText and IsContinuation.AgentEventQueue: Channel-backed queue that agents write events to. The SDK reads from it to build responses.ITaskStore: Interface for task persistence with simple CRUD methods (Get, Save, Delete, List).InMemoryTaskStore: In-memory implementation of ITaskStore suitable for development and testing.AgentTask: Represents a task with its status, history, artifacts, and metadata.AgentCard: Contains agent metadata, capabilities, and endpoint information.Message: Represents messages exchanged between agents and clients.This library provides ASP.NET Core integration for hosting A2A agents. It includes the following key classes:
A2AServiceCollectionExtensions: Provides AddA2AAgent<THandler>() for registering an agent, its card, and all A2A services with dependency injection.A2ARouteBuilderExtensions: Provides MapA2A() for JSON-RPC endpoints, MapHttpA2A() for HTTP REST endpoints, and MapWellKnownAgentCard() for agent card discovery.using A2A;
using A2A.AspNetCore;
var builder = WebApplication.CreateBuilder(args);
// Register the echo agent with DI — this sets up A2AServer, ITaskStore, and all middleware
builder.Services.AddA2AAgent<EchoAgent>(EchoAgent.GetAgentCard("http://localhost:5000/echo"));
var app = builder.Build();
// Map JSON-RPC endpoint for A2A communication
app.MapA2A("/echo");
// Map well-known agent card for discovery
var card = app.Services.GetRequiredService<AgentCard>();
app.MapWellKnownAgentCard(card);
app.Run();
// Define the agent — implement IAgentHandler
public sealed class EchoAgent : IAgentHandler
{
public async Task ExecuteAsync(
RequestContext context,
AgentEventQueue eventQueue,
CancellationToken cancellationToken)
{
var responder = new MessageResponder(eventQueue, context.ContextId);
await responder.ReplyAsync($"Echo: {context.UserText}", cancellationToken);
}
public static AgentCard GetAgentCard(string url) => new()
{
Name = "Echo Agent",
Description = "Echoes messages back to the user",
Version = "1.0.0",
SupportedInterfaces = [new AgentInterface
{
Url = url,
ProtocolBinding = "JSONRPC",
ProtocolVersion = "1.0"
}],
DefaultInputModes = ["text/plain"],
DefaultOutputModes = ["text/plain"],
Capabilities = new AgentCapabilities { Streaming = false },
Skills = [new AgentSkill
{
Id = "echo",
Name = "Echo",
Description = "Echoes back user messages",
Tags = ["echo"]
}],
};
}
using A2A;
// Discover agent
var cardResolver = new A2ACardResolver(new Uri("http://localhost:5000/"));
var agentCard = await cardResolver.GetAgentCardAsync();
// Create client using agent's endpoint
var client = new A2AClient(new Uri(agentCard.SupportedInterfaces[0].Url));
// Send message
var response = await client.SendMessageAsync(new SendMessageRequest
{
Message = new Message
{
MessageId = Guid.NewGuid().ToString("N"),
Role = Role.User,
Parts = [Part.FromText("Hello!")]
}
});
// Handle response
switch (response.PayloadCase)
{
case SendMessageResponseCase.Message:
Console.WriteLine(response.Message!.Parts[0].Text);
break;
case SendMessageResponseCase.Task:
Console.WriteLine($"Task created: {response.Task!.Id}");
break;
}
The repository includes several sample projects demonstrating different aspects of the A2A protocol implementation. Each sample includes its own README with detailed setup and usage instructions.
Comprehensive collection of client-side samples showing how to interact with A2A agents:
Server-side examples demonstrating how to build A2A-compatible agents:
Advanced sample showing integration with Microsoft Semantic Kernel:
Command-line tool for interacting with A2A agents:
Clone and build the repository:
git clone https://github.com/a2aproject/a2a-dotnet.git
cd a2a-dotnet
dotnet build
Run the client samples:
cd samples/AgentClient
dotnet run
For detailed instructions and advanced scenarios, see the individual README files linked above.
To learn more about the A2A protocol, explore these additional resources:
This library builds upon Darrel Miller's sharpa2a project. Thanks to Darrel and all the other contributors for the foundational work that helped shape this SDK.
This project is licensed under the Apache 2.0 License.
C#
100.0%
C#/.NET SDK for A2A Protocol
261
stars
269
commits
C#
primary language
Sep 9, 2026
updated
A .NET library that helps run agentic applications as A2AServers following the Agent2Agent (A2A) Protocol.
The A2A .NET SDK provides a robust implementation of the Agent2Agent (A2A) protocol, enabling seamless communication between AI agents and applications. This library offers both high-level abstractions and fine-grained control, making it easy to build A2A-compatible agents while maintaining flexibility for advanced use cases.
Key features include:
This library implements the A2A v1.0 specification. It provides full support for the JSON-RPC binding and HTTP+JSON REST binding, including streaming via Server-Sent Events.
If you're upgrading from the v0.3 SDK, see the Migration Guide for a comprehensive list of breaking changes and before/after code examples. A backward-compatible A2A.V0_3 NuGet package is available during the transition:
dotnet add package A2A.V0_3
dotnet add package A2A
dotnet add package A2A.AspNetCore

This library contains the core A2A protocol implementation. It includes the following key classes:
A2AClient: Primary client for making A2A requests to agents. Supports both streaming and non-streaming communication, task management, and push notifications.A2ACardResolver: Resolves agent card information from A2A-compatible endpoints to discover agent capabilities and metadata.A2AServer: Core server that handles A2A JSON-RPC requests, manages task lifecycle via TaskProjection, and coordinates streaming/non-streaming responses. Implements IA2ARequestHandler.IAgentHandler: Interface that agents implement. Provides ExecuteAsync() for message handling and CancelAsync() for task cancellation.TaskUpdater: Convenience API for emitting task lifecycle events (Submit, StartWork, AddArtifact, Complete, Fail, Cancel, RequireInput).MessageResponder: Convenience API for stateless message replies without task lifecycle.RequestContext: Pre-resolved context provided to agents, containing the incoming message, task ID, context ID, and helper properties like UserText and IsContinuation.AgentEventQueue: Channel-backed queue that agents write events to. The SDK reads from it to build responses.ITaskStore: Interface for task persistence with simple CRUD methods (Get, Save, Delete, List).InMemoryTaskStore: In-memory implementation of ITaskStore suitable for development and testing.AgentTask: Represents a task with its status, history, artifacts, and metadata.AgentCard: Contains agent metadata, capabilities, and endpoint information.Message: Represents messages exchanged between agents and clients.This library provides ASP.NET Core integration for hosting A2A agents. It includes the following key classes:
A2AServiceCollectionExtensions: Provides AddA2AAgent<THandler>() for registering an agent, its card, and all A2A services with dependency injection.A2ARouteBuilderExtensions: Provides MapA2A() for JSON-RPC endpoints, MapHttpA2A() for HTTP REST endpoints, and MapWellKnownAgentCard() for agent card discovery.using A2A;
using A2A.AspNetCore;
var builder = WebApplication.CreateBuilder(args);
// Register the echo agent with DI — this sets up A2AServer, ITaskStore, and all middleware
builder.Services.AddA2AAgent<EchoAgent>(EchoAgent.GetAgentCard("http://localhost:5000/echo"));
var app = builder.Build();
// Map JSON-RPC endpoint for A2A communication
app.MapA2A("/echo");
// Map well-known agent card for discovery
var card = app.Services.GetRequiredService<AgentCard>();
app.MapWellKnownAgentCard(card);
app.Run();
// Define the agent — implement IAgentHandler
public sealed class EchoAgent : IAgentHandler
{
public async Task ExecuteAsync(
RequestContext context,
AgentEventQueue eventQueue,
CancellationToken cancellationToken)
{
var responder = new MessageResponder(eventQueue, context.ContextId);
await responder.ReplyAsync($"Echo: {context.UserText}", cancellationToken);
}
public static AgentCard GetAgentCard(string url) => new()
{
Name = "Echo Agent",
Description = "Echoes messages back to the user",
Version = "1.0.0",
SupportedInterfaces = [new AgentInterface
{
Url = url,
ProtocolBinding = "JSONRPC",
ProtocolVersion = "1.0"
}],
DefaultInputModes = ["text/plain"],
DefaultOutputModes = ["text/plain"],
Capabilities = new AgentCapabilities { Streaming = false },
Skills = [new AgentSkill
{
Id = "echo",
Name = "Echo",
Description = "Echoes back user messages",
Tags = ["echo"]
}],
};
}
using A2A;
// Discover agent
var cardResolver = new A2ACardResolver(new Uri("http://localhost:5000/"));
var agentCard = await cardResolver.GetAgentCardAsync();
// Create client using agent's endpoint
var client = new A2AClient(new Uri(agentCard.SupportedInterfaces[0].Url));
// Send message
var response = await client.SendMessageAsync(new SendMessageRequest
{
Message = new Message
{
MessageId = Guid.NewGuid().ToString("N"),
Role = Role.User,
Parts = [Part.FromText("Hello!")]
}
});
// Handle response
switch (response.PayloadCase)
{
case SendMessageResponseCase.Message:
Console.WriteLine(response.Message!.Parts[0].Text);
break;
case SendMessageResponseCase.Task:
Console.WriteLine($"Task created: {response.Task!.Id}");
break;
}
The repository includes several sample projects demonstrating different aspects of the A2A protocol implementation. Each sample includes its own README with detailed setup and usage instructions.
Comprehensive collection of client-side samples showing how to interact with A2A agents:
Server-side examples demonstrating how to build A2A-compatible agents:
Advanced sample showing integration with Microsoft Semantic Kernel:
Command-line tool for interacting with A2A agents:
Clone and build the repository:
git clone https://github.com/a2aproject/a2a-dotnet.git
cd a2a-dotnet
dotnet build
Run the client samples:
cd samples/AgentClient
dotnet run
For detailed instructions and advanced scenarios, see the individual README files linked above.
To learn more about the A2A protocol, explore these additional resources:
This library builds upon Darrel Miller's sharpa2a project. Thanks to Darrel and all the other contributors for the foundational work that helped shape this SDK.
This project is licensed under the Apache 2.0 License.
C#
100.0%