gemini-cli

Gemini CLI Companion Plugin: Interface Specification

Last Updated: September 15, 2025

This document defines the contract for building a companion plugin to enable Gemini CLI’s IDE mode. For VS Code, these features (native diffing, context awareness) are provided by the official extension (marketplace). This specification is for contributors who wish to bring similar functionality to other editors like JetBrains IDEs, Sublime Text, etc.

I. The Communication Interface

Gemini CLI and the IDE plugin communicate through a local communication channel.

1. Transport Layer: MCP over HTTP

The plugin MUST run a local HTTP server that implements the Model Context Protocol (MCP).

2. Discovery Mechanism: The Port File

For Gemini CLI to connect, it needs to discover which IDE instance it’s running in and what port your server is using. The plugin MUST facilitate this by creating a “discovery file.”

II. The Context Interface

To enable context awareness, the plugin MAY provide the CLI with real-time information about the user’s activity in the IDE.

ide/contextUpdate Notification

The plugin MAY send an ide/contextUpdate notification to the CLI whenever the user’s context changes.

How the CLI Uses This Context

After receiving the IdeContext object, the CLI performs several normalization and truncation steps before sending the information to the model.

While the CLI handles the final truncation, it is highly recommended that your plugin also limits the amount of context it sends.

III. The Diffing Interface

To enable interactive code modifications, the plugin MAY expose a diffing interface. This allows the CLI to request that the IDE open a diff view, showing proposed changes to a file. The user can then review, edit, and ultimately accept or reject these changes directly within the IDE.

openDiff Tool

The plugin MUST register an openDiff tool on its MCP server.

closeDiff Tool

The plugin MUST register a closeDiff tool on its MCP server.

ide/diffAccepted Notification

When the user accepts the changes in a diff view (e.g., by clicking an “Apply” or “Save” button), the plugin MUST send an ide/diffAccepted notification to the CLI.

ide/diffRejected Notification

When the user rejects the changes (e.g., by closing the diff view without accepting), the plugin MUST send an ide/diffRejected notification to the CLI.

IV. The Lifecycle Interface

The plugin MUST manage its resources and the discovery file correctly based on the IDE’s lifecycle.