|
| 1 | +# ACP NATS Stdio |
| 2 | + |
| 3 | +Translates [Agent Client Protocol](https://agentclientprotocol.com) (ACP) messages between stdio and [NATS](https://nats.io), letting IDEs and CLI tools talk to distributed agent backends without a direct network connection from the client. |
| 4 | + |
| 5 | +For managed NATS infrastructure in production, we recommend <a href="https://synadia.com"><img src="./assets/synadia-logo.png" alt="Synadia" width="20" style="vertical-align: middle;"> Synadia</a>. |
| 6 | + |
| 7 | +```mermaid |
| 8 | +graph LR |
| 9 | + A[IDE] <-->|stdio| B[acp-nats-stdio] |
| 10 | + B <-->|NATS| C[Backend] |
| 11 | +``` |
| 12 | + |
| 13 | +## Features |
| 14 | + |
| 15 | +- Bidirectional ACP bridge with request forwarding |
| 16 | +- OpenTelemetry integration (logs, metrics, traces) |
| 17 | +- Graceful shutdown (SIGINT/SIGTERM) |
| 18 | +- Custom prefix support for multi-tenancy |
| 19 | + |
| 20 | +## Quick Start |
| 21 | + |
| 22 | +```bash |
| 23 | +docker run -p 4222:4222 nats:latest |
| 24 | + |
| 25 | +cargo build --release -p acp-nats-stdio |
| 26 | + |
| 27 | +./target/release/acp-nats-stdio |
| 28 | +``` |
| 29 | + |
| 30 | +## Configuration |
| 31 | + |
| 32 | +### ACP |
| 33 | + |
| 34 | +| Variable | Description | Default | |
| 35 | +|----------|-------------|---------| |
| 36 | +| `ACP_PREFIX` | Subject prefix for multi-tenancy | `acp` | |
| 37 | +| `ACP_OPERATION_TIMEOUT_SECS` | Timeout for NATS request/reply operations | built-in default | |
| 38 | +| `ACP_PROMPT_TIMEOUT_SECS` | Timeout for prompt round-trips | built-in default | |
| 39 | +| `ACP_NATS_CONNECT_TIMEOUT_SECS` | NATS connection timeout | `10` | |
| 40 | + |
| 41 | +CLI flag `--acp-prefix` overrides `ACP_PREFIX`. |
| 42 | + |
| 43 | +### NATS |
| 44 | + |
| 45 | +| Variable | Description | Default | |
| 46 | +|----------|-------------|---------| |
| 47 | +| `NATS_URL` | Server URL(s), comma-separated for failover | `localhost:4222` | |
| 48 | + |
| 49 | +### NATS Authentication |
| 50 | + |
| 51 | +Resolved in priority order — the first match wins: |
| 52 | + |
| 53 | +| Priority | Variable(s) | Method | |
| 54 | +|----------|-------------|--------| |
| 55 | +| 1 | `NATS_CREDS` | Credentials file path | |
| 56 | +| 2 | `NATS_NKEY` | NKey seed | |
| 57 | +| 3 | `NATS_USER` + `NATS_PASSWORD` | Username/password | |
| 58 | +| 4 | `NATS_TOKEN` | Token | |
| 59 | + |
| 60 | +If none are set, the connection is unauthenticated. |
| 61 | + |
| 62 | +### Observability |
| 63 | + |
| 64 | +| Variable | Description | |
| 65 | +|----------|-------------| |
| 66 | +| `RUST_LOG` | Tracing filter directive (default: `info`) | |
| 67 | +| `ACP_LOG_DIR` | Directory for file-based logging | |
| 68 | + |
| 69 | +### OpenTelemetry |
| 70 | + |
| 71 | +Traces, metrics, and logs are exported over HTTP. The following [OTLP environment variables](https://opentelemetry.io/docs/specs/otel/protocol/exporter/) are supported: |
| 72 | + |
| 73 | +| Variable | Description | |
| 74 | +|----------|-------------| |
| 75 | +| `OTEL_EXPORTER_OTLP_ENDPOINT` | Collector base URL (e.g. `http://localhost:4318`) | |
| 76 | +| `OTEL_EXPORTER_OTLP_HEADERS` | Custom headers, comma-separated `key=value` pairs (e.g. auth tokens) | |
| 77 | +| `OTEL_EXPORTER_OTLP_TIMEOUT` | Export timeout in milliseconds (default: `10000`) | |
| 78 | +| `OTEL_RESOURCE_ATTRIBUTES` | Additional resource attributes, comma-separated `key=value` pairs | |
| 79 | + |
| 80 | +`OTEL_SERVICE_NAME` is hardcoded to `acp-nats-stdio` and cannot be overridden. |
0 commit comments