MCP Gopls MCP Server

A Model Context Protocol (MCP) server that lets AI assistants use Go’s LSP (`gopls`) for navigation, diagnostics, testing, coverage, and more.

Local serverstdioGo

What is the MCP Gopls MCP Server?

A Model Context Protocol (MCP) server that lets AI assistants use Go’s LSP (gopls) for navigation, diagnostics, testing, coverage, and more.

What you get

  • Configurable runtime — --workspace, --gopls-path, --log-level, --rpc-timeout, and --shutdown-timeout flags + env vars (MCP_GOPLS_*)
  • Structured logging — Text/JSON logging with slog and optional file output
  • Extended LSP surface — navigation, diagnostics, formatting, rename, code actions, hover, completion, workspace symbols
  • Test & tooling helpers — coverage analysis, go test, go mod tidy, govulncheck, go mod graph
  • MCP extras — resources (resource://workspace/overview, resource://workspace/go.mod) and prompts (summarize_diagnostics, refactor_plan)
  • Progress streaming — long-running commands emit notifications/progress events so clients can surface status updates

Configuration and credentials

  • Go 1.25+ (tested with go1.25.4) - gopls installed (go install golang.org/x/tools/gopls@latest) - Optional: govulncheck (go install golang.org/x/vuln/cmd/govulncheck@latest) - The server forces GOTOOLCHAIN=local for its nested gopls process. If you need a different toolchain, set GOTOOLCHAIN in the environment before launching mcp-gopls.

More MCP options

Compare MCP servers by category, or browse hosted MCP servers if you prefer an endpoint over a local process.

Maintainer setup documentation.

Recorded tools

Check the linked publisher documentation and your connected client's tool list. Names and availability can vary with the server version and account permissions.

ToolWhat it does
go_to_definitionNavigate to the definition of a symbol
find_referencesList all references for a symbol
check_diagnosticsFetch cached diagnostics for a file
get_hover_infoReturn hover markdown for a symbol
get_completionReturn completion labels at a position
format_documentReturn formatting edits for an entire document
rename_symbolReturn workspace edits for a rename
list_code_actionsList available code actions for a range
search_workspace_symbolsSearch workspace-wide symbols
analyze_coverageRun go test with coverage + optional per-function report
run_go_testExecute go test for a package/pattern
run_go_mod_tidyExecute go mod tidy
run_govulncheckExecute govulncheck ./...
module_graphReturn go mod graph output

How to install the MCP Gopls MCP Server

{
  "mcpServers": {
    "mcp-gopls": {
      "command": "mcp-gopls",
      "args": [
        "--workspace",
        "/absolute/path/to/your/go/project"
      ],
      "env": {
        "MCP_GOPLS_LOG_LEVEL": "info"
      }
    }
  }
}

From the project documentation. Replace placeholders and example paths before connecting.

Configuration

  • Go 1.25+ (tested with go1.25.4) - gopls installed (go install golang.org/x/tools/gopls@latest) - Optional: govulncheck (go install golang.org/x/vuln/cmd/govulncheck@latest) - The server forces GOTOOLCHAIN=local for its nested gopls process. If you need a different toolchain, set GOTOOLCHAIN in the environment before launching mcp-gopls.
VariableDescriptionRequired
MCP_GOPLS_LOG_LEVELDeclared in the maintainer’s client configuration.Check documentation

Example prompts to try

  • “Use MCP Gopls to go to definition.”
  • “Use MCP Gopls to find references.”
  • “Use MCP Gopls to check diagnostics.”

Frequently asked questions

A Model Context Protocol (MCP) server that lets AI assistants use Go’s LSP (`gopls`) for navigation, diagnostics, testing, coverage, and more. Confirm the tools offered by your installed version in the connected client. Tool availability and permissions depend on the server and account configuration.