Skip to main content
This page documents the Palyra CLI’s implementation of agent-to-system protocols, specifically the Agent Control Protocol (ACP) and the Model Context Protocol (MCP). These bridges allow external entities (IDEs, autonomous agents, or scripts) to interact with the Palyra daemon using standardized communication patterns while maintaining the system’s security and policy posture.

Overview

Palyra provides two primary bridging mechanisms for external agents:
  1. ACP (Agent Control Protocol): A stateful, session-oriented bridge designed for IDE integrations and persistent agent interactions. It supports complex session lifecycle management and inline approval mediation crates/palyra-cli/data/docs/cli-v1-acp-shim.md#50-54.
  2. MCP (Model Context Protocol): A stateless stdio facade following the 2024-11-05 protocol version crates/palyra-cli/src/commands/mcp.rs#10-11. It is optimized for tool-driven clients that expect a tools/list and tools/call interface crates/palyra-cli/data/docs/cli-mcp-interop-playbook.md#38-41.

Agent Control Protocol (ACP) Bridge

The ACP bridge is implemented in crates/palyra-cli/src/acp_bridge.rs. It acts as a translator between the JSON-RPC based ACP protocol and Palyra’s internal gRPC-based GatewayService.

Bridge Architecture and Data Flow

The bridge maintains a BridgeState to map ACP session identifiers to Palyra’s internal ULID-based session identifiers crates/palyra-cli/src/acp_bridge.rs#38-44. ACP Bridge Component Interaction Sources: crates/palyra-cli/src/acp_bridge.rs#90-97, crates/palyra-cli/src/client/runtime.rs#9-12

Session Management and Metadata

ACP allows clients to pass _meta fields to override session behavior. The bridge parses these in session_overrides crates/palyra-cli/src/acp_bridge.rs#197-205:

Model Context Protocol (MCP) Facade

The MCP implementation provides a standard mcp serve command that exposes Palyra’s capabilities as a set of discrete tools crates/palyra-cli/src/commands/mcp.rs#22-28.

MCP Tool Inventory

The LiveMcpBackend implements the following tools crates/palyra-cli/src/commands/mcp.rs#80-108:
Tool NameTypeDescription
sessions_listReadLists available chat sessions crates/palyra-cli/src/commands/mcp.rs#13-13.
session_transcript_readReadRetrieves the full history of a session crates/palyra-cli/src/commands/mcp.rs#14-14.
session_exportReadExports session to JSON or Markdown crates/palyra-cli/src/commands/mcp.rs#15-15.
memory_searchReadQueries the vector/FTS5 memory store crates/palyra-cli/src/commands/mcp.rs#16-16.
approvals_listReadLists pending or past tool approvals crates/palyra-cli/src/commands/mcp.rs#17-17.
session_createMutationInitializes a new agent session crates/palyra-cli/src/commands/mcp.rs#18-18.
session_promptMutationSends a prompt to an agent (triggers RunStream) crates/palyra-cli/src/commands/mcp.rs#19-19.
approval_decideMutationSubmits a decision for a pending tool approval crates/palyra-cli/src/commands/mcp.rs#20-20.

Security Posture

The MCP server enforces two primary flags to restrict agent behavior:
  1. --read-only: Disables all mutation tools crates/palyra-cli/src/args/mcp.rs#13-14.
  2. --allow-sensitive-tools: Explicitly enables tools that might perform destructive actions or egress crates/palyra-cli/src/args/mcp.rs#15-16.

Operator and Runtime Clients

The CLI uses specialized client modules to communicate with the daemon.

OperatorRuntime

Located in crates/palyra-cli/src/client/operator.rs, this class manages high-level operations like starting run streams and handling interactive session logic crates/palyra-cli/src/client/operator.rs#15-17. Key function: start_run_stream crates/palyra-cli/src/client/operator.rs#137-140

GatewayRuntimeClient

Located in crates/palyra-cli/src/client/runtime.rs, this is the low-level gRPC wrapper for the GatewayServiceClient crates/palyra-cli/src/client/runtime.rs#9-12. It handles raw message construction and metadata injection (e.g., principal, device ID, and auth tokens) crates/palyra-cli/src/client/runtime.rs#84-88.

Agent Command Reference

The agent command family provides the CLI-native way to interact with agents without using ACP/MCP bridges.

Interactive Command Flow

Sources: crates/palyra-cli/src/commands/agent.rs#115-136, crates/palyra-cli/src/client/operator.rs#112-118, crates/palyra-cli/src/client/operator.rs#137-146

Session Management Commands

The sessions command family (crates/palyra-cli/src/commands/sessions.rs) provides administrative control over agent history: Sources: crates/palyra-cli/src/commands/sessions.rs#1-46, crates/palyra-cli/src/client/operator.rs#101-135