A2A 0.3.1-preview

Prefix Reserved
This is a prerelease version of A2A.
dotnet add package A2A --version 0.3.1-preview
                    
NuGet\Install-Package A2A -Version 0.3.1-preview
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="A2A" Version="0.3.1-preview" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="A2A" Version="0.3.1-preview" />
                    
Directory.Packages.props
<PackageReference Include="A2A" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add A2A --version 0.3.1-preview
                    
#r "nuget: A2A, 0.3.1-preview"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package A2A@0.3.1-preview
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=A2A&version=0.3.1-preview&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=A2A&version=0.3.1-preview&prerelease
                    
Install as a Cake Tool

A2A .NET SDK

License NuGet Version

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:

  • 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

alt text

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 of ITaskStore 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: Provides MapA2A() and MapHttpA2A() 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

samples/AgentClient/

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

samples/AgentServer/

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

samples/SemanticKernelAgent/

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

samples/A2ACli/

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

  1. Clone and build the repository:

    git clone https://github.com/a2aproject/a2a-dotnet.git
    cd a2a-dotnet
    dotnet build
    
  2. Run the client samples:

    cd samples/AgentClient
    dotnet run
    

For detailed instructions and advanced scenarios, see the individual README files linked above.

Further Reading

To learn more about the A2A protocol, explore these additional resources:

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 Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  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. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (3)

Showing the top 3 NuGet packages that depend on A2A:

Package Downloads
A2A.AspNetCore

ASP.NET Core extensions for the Agent2Agent (A2A) protocol.

Microsoft.SemanticKernel.Agents.A2A

Defines a concrete Agent based on the A2A Protocol.

Dapr.AI.A2a

Dapr SDK for implementing agent-to-agent operations.

GitHub repositories (4)

Showing the top 4 popular GitHub repositories that depend on A2A:

Repository Stars
microsoft/semantic-kernel
Integrate cutting-edge LLM technology quickly and easily into your apps
dapr/dotnet-sdk
Dapr SDK for .NET
axzxs2001/Asp.NetCoreExperiment
原来所有项目都移动到**OleVersion**目录下进行保留。新的案例装以.net 5.0为主,一部分对以前案例进行升级,一部分将以前的工作经验总结出来,以供大家参考!
Azure-Samples/eShopLite
eShopLite is a set of reference .NET applications implementing an eCommerce site with features like Semantic Search, MCP, Reasoning models and more.
Version Downloads Last Updated
0.3.1-preview 255 9/4/2025
0.1.0-preview.2 11,738 7/31/2025