English | 简体中文
This extension integrates the official MCP of the Go language server (gopls) with Gemini CLI. It enables Gemini to understand, write, and modify Go code with greater precision by providing language-aware features directly within the CLI environment.
To demonstrate its effectiveness, I performed the same code refactoring task in a Go project, both with and without this extension.
When using the extension, Gemini CLI calls the gopls tool to obtain precise symbol relationships and runs diagnostics immediately after each file modification. This avoids having to deal with a large number of syntax errors all at once during the final compilation.
Both the speed and accuracy of refactoring were significantly improved with the extension. For example, in the comparison case, Gemini missed updating some references to the refactored code when the extension was not used.
Install this extension using the following Gemini CLI command:
gemini extensions install https://github.com/Menghuan1918/gemini-cli-goplsThe extension automatically checks the gopls version in the system PATH at runtime. Since the MCP feature requires gopls v0.20.0 or later, if a compatible version of gopls is not found, the extension will attempt to automatically download and install it to the ~/go/bin directory.
If it still fails to start, please try manually installing gopls v0.20.0 or a later version into your PATH.
This extension provides Gemini CLI with the following tools based on the gopls MCP:
go_diagnostics: Workspace-based syntax error checkinggo_file_context: Summarizes cross-file dependencies for a filego_package_api: Provides information on external/internal Go package APIsgo_search: Searches for symbols in the workspacego_symbol_references: Provides reference locations for Go symbolsgo_workspace: Provides Go workspace information
Additionally, the plugin has built-in prompts from the official gopls MCP, with minor modifications to better suit Gemini CLI. You can view them in GEMINI.md.
The built-in prompts from the official gopls MCP were exported using
gopls mcp -instructions > GEMINI.md
When launched in a Go project (a workspace containing a go.mod file), the relevant tools will be loaded automatically. Otherwise, only an empty MCP service will be loaded (to avoid errors).
