A2A.AspNetCore
0.1.0-preview.2
Prefix Reserved
See the version list below for details.
dotnet add package A2A.AspNetCore --version 0.1.0-preview.2
NuGet\Install-Package A2A.AspNetCore -Version 0.1.0-preview.2
<PackageReference Include="A2A.AspNetCore" Version="0.1.0-preview.2" />
<PackageVersion Include="A2A.AspNetCore" Version="0.1.0-preview.2" />
<PackageReference Include="A2A.AspNetCore" />
paket add A2A.AspNetCore --version 0.1.0-preview.2
#r "nuget: A2A.AspNetCore, 0.1.0-preview.2"
#:package A2A.AspNetCore@0.1.0-preview.2
#addin nuget:?package=A2A.AspNetCore&version=0.1.0-preview.2&prerelease
#tool nuget:?package=A2A.AspNetCore&version=0.1.0-preview.2&prerelease
A2A .NET SDK
<html> <h2 align="center"> <img src="https://raw.githubusercontent.com/a2aproject/A2A/refs/heads/main/docs/assets/a2a-logo-black.svg" width="256" alt="A2A Logo"/> </h2> <h3 align="center">A .NET library that helps run agentic applications as A2AServers following the <a href="https://a2a-protocol.org">Agent2Agent (A2A) Protocol</a>.</h3> </html>
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:
- Agent Capability Discovery: Retrieve agent capabilities and metadata through agent cards
- Message-based Communication: Direct, stateless messaging with immediate responses
- Task-based Communication: Create and manage persistent, long-running agent tasks
- Streaming Support: Real-time communication using Server-Sent Events
- ASP.NET Core Integration: Built-in extensions for hosting A2A agents in web applications
- Cross-platform Compatibility: Supports .NET Standard 2.0 and .NET 8+
Protocol Compatibility
This library implements most of the features of protocol v0.2.6, however there are some scenarios that are not yet complete for full compatibility with this version. A complete list of outstanding compatibility items can be found at: open compatibility items
Installation
Core A2A Library
dotnet add package A2A
ASP.NET Core Extensions
dotnet add package A2A.AspNetCore
Overview
Library: A2A
This library contains the core A2A protocol implementation. It includes the following key classes:
Client 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.
Server Classes
TaskManager
: Manages the complete lifecycle of agent tasks including creation, updates, cancellation, and event streaming. Handles both message-based and task-based communication patterns.ITaskStore
: An interface for abstracting the storage of tasks.InMemoryTaskStore
: Simple in-memory implementation ofITaskStore
suitable for development and testing scenarios.
Core Models
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.
Library: A2A.AspNetCore
This library provides ASP.NET Core integration for hosting A2A agents. It includes the following key classes:
Extension Methods
A2ARouteBuilderExtensions
: ProvidesMapA2A()
andMapHttpA2A()
extension methods for configuring A2A endpoints in ASP.NET Core applications.
Getting Started
1. Create an Agent Server
using A2A;
using A2A.AspNetCore;
var builder = WebApplication.CreateBuilder(args);
var app = builder.Build();
// Create and register your agent
var taskManager = new TaskManager();
var agent = new EchoAgent();
agent.Attach(taskManager);
app.MapA2A(taskManager, "/echo");
app.Run();
public class EchoAgent
{
public void Attach(ITaskManager taskManager)
{
taskManager.OnMessageReceived = ProcessMessageAsync;
taskManager.OnAgentCardQuery = GetAgentCardAsync;
}
private Task<Message> ProcessMessageAsync(MessageSendParams messageSendParams, CancellationToken cancellationToken)
{
var text = messageSendParams.Message.Parts.OfType<TextPart>().First().Text;
return Task.FromResult(new Message
{
Role = MessageRole.Agent,
MessageId = Guid.NewGuid().ToString(),
ContextId = messageSendParams.Message.ContextId,
Parts = [new TextPart { Text = $"Echo: {text}" }]
});
}
private Task<AgentCard> GetAgentCardAsync(string agentUrl, CancellationToken cancellationToken)
{
return Task.FromResult(new AgentCard
{
Name = "Echo Agent",
Description = "Echoes messages back to the user",
Url = agentUrl,
Version = "1.0.0",
DefaultInputModes = ["text"],
DefaultOutputModes = ["text"],
Capabilities = new AgentCapabilities { Streaming = true }
});
}
}
2. Connect with A2AClient
using A2A;
// Discover agent and create client
var cardResolver = new A2ACardResolver(new Uri("http://localhost:5100/"));
var agentCard = await cardResolver.GetAgentCardAsync();
var client = new A2AClient(new Uri(agentCard.Url));
// Send message
var response = await client.SendMessageAsync(new MessageSendParams
{
Message = new Message
{
Role = MessageRole.User,
Parts = [new TextPart { Text = "Hello!" }]
}
});
Samples
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.
Agent Client Samples
Comprehensive collection of client-side samples showing how to interact with A2A agents:
- Agent Capability Discovery: Retrieve agent capabilities and metadata using agent cards
- Message-based Communication: Direct, stateless messaging with immediate responses
- Task-based Communication: Create and manage persistent agent tasks
- Streaming Communication: Real-time communication using Server-Sent Events
Agent Server Samples
Server-side examples demonstrating how to build A2A-compatible agents:
- Echo Agent: Simple agent that echoes messages back to clients
- Echo Agent with Tasks: Task-based version of the echo agent
- Researcher Agent: More complex agent with research capabilities
- HTTP Test Suite: Complete set of HTTP tests for all agent endpoints
Semantic Kernel Integration
Advanced sample showing integration with Microsoft Semantic Kernel:
- Travel Planner Agent: AI-powered travel planning agent
- Semantic Kernel Integration: Demonstrates how to wrap Semantic Kernel functionality in A2A protocol
Command Line Interface
Command-line tool for interacting with A2A agents:
- Direct command-line access to A2A agents
- Useful for testing and automation scenarios
Quick Start with Client Samples
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.
Acknowledgements
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.
License
This project is licensed under the Apache 2.0 License.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last Updated |
---|---|---|
0.3.1-preview | 0 | 9/4/2025 |
0.1.0-preview.2 | 7,262 | 7/31/2025 |