VTCode ACP Client
HTTP-based Agent Communication Protocol (ACP) client library for inter-agent communication in distributed agent systems.
Features
✓ REST-based Communication - Standard HTTP protocol, no special SDKs required ✓ Agent Discovery - Find agents by capability or ID ✓ Sync & Async - Both synchronous and asynchronous request handling ✓ Health Monitoring - Ping agents to check status ✓ Message Serialization - Type-safe ACP message handling ✓ Registry Management - In-memory agent registry with lifecycle management ✓ Error Handling - Comprehensive error types for debugging
Quick Start
Add to Cargo.toml
[]
= { = "../vtcode-acp-client" }
Basic Usage
use ;
use json;
async
Module Overview
Core Components
AcpClient
Main client for agent communication.
// Create a new client
let client = new?;
// Synchronous call (waits for response)
let result = client.call_sync.await?;
// Asynchronous call (returns message_id immediately)
let msg_id = client.call_async.await?;
// Health check
let is_online = client.ping.await?;
// Discover remote agent
let agent_info = client.discover_agent.await?;
AgentRegistry
In-memory registry of available agents.
let registry = client.registry;
// Register agent
registry.register.await?;
// Find agent
let agent = registry.find.await?;
// Find by capability
let agents = registry.find_by_capability.await?;
// List all/online agents
let all = registry.list_all.await?;
let online = registry.list_online.await?;
// Update status
registry.update_status.await?;
AcpMessage
Type-safe message handling.
// Create request
let msg = request;
// Serialize to JSON
let json = msg.to_json?;
// Deserialize from JSON
let msg = from_json?;
Error Handling
use AcpError;
match client.call_sync.await
Architecture
User Code
│
└─► AcpClient
├─► HTTP Communication (reqwest)
├─► Message Serialization (serde_json)
└─► AgentRegistry
└─► In-memory HashMap<String, AgentInfo>
Message Protocol
Request
Response
Remote Agent Requirements
For an agent to be callable, it must implement:
1. POST /messages
Handle ACP requests and return responses.
app.post
2. GET /metadata
Return agent discovery information.
app.get
3. GET /health
Simple health check endpoint.
app.get
Configuration
Build client with custom timeout:
use Duration;
use AcpClientBuilder;
let client = new
.with_timeout
.build?;
Testing
Run tests:
Run example:
Performance
- Message serialization: <1ms
- Local registry lookup: O(1)
- HTTP timeout: Configurable (default 30s)
- Async overhead: Minimal (uses tokio)
Security Considerations
⚠️ Current Implementation:
- HTTP (not HTTPS) by default
- No authentication/authorization
- No message encryption
- Messages logged with tracing
🔒 Recommended for Production:
- Use HTTPS with certificate pinning
- Implement JWT or mTLS authentication
- Add message signing and encryption
- Implement rate limiting
- Add audit logging
- Use VPN/private networks
Roadmap
- HTTPS/TLS support
- Authentication plugins (JWT, mTLS)
- Message encryption
- Automatic retries with exponential backoff
- Circuit breaker pattern
- Message queuing
- OpenTelemetry integration
- Metrics collection
Integration with VTCode
The ACP client is exposed to the main agent through three MCP tools:
- acp_call - Call remote agents
- acp_discover - Discover agents
- acp_health - Check agent health
See ACP_INTEGRATION.md for integration details.
References
License
MIT