home / mcp / mcp-gopls mcp server
Model Context Protocol (MCP) server for Go using gopls – LSP-powered analysis, tests, coverage, and tooling.
Configuration
View docs{
"mcpServers": {
"hloiseau-mcp-gopls": {
"command": "mcp-gopls",
"args": [
"--workspace",
"/absolute/path/to/your/go/project"
],
"env": {
"MCP_GOPLS_LOG_LEVEL": "info",
"MCP_GOPLS_WORKSPACE": "\"/path/to/project\"",
"MCP_GOPLS_GOPLS_PATH": "\"/usr/local/bin/gopls\"",
"MCP_GOPLS_RPC_TIMEOUT": "\"30s\"",
"MCP_GOPLS_SHUTDOWN_TIMEOUT": "\"5s\""
}
}
}
}You can run a Go MCP server named mcp-gopls that lets AI assistants leverage Go tooling through gopls. This server exposes extensive LSP-powered capabilities for navigation, diagnostics, testing, coverage, and workspace inspection, enabling seamless interaction with Go code from AI copilots and IDE integrations.
Connect to mcp-gopls from your MCP-aware client to access Go language features through the LSP surface and the MCP tools. With this server you can navigate to definitions, find references, view hover information, trigger completions, format documents, rename symbols, list code actions, search workspace symbols, run Go tests and coverage, tidy modules, perform vulnerability checks, and generate a module graph. You also receive curated workspace resources and prompts to help with diagnostics and refactoring.
Prerequisites you need before installing this server:
Go 1.25+ (tested with go1.25.4) must be installed on your system.
GOPATH-aware Go tooling is expected, including gopls (Go language server) installed via the Go toolchain.
Step-by-step commands to install and run the MCP server locally:
go install github.com/hloiseau/mcp-gopls/v2/cmd/mcp-gopls@latestmcp-gopls --helpYou can start the server directly from the command line and point clients to the workspace you want to analyze.
If you prefer containerized execution, run the server with Docker using your workspace mounted into the container.
docker run --rm -i \
-v /absolute/path/to/your/go/project:/workspace \
ghcr.io/hloiseau/mcp-gopls:latest \
--workspace /workspaceNavigate to the definition of a symbol in the workspace using the MCP tool surface.
List all references to a symbol across the workspace.
Fetch cached or up-to-date diagnostics for a file.
Return hover information for a symbol, including type and documentation snippets.
Provide completion suggestions at a given code position.
Return formatting edits to apply to an entire document.
Compute workspace edits to rename a symbol across the project.
List available code actions that can be applied to a code range.
Search for symbols across the entire workspace.
Run tests with coverage and generate optional per-function reports.
Execute go test for a package or pattern.
Run go mod tidy to synchronize module dependencies.
Execute vulnerability checks across the workspace.
Return the output of go mod graph to visualize dependencies.