mcp-gopls
Model Context Protocol (MCP) server for Go using gopls – LSP-powered analysis, tests, coverage, and tooling.
claude mcp add --transport stdio hloiseau-mcp-gopls mcp-gopls --workspace /absolute/path/to/your/go/project \ --env MCP_GOPLS_LOG_LEVEL="info"
How to use
mcp-gopls exposes Go tooling through the MCP protocol by wrapping the gopls language server in an MCP server. With this server, AI assistants can perform go-to-definition, find references, show diagnostics, hover information, code completion, formatting, renaming, and code actions directly through MCP tools. It also provides Go-specific tooling like running tests, generating coverage, tidying go.mod, and performing vulnerability checks, all with structured results suitable for chat-based workflows. To use it, run the server with a workspace path pointing at your Go project and connect an MCP client (Cursor, Claude, Copilot, or another client) to issue the available MCP tools such as go_to_definition, find_references, check_diagnostics, get_hover_info, get_completion, format_document, rename_symbol, list_code_actions, run_go_test, analyze_coverage, run_go_mod_tidy, and run_govulncheck. The server will communicate with gopls via LSP and surface results in the MCP format.
How to install
Prerequisites:
- Go installed (1.20+ recommended)
- Access to the internet to fetch modules and binaries
Step-by-step:
- Install the MCP server binary (example using the published module):
- go install github.com/hloiseau/mcp-gopls/v2/cmd/mcp-gopls@latest
- Verify installation:
- mcp-gopls --help
- Run the MCP server pointing to your Go workspace:
- mcp-gopls --workspace /absolute/path/to/your/go/project
- (Optional) Set up an MCP client configuration (e.g., Cursor) to connect to the server using the same workspace path.
If you prefer containerized usage, see the Docker guidance in the README for running mcp-gopls inside a container and mounting your workspace.
Additional notes
Tips and notes:
- Environment variables supported by the server include MCP_GOPLS_LOG_LEVEL to control logging verbosity. Use values like info, debug, warn, error as needed.
- The --workspace flag determines the Go workspace the server analyzes; ensure your path points to the root of your Go module or workspace.
- For best performance, mount a local Go module workspace into the container (if using Docker) or run natively where the workspace resides.
- If you update gopls or your Go module, restart the MCP server to reload state.
- Use the provided MCP tools list to discover capabilities; the server supports extended LSP features via tools such as go_to_definition, get_hover_info, get_completion, and more, along with Go tooling like run_go_test and analyze_coverage.
- When integrating with clients, ensure the client uses the same workspace path and passes any necessary environment configurations to replicate local behavior.
Related MCP Servers
go-utcp
Official Go implementation of the UTCP
mcp-batchit
🚀 MCP aggregator for batching multiple tool calls into a single request. Reduces overhead, saves tokens, and simplifies complex operations in AI agent workflows.
mcp-zero
Model Context Protocol (MCP) server for go-zero framework - Generate APIs, RPC services, and models with AI assistance.
cadre-ai
Your AI agent squad for Claude Code. 17 specialized agents, persistent memory, desktop automation, and a common sense engine.
Hoofy
Hoofy — AI development companion MCP server. Persistent memory, spec-driven development, adaptive change pipeline, Clarity Gate. 32 tools, single Go binary, zero deps.
ruvscan
🧠 The AI that finds the code you didn't know you needed - Sublinear-intelligence MCP server for discovering GitHub leverage