docs/cli/acp-mode.md
ACP (Agent Client Protocol) mode is a special operational mode of Gemini CLI designed for programmatic control, primarily for IDE and other developer tool integrations. It uses a JSON-RPC protocol over stdio to communicate between Gemini CLI agent and a client.
To start Gemini CLI in ACP mode, use the --acp flag:
gemini --acp
ACP is an open protocol that standardizes how AI coding agents communicate with code editors and IDEs. It addresses the challenge of fragmented distribution, where agents traditionally needed custom integrations for each client. With ACP, developers can implement their agent once, and it becomes compatible with any ACP-compliant editor.
For a comprehensive introduction to ACP, including its architecture and benefits, refer to the official ACP Introduction documentation.
The ACP Agent Registry simplifies the distribution and management of ACP-compatible agents across various IDEs. Gemini CLI is an ACP-compatible agent and can be found in this registry.
For more general information about the registry, and how to use it with specific IDEs like JetBrains and Zed, refer to the IDE Integration documentation.
You can also find more information on the official ACP Agent Registry page.
ACP mode establishes a client-server relationship between your tool (the client) and Gemini CLI (the server).
The core of the ACP implementation can be found in
packages/cli/src/acp/acpClient.ts.
ACP can be used with the Model Context Protocol (MCP). This lets an ACP client (like an IDE) expose its own functionality as "tools" that the Gemini model can use.
initialize handshake, the client provides the connection
details for its MCP server.This mechanism lets for a powerful, two-way integration where the agent can
leverage the IDE's capabilities to perform tasks. The MCP client logic is in
packages/core/src/tools/mcp-client.ts.
The ACP protocol exposes a number of methods for ACP clients (for example IDEs) to control Gemini CLI.
initialize: Establishes the initial connection and lets the client to
register its MCP server.authenticate: Authenticates the user.newSession: Starts a new chat session.loadSession: Loads a previous session.prompt: Sends a prompt to the agent.cancel: Cancels an ongoing prompt.setSessionMode: Allows changing the approval level for tool calls (for
example, to auto-approve).unstable_setSessionModel: Changes the model for the current session.ACP includes a proxied file system service. This means that when the agent needs to read or write files, it does so through the ACP client. This is a security feature that ensures the agent only has access to the files that the client (and by extension, the user) has explicitly allowed.
You can get insights into the ACP communication and the agent's behavior through debugging logs and telemetry.
To enable general debugging logs, start Gemini CLI with the --debug flag:
gemini --acp --debug
For more detailed telemetry, you can use the following environment variables to capture telemetry data to a file:
GEMINI_TELEMETRY_ENABLED=trueGEMINI_TELEMETRY_TARGET=localGEMINI_TELEMETRY_OUTFILE=/path/to/your/log.jsonThis will write a JSON log file containing detailed information about all the
events happening within the agent, including ACP requests and responses. The
integration test integration-tests/acp-telemetry.test.ts provides a working
example of how to set this up.