acpd logo

acpd

English · 简体中文

The platform-neutral Dart SDK for the Agent Client Protocol (ACP).

Features

  • Every stable ACP v1 schema type and method.
  • Single and batch JSON-RPC frames with ordered grouped responses.
  • Concurrent bidirectional requests, notifications, extension methods, timeouts, and cooperative cancellation.
  • AgentRole and ClientRole builders with typed handlers and contexts for every stable method, request timeouts, and cooperative cancellation.
  • High-level Session create/load/resume/close lifecycle with streamed updates, live modes, config options, and prompt results.
  • Pure Dart: VM, Flutter, Web, and WASM; no dart:io dependency.

Use acpd_io for stdio/process transports, acpd_http for HTTP/SSE/WebSocket, and acpd_test for test peers.

Usage

import 'package:acpd/acpd.dart';

Future<PromptTurnResult> promptAgent(
  Transport transport,
  String text,
) async {
  final client = ClientRole().connect(transport);
  try {
    await client.client.initialize(
      const InitializeRequest(
        protocolVersion: ProtocolVersion.v1,
        clientInfo: Implementation(name: 'my-client', version: '1.0.0'),
      ),
    );
    final session = await Session.create(
      client,
      const NewSessionRequest(cwd: '.', mcpServers: []),
    );
    try {
      return await session.sendPrompt(
        <ContentBlock>[TextContentBlock(text: text)],
      );
    } finally {
      session.dispose();
    }
  } finally {
    await client.close();
  }
}

See the package example/ and the full workspace guide.

License

Apache License 2.0. See LICENSE.

Libraries

acpd
The acpd library — Dart SDK for the Agent Client Protocol (ACP).