| 1 | # AgentClientProtocol for C# |
| 2 | Unofficial C# SDK for ACP (Agent Client Protocol) clients and agents |
| 3 | |
| 4 | [](https://www.nuget.org/packages/AgentClientProtocol) |
| 5 | [](https://github.com/nuskey8/acp-csharp/releases) |
| 6 | [](LICENSE) |
| 7 | |
| 8 | ## What's Agent Client Protocol? |
| 9 | |
| 10 | Agent Client Protocol is a protocol proposed by Zed to standardize communication between code editors/IDEs and coding agents. |
| 11 | |
| 12 | > ACP solves this by providing a standardized protocol for agent-editor communication, similar to how the Language Server Protocol (LSP) standardized language server integration. |
| 13 | |
| 14 | Please refer to [the official documentation](https://agentclientprotocol.com/) for details. |
| 15 | |
| 16 | ## Installation |
| 17 | |
| 18 | ### .NET CLI |
| 19 | |
| 20 | ```ps1 |
| 21 | dotnet add package AgentClientProtocol |
| 22 | ``` |
| 23 | |
| 24 | ### Package Manager |
| 25 | |
| 26 | ```ps1 |
| 27 | Install-Package AgentClientProtocol |
| 28 | ``` |
| 29 | |
| 30 | ## Quick Start |
| 31 | |
| 32 | ### Client |
| 33 | |
| 34 | ```cs |
| 35 | class ExampleClient : IAcpClient { ... } |
| 36 | ``` |
| 37 | |
| 38 | ```cs |
| 39 | var client = new ExampleClient(); |
| 40 | |
| 41 | using var conn = new ClientSideConnection( _ => client, reader, writer); |
| 42 | |
| 43 | conn.Open(); |
| 44 | |
| 45 | var initResult = await conn.InitializeAsync(new InitializeRequest |
| 46 | { |
| 47 | ProtocolVersion = 1, |
| 48 | ClientCapabilities = new ClientCapabilities |
| 49 | { |
| 50 | Fs = new FileSystemCapability |
| 51 | { |
| 52 | ReadTextFile = true, |
| 53 | WriteTextFile = true |
| 54 | } |
| 55 | } |
| 56 | }); |
| 57 | |
| 58 | Console.WriteLine($"Connected to agent (protocol v{initResult.ProtocolVersion})"); |
| 59 | ``` |
| 60 | |
| 61 | ### Agent |
| 62 | |
| 63 | ```cs |
| 64 | class ExampleClient : IAcpAgent { ... } |
| 65 | ``` |
| 66 | |
| 67 | ```cs |
| 68 | var agent = new ExampleAgent(); |
| 69 | using var conn = new AgentSideConnection(agent, reader, writer); |
| 70 | conn.Open(); |
| 71 | |
| 72 | await Task.Delay(-1); |
| 73 | ``` |
| 74 | |
| 75 | ## License |
| 76 | |
| 77 | This library is under the [MIT License](LICENSE). |