AcpSdk 1.2.0

dotnet add package AcpSdk --version 1.2.0
                    
NuGet\Install-Package AcpSdk -Version 1.2.0
                    
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="AcpSdk" Version="1.2.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="AcpSdk" Version="1.2.0" />
                    
Directory.Packages.props
<PackageReference Include="AcpSdk" />
                    
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 AcpSdk --version 1.2.0
                    
#r "nuget: AcpSdk, 1.2.0"
                    
#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 AcpSdk@1.2.0
                    
#: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=AcpSdk&version=1.2.0
                    
Install as a Cake Addin
#tool nuget:?package=AcpSdk&version=1.2.0
                    
Install as a Cake Tool

ACP SDK for .NET

A modern, AOT-compatible .NET SDK for the Agent Client Protocol (ACP) - enabling seamless communication between AI coding assistants and IDE extensions using JSON-RPC 2.0.

Overview

ACP SDK provides a robust implementation of the Agent Client Protocol, built on top of Microsoft's StreamJsonRpc library. This unified SDK enables developers to:

  • Build IDE Extensions: Create Visual Studio, VS Code, or other IDE extensions that communicate with AI coding assistants
  • Implement AI Agents: Build AI agent backends that respond to client requests
  • Bidirectional Communication: Full support for requests, notifications, and streaming updates

All components (Client, Server, Protocol) are integrated into a single, lightweight package (AcpSdk).

Architecture

┌─────────────────┐                      ┌─────────────────┐
│    IDE/Client   │                      │    AI Agent     │
│                 │                      │                 │
│  ┌───────────┐  │   StreamJsonRpc      │  ┌───────────┐  │
│  │AcpSdk.Client│◄─┼──────────────────────┼─►│AcpSdk.Server│  │
│  └───────────┘  │   (JSON-RPC 2.0)     │  └───────────┘  │
│                 │                      │                 │
│  ┌──────────────┐  │                      │  ┌──────────────┐  │
│  │AcpSdk.Protocol│ │                      │  │AcpSdk.Protocol│ │
│  └──────────────┘  │                      │  └──────────────┘  │
└─────────────────┘                      └─────────────────┘

Namespaces

Namespace Description
AcpSdk.Protocol Core protocol definitions, schema models, and JSON serialization context (AOT-compatible)
AcpSdk.Client Client-side implementation for connecting to AI agents
AcpSdk.Server Server-side (agent) implementation for handling client requests

Features

  • AOT Compatible: Full support for Native AOT compilation using source generators
  • StreamJsonRpc Integration: Built on Microsoft's production-grade JSON-RPC library
  • Multi-target: Supports .NET 8.0, .NET 9.0, and .NET Standard 2.1
  • Type-safe: Strongly-typed request/response models with polymorphic serialization
  • Streaming Updates: Real-time session updates via notifications
  • Terminal Support: Full terminal emulation protocol
  • MCP Integration: Support for Model Context Protocol servers
  • HTTP/SSE Transport: Full support for HTTP POST/SSE communication (ideal for web/cloud agents)

Installation

# Install the SDK package (includes Client, Server, and Protocol)
dotnet add package AcpSdk

For projects that support PackageReference, copy this XML node into the project file to reference the package:

<PackageReference Include="AcpSdk" Version="1.2.0" />

Quick Start

Client Usage (IDE Extension)

using AcpSdk.Client;
using AcpSdk.Protocol.Abstractions;
using AcpSdk.Protocol.Core.Constants;
using AcpSdk.Protocol.Models;
using AcpSdk.Protocol.Models.Contents;
using AcpSdk.Protocol.Models.Files;
using AcpSdk.Protocol.Models.Initialize;
using AcpSdk.Protocol.Models.Prompts;
using AcpSdk.Protocol.Models.Session;

// Implement the client handler for incoming requests from the agent
public class MyClientHandler : IAcpClient
{
    public ValueTask<ReadTextFileResponse> ReadTextFileAsync(ReadTextFileRequest request, CancellationToken ct)
    {
        var content = File.ReadAllText(request.Path);
        return ValueTask.FromResult(new ReadTextFileResponse { Content = content });
    }

    public ValueTask OnSessionNotificationAsync(SessionNotification notification, CancellationToken ct)
    {
        // Handle streaming updates
        Console.WriteLine($"Session update: {notification.Update}");
        return ValueTask.CompletedTask;
    }

    // ... implement other methods
}

// Connect to an agent process
var process = new Process
{
    StartInfo = new ProcessStartInfo("path/to/agent")
    {
        RedirectStandardInput = true,
        RedirectStandardOutput = true,
        UseShellExecute = false
    }
};
process.Start();

var clientHandler = new MyClientHandler();
// Uses implicit CreateNewLineDelimited (NDJSON) framing by default for processes
var connection = AcpClientConnection.CreateForProcess(process, clientHandler);
connection.StartListening();

// Initialize the connection
var initResponse = await connection.InitializeAsync(new InitializeRequest
{
    ProtocolVersion = ProtocolConstants.ProtocolVersion,
    ClientInfo = new Implementation { Name = "MyIDE", Version = "1.0.0" }
});

// Create a session
var session = await connection.NewSessionAsync(new NewSessionRequest
{
    Cwd = Environment.CurrentDirectory,
    McpServers = []
});

// Send a prompt
var response = await connection.PromptAsync(new PromptRequest
{
    SessionId = session.SessionId,
    Prompt = [new TextContentBlock { Text = "Hello, agent!" }]
});

Remote Agent Connection (HTTP/SSE)

For connecting to a remote agent or a containerized agent that exposes HTTP/SSE endpoints:

using AcpSdk.Client;
using System.Net.Http;

// ... Create your client handler ...

// Connect to an agent via HTTP/SSE
// The SDK will use POST /rpc for sending and GET /events for receiving
var httpClient = new HttpClient();
var connection = AcpClientConnectionExtensions.CreateHttpSse(
    "http://localhost:5000/agent", 
    httpClient, 
    clientHandler
);

// Start listening for SSE events
// connection.StartListening() is called automatically for SSE, so you can proceed to InitializeAsync
var initResponse = await connection.InitializeAsync(new InitializeRequest { ... });

Server Usage (AI Agent)

using AcpSdk.Server;
using AcpSdk.Protocol.Abstractions;
using AcpSdk.Protocol.Core.Constants;
using AcpSdk.Protocol.Models;
using AcpSdk.Protocol.Models.Authentication;
using AcpSdk.Protocol.Models.Initialize;
using AcpSdk.Protocol.Models.Prompts;

// Implement the agent handler
public class MyAgentHandler : IAcpAgent
{
    public ValueTask<InitializeResponse> InitializeAsync(InitializeRequest request, CancellationToken ct)
    {
        return ValueTask.FromResult(new InitializeResponse
        {
            ProtocolVersion = ProtocolConstants.ProtocolVersion,
            AgentInfo = new Implementation { Name = "MyAgent", Version = "1.0.0" },
            AuthMethods = [new AuthMethod { Id = "none", Label = "No Auth" }]
        });
    }

    public ValueTask<PromptResponse> PromptAsync(PromptRequest request, CancellationToken ct)
    {
        // Process the prompt and stream updates
        return ValueTask.FromResult(new PromptResponse
        {
            StopReason = StopReason.EndTurn
        });
    }

    // ... implement other methods
}

// Start the server (Standard Input/Output = NDJSON)
var agentHandler = new MyAgentHandler();
var connection = AcpServerConnection.CreateForConsole(agentHandler);
connection.StartListening();

// Wait for the connection to close
await connection.Completion;

Configuration

The SDK provides a simple way to load agent configuration from a JSON file using AgentConfigurationLoader. This is useful for switching between local and remote agents without changing code.

using AcpSdk.Client.Configuration;
using AcpSdk.Client.Factories;

// Load configuration
var config = AgentConfigurationLoader.Load("agent.config.json");

// Create connection using the factory
// This automatically handles validation and local/remote logic
var connection = await AcpClientFactory.CreateFromConfigAsync(config, clientHandler);

connection.StartListening();

Configuration File Example (agent.config.json)

Local Agent:

{
  "type": "local",
  "local": {
    "command": "path/to/agent.exe",
    "arguments": ["--verbose"],
    "workingDirectory": "."
  }
}

Remote Agent:

{
  "type": "remote",
  "remote": {
    "url": "http://localhost:5000/agent",
    "transport": "sse"
  }
}

Protocol Methods

Agent Methods (Client → Agent)

Method Description
initialize Initialize connection and exchange capabilities
authenticate Authenticate using a specific method
session/new Create a new session
session/load Load an existing session
session/prompt Send a prompt to the agent
session/cancel Cancel an ongoing operation
session/set_mode Change the session mode

Client Methods (Agent → Client)

Method Description
fs/read_text_file Read file contents
fs/write_text_file Write file contents
session/request_permission Request user permission
session/update Stream session updates (notification)
terminal/* Terminal operations

Session Updates

The SDK supports streaming session updates including:

  • user_message_chunk - Echoed user input
  • agent_message_chunk - Agent response chunks
  • agent_thought_chunk - Agent reasoning (when visible)
  • tool_call - Tool invocation details
  • tool_call_update - Incremental tool progress
  • plan - Agent planning information
  • available_commands_update - Available slash commands
  • current_mode_update - Current session mode

Content Types

The protocol supports multiple content types through polymorphic serialization:

  • Text - Plain text content
  • Image - Base64-encoded images
  • Audio - Audio data
  • Resource - MCP resource references
  • Resource Link - Links to MCP resources

License

MIT License - see LICENSE for details.

Contributing

Contributions are welcome! Please read our contributing guidelines before submitting PRs.

Support

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 netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.1 is compatible. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen 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

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
1.2.0 123 2/4/2026
1.1.0 127 1/8/2026
1.0.1 114 1/7/2026
1.0.0 115 1/6/2026