Skip to main content
Glama

Caduceus: Peer-to-Peer mTLS 1.3 Mesh for Autonomous AI Agents

Go Version License: Apache 2.0 CI Status Static Binary Zero Dependencies

Caduceus is a lightweight, zero-dependency peer-to-peer networking server for the Model Context Protocol (MCP). It enables autonomous AI agents—running in Claude Desktop, Zed, Hermes Agent, or headless scripts—to securely discover, communicate, consult, and delegate tasks to other agents across machines, local networks, or the internet.

Built 100% with the Go standard library, Caduceus compiles into a single 5.9MB static binary with zero external dependencies, zero cloud lock-in, and military-grade mutual TLS 1.3 encryption.


[Local Machine: Laptop/Desktop]                    [Remote Node: Server/Homelab/Pi]
 Claude Desktop / Zed / Hermes                       Hermes / Headless Worker / LLM
          │                                                        ▲
     (stdio MCP)                                              (stdio MCP)
          ▼                                                        │
┌──────────────────────────┐     Mutual TLS 1.3 Mesh      ┌──────────────────────────┐
│     Caduceus Node A      │ ◄──────────────────────────► │     Caduceus Node B      │
│  - Ed25519 Root CA       │      AES-128-GCM / ChaCha20  │  - Ed25519 Root CA       │
│  - Maildir Message Spool │      Direct LAN / VPN / WAN  │  - Maildir Message Spool │
│  - Context Compactor     │                              │  - Greylist OTP Engine   │
└──────────────────────────┘                              └──────────────────────────┘

Why Caduceus?

Today's AI coding and task agents are isolated silos trapped on a single machine or within a single chat session. They cannot offload heavy workloads to dedicated hardware, cannot seek second opinions from specialized peer models, and cannot coordinate long-running jobs without fragile third-party cloud services.

Caduceus provides the decentralized nervous system for multi-agent workflows:

  • True Peer-to-Peer Symmetry: Every node is functionally identical. Nodes can listen (-listen) or connect (-ip). No central coordinators, accounts, or telemetry.

  • Zero-Trust Cryptography (mTLS 1.3): Nodes communicate over mutual TLS 1.3 with hardware-grade Ed25519 keypairs. Untrusted certificates are rejected at the TLS handshake.

  • Human-in-the-Loop Defense (Greylist Engine): Prevent rogue or prompt-injected agents from performing unauthorized actions. Untrusted tasks trigger out-of-band One-Time Passwords (OTP) on the operator console before execution.

  • Crash-Proof Maildir Spooling: Message exchange uses the Unix Maildir standard (tmp/, new/, cur/, quarantine/) with atomic filesystem renames and fsync durability. Zero dropped messages during sudden crashes or power loss.

  • Automatic Context Compactor: Terminal output and large responses are automatically compacted (ANSI code stripping, run-length line deduplication, and head-tail windowing) to prevent context window bloat.

  • Zero External Dependencies: Pure Go standard library. No bloated Node/Python runtimes, no CGo bindings, and no supply chain vulnerabilities.


Related MCP server: zahadun

Real-World Use Cases

  • Heavy Task Offloading: An agent running in Claude Desktop on a lightweight laptop delegates a 45-minute compilation, Docker build, or test suite to an agent on a dedicated server or Raspberry Pi.

  • Peer Code Review & Consultation: An agent finishing a complex refactor automatically requests a second opinion from a peer agent running a different model architecture before committing.

  • Multi-Node Autonomous Swarms: Link multiple specialized agent nodes across your local LAN or WireGuard mesh with mutual attestation.

  • Sandboxed Agent Workers: Run autonomous worker agents in restricted Docker containers while maintaining operator oversight through the greylist authorization engine.


Core Capabilities

  • Bidirectional mTLS 1.3 Transport: Encrypted with Curve25519, Ed25519 certificates, and buffered zero-allocation wire framing.

  • 12 Built-in MCP Tools: Native tools exposed over stdio covering messaging, review, task delegation, status tracking, and capabilities.

  • Zero-Touch Initialization (caduceus init): Generates an Ed25519 Root CA, leaf certificate, config, and mailbox structure in one command.

  • Out-of-Band Trust Federation (caduceus trust): Add, list, or revoke peer CA fingerprints with strict RFC 5280 validation.

  • Policy Authorization Engine (caduceus auth): Define shell-style globbing rules (allow, greylist, deny) with brute-force lockout safeguards.

  • Deterministic Compactor: Built-in 3-stage compaction pipeline keeping tool outputs compact and cost-effective.


Quick Start

1. Build or Install

Compile a stripped, zero-dependency static binary:

make build
# Binary output: bin/caduceus (5.9MB)

2. Bootstrap Local Node Credentials

Initialize the node's local Ed25519 root CA, leaf certificates, and Maildir directories:

./bin/caduceus init

Creates credentials and config in ~/.config/caduceus/ (mode 0700).

3. Run Caduceus

Start a listener node or connect to a peer:

# Node A: Listen for incoming peer connections
./bin/caduceus -listen :8443

# Node B: Connect to Node A across the network
./bin/caduceus -ip 192.168.1.50:8443

Configuration precedence: CLI Flags > config.json > Hardcoded Defaults.


Multi-Node Trust Setup

Caduceus uses a decentralized trust model where nodes establish pairing by cross-importing each other's root CAs out-of-band:

  1. Bootstrap both machines:

    # Run on Laptop (Node A) and Server (Node B):
    caduceus init
  2. Exchange public root certificates: Copy ca.pem from Node A to Node B, and vice versa (via scp, USB, or shared secret).

  3. Import trust:

    # On Node A: Trust Node B's root CA
    caduceus trust add /path/to/node-b-ca.pem
    
    # On Node B: Trust Node A's root CA
    caduceus trust add /path/to/node-a-ca.pem
  4. Verify fingerprints:

    caduceus trust list

Both nodes will now mutually authenticate over mTLS 1.3. To revoke a peer at any time without affecting your local CA:

caduceus trust remove <fingerprint>

Authorization & Human-in-the-Loop Security

Caduceus protects nodes against unauthorized task execution with a built-in authorization engine (internal/auth). When an agent delegates a task via agent_peer_delegate, the action is evaluated against three policy states:

  • Allow: Executes immediately without operator intervention.

  • Greylist (Default): Suspends execution, generates an out-of-band One-Time Password (OTP), notifies the operator console, and holds the task pending authorization.

  • Deny: Rejects the task dispatch immediately.

Managing Policy Rules

# View active policy rules and default action
caduceus auth rules

# Explicitly allow safe read-only queries
caduceus auth allow "system.status" "allow status checks"

# Explicitly block destructive operations
caduceus auth deny "disk.format" "block disk format operations"

# Inspect active authorization challenges waiting for operator approval
caduceus auth pending

Pending challenges automatically lock out and fail closed after 3 incorrect verification attempts. Challenge tokens are displayed exclusively on the operator console and are never leaked to the disk spool.


Connecting MCP Hosts to Caduceus

Caduceus communicates with Model Context Protocol (MCP) clients via standard I/O (stdin/stdout). When launched by an MCP client, Caduceus acts as a local MCP server while transparently managing the encrypted mTLS 1.3 tunnel to the remote peer (-ip).

1. Hermes Agent (~/.hermes/config.yaml)

mcp_servers:
  caduceus:
    command: caduceus
    args:
      - -ip
      - "192.168.1.50:8443"

2. Claude Desktop (claude_desktop_config.json)

  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json

  • Linux: ~/.config/Claude/claude_desktop_config.json

  • Windows: %APPDATA%\Claude\claude_desktop_config.json

Native Binary:

{
  "mcpServers": {
    "caduceus": {
      "command": "caduceus",
      "args": ["-ip", "192.168.1.50:8443"]
    }
  }
}

Sandboxed Container (Podman / Docker):

{
  "mcpServers": {
    "caduceus": {
      "command": "docker",
      "args": [
        "run",
        "-i",
        "--rm",
        "-v",
        "caduceus-data:/home/caduceus/.config/caduceus",
        "caduceus",
        "-ip",
        "192.168.1.50:8443"
      ]
    }
  }
}

3. Zed Editor (~/.config/zed/settings.json)

{
  "context_servers": {
    "caduceus": {
      "command": {
        "path": "caduceus",
        "args": ["-ip", "192.168.1.50:8443"]
      }
    }
  }
}

Running in a Container Sandbox

Caduceus includes a hardened, multi-stage Dockerfile creating an unprivileged, minimal Alpine runtime sandbox (~15MB total):

# 1. Build the container image
docker build -t caduceus .

# 2. Bootstrap node credentials in a persistent volume
docker run --rm -v caduceus-data:/home/caduceus/.config/caduceus caduceus init

# 3. Run listener node
docker run -d --name caduceus-node -p 8443:8443 \
  -v caduceus-data:/home/caduceus/.config/caduceus \
  caduceus -listen :8443

A pre-configured 2-node simulation is available via docker-compose.yml:

docker compose up

Built-in MCP Tools

Caduceus exposes 12 Model Context Protocol tools to connected LLM hosts:

Category

Tool

Description

Direct Messaging

agent_peer_send

Transmit an asynchronous message envelope directly to a peer agent's Maildir inbox.

agent_peer_inbox

Drain and read pending messages, review requests, and task results from the local spool.

Consultative Review

agent_peer_consult

Request a second opinion or advisory analysis on an approach or architecture.

agent_peer_review

Submit code, diffs, or text artifacts to a peer agent for formal review.

agent_peer_reply

Transmit an advisory or review response back to the requesting agent's correlation ticket.

Task Delegation

agent_peer_delegate

Hand off an objective to a remote agent. Evaluated by the remote greylist policy engine.

agent_peer_task_status

Query the real-time lifecycle status (pending, running, completed, failed) of a task.

agent_peer_task_cancel

Signal cancellation for an active delegated task.

agent_peer_task_complete

Terminal state handler recording completion and results into the requester's inbox.

agent_peer_task_progress

Emit intermediate progress updates during long-running background tasks.

Inspection

agent_peer_status

Check physical connection state, latency, and SAN identity of the configured peer.

agent_peer_capabilities

Inspect peer feature sets, supported protocol versions, and host system metadata.


Wire Protocol Specification (v1.0.0 Freeze)

Caduceus enforces a strict, zero-dependency wire protocol:

  1. Transport Layer: Mutual TLS (mTLS) 1.3 exclusively (tls.VersionTLS13). Ed25519 signatures embedded in RFC 5280 compliant X.509 v3 certificates (KeyUsageCertSign).

  2. Framing: Newline-delimited (\n) JSON-RPC 2.0 streaming envelopes over raw TLS sockets with buffered I/O.

  3. Handshake Sequence:

    • Client sends caduceus/handshake carrying version, supported features (messaging, consultative, tasks), and architecture metadata (arch, host, os).

    • Server verifies major SemVer compatibility and required capabilities, replying with local capabilities.

    • Both nodes transition to StateActive and start background keepalive ping monitors.

  4. Tool Schemas: All 12 MCP tool interfaces and argument definitions are frozen under Semantic Versioning 1.0.0.


Development & Quality Gates

Caduceus maintains a strict clean-code standard with zero external modules in go.mod.

# Run all unit and integration tests with race detection
make test

# Run Go static analysis
make vet

# Check code formatting
make fmt-check

# Compile production static stripped binary
make build

License

Apache License 2.0. See LICENSE for full details.

Available Tools

12 tools
agent_peer_capabilitiesA

Inspect the negotiated capabilities, features, and metadata of the connected peer agent

Inputs: no named parameters.

agent_peer_consultC

Consult a peer agent for a question or guidance

Inputs: query (required), context.

agent_peer_delegateB

Delegate a task or job to the connected peer agent for execution

Inputs: objective (required), context, task_id, timeout_sec.

agent_peer_inboxB

Check inbox for messages or tasks from a peer agent

Inputs: no named parameters.

agent_peer_replyC

Response to a peer agent's consult or review request

Inputs: response (required), ticket_id (required), status.

agent_peer_reviewB

Request review of code diffs, configuration files, or architectural text

Inputs: artifact (required), rubric.

agent_peer_sendC

Send a message or task to the connected peer agent

Inputs: message (required).

agent_peer_statusB

Check the active mTLS connection state to the peer agent

Inputs: no named parameters.

agent_peer_task_cancelC

Cancel or abort an active task running on the peer agent

Inputs: task_id (required), reason.

agent_peer_task_completeB

Mark an active delegated task as completed with results and optional artifacts

Inputs: result (required), task_id (required), artifacts.

agent_peer_task_progressC

Update progress notes on an active delegated task

Inputs: task_id (required), progress (required).

agent_peer_task_statusC

Query the status, progress, result, and artifacts of a delegated task

Inputs: task_id (required).

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    B3.2/5.0

    Scored across 12 tools

    Disambiguation4/5

    Each tool targets a distinguishable action: raw messaging (send/inbox/reply), connection introspection (status/capabilities), and task lifecycle (delegate/task_status/task_cancel/task_complete/task_progress). The main ambiguity is that agent_peer_send claims to send 'a message or task' while agent_peer_delegate and agent_peer_consult also cover tasks/requests, so an agent may hesitate between send, consult, and delegate. agent_peer_reply is also only loosely bounded (consult vs review responses).

    Naming Consistency4/5

    All twelve tools share the agent_peer_ prefix and snake_case throughout, with a recognizable agent_peer_task_* sub-family for delegated tasks. Minor deviations: the task sub-family is nested while other verbs are flat, so 'status' appears both as agent_peer_status (connection) and agent_peer_task_status (task), which is predictable but slightly inconsistent in structure.

    Tool Count5/5

    Twelve tools is squarely in the well-scoped range and each tool maps to a concrete peer-interaction operation. Nothing appears redundant enough to be dropped, and the split between messaging, introspection, and task lifecycle is proportionate to the domain.

    Completeness4/5

    Coverage is solid for a single-peer mTLS link: connection state, capability negotiation, messaging, consult, review, delegation, and a full task lifecycle (status/progress/complete/cancel). Gaps exist around peer discovery/listing, connect/disconnect, and message/history retrieval or acknowledgment, but core workflows have no dead ends.

    Maintenance

    ActivityActive
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      A
      quality
      A
      maintenance
      The infrastructure for AI teams: a self-hosted server that gives a fleet of agents shared semantic memory, tasks, direct messages, and session handoff. Any agent that speaks HTTP participates: Claude Code, AutoGen, raw API scripts, anything.
      47
      9
      MIT
    • A
      license
      B
      quality
      B
      maintenance
      Enables Claude Code and OpenCode agents to delegate tasks to peer machines over a self-hosted A2A mesh, using mTLS identity and executing via local CLIs or scripts.
      8
      Apache 2.0
    • A
      license
      B
      quality
      B
      maintenance
      Enables MCP-capable coding agents to discover peers, send messages, and read inboxes through a small self-hosted relay on your LAN or VPN, including role-based fan-out to teams. Incoming messages can wake idle agent sessions so one agent can hand work to another and get the result back without human typing.
      7
      112 npm
      10
      Apache 2.0
    • A
      license
      Not graded
      quality
      B
      maintenance
      Open coordination hub for autonomous AI agents: Ed25519-signed messages, client-side end-to-end encrypted channels, public task bounties, an MCP server, and a libp2p mesh with an auditable ledger.
      3
      Apache 2.0