What is ACP (Agent Client Protocol) and How It Integrates with Zed and JetBrains

ACP (Agent Client Protocol) is a lightweight JSON-RPC protocol that enables editors like Zed and JetBrains IDEs to act as clients for language-model-driven agents, communicating over stdin/stdout without requiring network services.

In the kimi-code repository by MoonshotAI, ACP serves as the bridge between the Kimi Code CLI and external editors. The protocol allows any ACP-compatible client to spawn a subprocess, send JSON-RPC requests, and receive structured responses including tool calls, session state, and streaming output. This architecture makes Kimi Code IDE-agnostic while providing deep integration capabilities for modern development environments.

Understanding the ACP Architecture

The ACP implementation in Kimi Code centers on the @moonshot-ai/acp-adapter package. This adapter runs the Kimi Code CLI as an ACP server over stdin/stdout, exposing RPC methods that conform to the ACP 0.23 specification.

When you launch the CLI with the kimi acp sub-command (implemented in apps/kimi-code/src/cli/sub/acp.ts), it initializes the protocol layer:

  1. Starts the ACP server (runAcpServer) from the adapter package.
  2. Listens for JSON-RPC requests on the process's standard streams.
  3. Bridges requests to internal Kimi Code services including sessions, transcript management, and tool invocation.

Because communication happens purely over stdio, ACP eliminates the need for background daemons or TCP ports. Any editor capable of spawning a subprocess can drive a full Kimi Code session.

Core Protocol Methods

The adapter exposes several key RPC methods that clients invoke:

  • createSession – Initializes a new conversation context with model selection.
  • sendPrompt – Transmits user input to the language model and streams responses.
  • runTool – Executes approved tool calls and returns structured results.

These methods enable complete agent workflows including plan review, tool approval, and state inspection directly within the editor UI.

Zed IDE Integration

Zed provides native ACP support, making it straightforward to integrate Kimi Code. The configuration requires adding an agent server entry to Zed's global settings.

Configuring Zed for Kimi Code

Add the following to your ~/.config/zed/settings.json:

{
  "agent_servers": {
    "kimi": {
      "type": "terminal",
      "command": "kimi acp",
      "env": {}
    }
  }
}

The "type": "terminal" designation tells Zed to launch kimi acp as a subprocess. The empty env object allows Zed to inject its default environment variables automatically.

Once configured, open the Agent panel in Zed and start a new conversation. Zed launches the CLI subprocess, connects via ACP, and renders the session UI—including the "thinking" picker and real-time tool call updates—using native interface elements.

The mapping between Zed's UI concepts and ACP schema resides in packages/acp-adapter/src/config-options.ts, which translates editor-specific interactions into generic protocol messages.

JetBrains IDE Integration

JetBrains IDEs expose an AI Chat feature that consumes ACP, allowing Kimi Code integration through Run/Debug configurations rather than JSON settings files.

Setting Up JetBrains AI Chat

  1. Create a Run/Debug configuration with:

    • Program: kimi
    • Arguments: acp
    • Working directory: $PROJECT_ROOT
  2. In the AI Chat settings, point the Agent field to this configuration.

  3. JetBrains launches the subprocess when opening an AI Chat session, driving Kimi Code via the same JSON-RPC channel used by Zed.

The adapter handles JetBrains-specific expectations through packages/acp-adapter/src/auth-methods.ts, which manages authentication flows including the AuthMethodTerminal path required by JetBrains' security model.

Practical Implementation Examples

Launching ACP Standalone

To run Kimi Code in ACP server mode for testing or custom clients:

$ kimi acp

# JSON-RPC server starts on stdin/stdout

Node.js ACP Client

For programmatic control, use the ACP client library:

import { createClient } from '@moonshot-ai/acp-client'

const client = await createClient({
  command: ['kimi', 'acp'],
  cwd: process.cwd()
})

// Start a session and send a prompt
const sess = await client.createSession({ model: 'gpt-4' })
const reply = await client.sendPrompt({ 
  sessionId: sess.id, 
  prompt: 'Explain ACP architecture' 
})
console.log(reply.output)

JetBrains Run Configuration

Configure the Run/Debug settings as follows:

  • Program: kimi
  • Arguments: acp
  • Working directory: $PROJECT_ROOT

Summary

  • ACP (Agent Client Protocol) is a JSON-RPC protocol enabling editor-agent communication over stdin/stdout.
  • The @moonshot-ai/acp-adapter package implements ACP 0.23 in Kimi Code, exposing methods like createSession and runTool.
  • The kimi acp command (in apps/kimi-code/src/cli/sub/acp.ts) launches the ACP server as a subprocess.
  • Zed integrates through settings.json agent server configuration using "type": "terminal".
  • JetBrains uses Run/Debug configurations to spawn kimi acp, with authentication handled in packages/acp-adapter/src/auth-methods.ts.
  • Because ACP uses stdio transport, Kimi Code works with any editor supporting subprocess communication without network dependencies.

Frequently Asked Questions

What is the difference between ACP and other AI coding protocols?

ACP (Agent Client Protocol) is specifically designed for editor-to-agent communication using JSON-RPC over stdin/stdout, whereas protocols like MCP (Model Context Protocol) focus on context sharing between models and tools. ACP handles the full session lifecycle including UI elements like tool pickers and thinking indicators, making it more comprehensive for IDE integration than simple API wrappers.

Does ACP require an internet connection to work?

ACP itself operates over local stdio pipes between the editor and the Kimi Code CLI, but the CLI requires internet connectivity to reach MoonshotAI's language model APIs. The protocol transport is entirely local, meaning you can run the ACP server offline if using local models, though standard Kimi Code usage requires cloud API access for the underlying LLM features.

Can I use ACP with editors other than Zed and JetBrains?

Yes. Any editor capable of spawning a subprocess and exchanging JSON-RPC messages over stdin/stdout can implement ACP support. The protocol specification is editor-agnostic, and the kimi acp command provides the same feature set regardless of the client. Custom implementations can use the @moonshot-ai/acp-client package or directly implement the JSON-RPC interface against the running subprocess.

How do I troubleshoot ACP connection failures?

First verify that kimi acp launches successfully in your terminal and responds to JSON-RPC messages. Check that your editor configuration points to the correct executable path and that environment variables are properly passed (Zed uses "env": {} to inherit defaults, while JetBrains configurations must explicitly set the working directory). Review packages/acp-adapter/src/auth-methods.ts if encountering authentication errors, as different editors handle credential delegation differently.

Have a question about this repo?

These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:

Share the following with your agent to get started:
curl -s "https://instagit.com/install.md"

Works with
Claude Codex Cursor VS Code OpenClaw Any MCP Client

Maintain an open-source project? Get it listed too →