This plugin integrates the Gemini CLI into IntelliJ IDEA, providing seamless editor integration through the MCP (Model Context Protocol) IDE Companion Specification.
- Terminal Integration: Opens a dedicated "Gemini" terminal tab that runs the Gemini CLI with automatic IDE server discovery.
- Real-time Context Streaming: Automatically streams workspace context to Gemini via Server-Sent Events (SSE), including:
- Open files and their paths
- Active file and cursor position (line/column)
- Selected text in the active editor
- Native Diff Viewer: Gemini can open diffs directly in IntelliJ's native diff viewer using the
openDiffMCP tool. - Keyboard Shortcut: Trigger with
Shift+Cmd+Esctwice (orShift+Cmd+EscthenEsc). - Auto-Discovery: The plugin automatically registers an MCP server that Gemini discovers via a JSON file in the system temp directory.
- Gemini CLI: You must have the
geminiCLI tool installed and in your PATH. - IntelliJ IDEA 2023.2 or later (with Terminal plugin enabled).
The plugin starts a local HTTP server (MCP) on a dynamic port when your project opens. When you trigger the plugin via keyboard shortcut:
- A new terminal tab named "Gemini" is created (or focused if it already exists)
- The
geminiCLI is launched with theGEMINI_CLI_IDE_SERVER_PORTenvironment variable set - Gemini discovers the IDE server via a discovery file at
$TMPDIR/gemini/ide/gemini-ide-server-{pid}-{port}.json - The CLI connects to the MCP server to receive real-time context updates and use IDE tools like
openDiff
As you work in IntelliJ, the plugin automatically sends context updates to Gemini whenever you:
- Switch between files
- Move your cursor
- Select text
To make Gemini open files directly in IntelliJ when it needs to edit them, set the EDITOR environment variable to idea:
export EDITOR=ideaAdd this to your shell profile (~/.zshrc, ~/.bashrc, etc.) to make it permanent.
The idea command is a shell script that launches IntelliJ IDEA. You can create it via:
- Open IntelliJ IDEA
- Go to Tools → Create Command-line Launcher...
- Accept the default path (
/usr/local/bin/idea) or customize it
This creates a simple shell wrapper (on macOS):
#!/bin/sh
open -na '/Applications/IntelliJ IDEA.app' --args "$@"Note: The exact path and script content may differ based on your IntelliJ installation (Community vs Ultimate, custom install location, or OS platform).
Once configured, when Gemini needs to open a file for editing, it will launch IntelliJ and open the file directly, providing a seamless workflow between the CLI and IDE.
- Build the plugin:
./gradlew buildPlugin - Install from disk: Settings -> Plugins -> Gear Icon -> Install Plugin from Disk -> select
build/libs/intellij-gemini-cli-1.0-SNAPSHOT.zip
Run the plugin in a sandboxed IDE:
./gradlew runIde