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?

MCP Gopls MCP server exists for a simple reason — assistants are far more useful when they can act on MCP Gopls directly instead of describing what you should do. 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

What the assistant can call

Once MCP Gopls is connected, these are the calls the assistant has available:

  • go_to_definition — “Use go_to_definition on pkg/server/server.go:42.”
  • find_references — “Ask the tool for references to ServeStdio.”
  • check_diagnostics — “Request diagnostics for cmd/mcp-gopls/main.go.”
  • get_hover_info — “Call get_hover_info on pkg/tools/workspace.go:88.”
  • get_completion — “Trigger completions at pkg/server/server.go:55.”
  • format_document — “Run the formatter over pkg/tools/refactor.go.”
  • rename_symbol — “Rename clientFactory to newClientFactory via the tool.”
  • list_code_actions — “List code actions for pkg/server/server.go:80-90.”
  • search_workspace_symbols — “Search workspace symbols for NewWorkspaceConfig.”
  • analyze_coverage — “Run analyze_coverage for ./pkg/... with per-function stats.”
  • run_go_test — “Execute run_go_test on ./cmd/....”
  • run_go_mod_tidy — “Invoke run_go_mod_tidy to sync go.mod.”

Configuration and credentials

You will need 2 environment variables: MCP_GOPLS_LOG_LEVEL, MCP_GOPLS_GOPLS_PATH. Keep credentials in your client's env block or a secrets manager rather than in a file you might commit.

  • 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.

Setting it up

@mark3labs/mcp-inspector on npm is all you need. Most clients run it directly, so configuration is a few lines and a restart.

Choosing this one

Plenty of developer tooling servers cover similar ground. The differences that matter in practice are scope of access and how much setup stands between you and a working tool call. MCP Gopls's toolset — go_to_definition, find_references, check_diagnostics and 11 more — is a fair guide to whether it matches your workflow. It is maintained by hloiseaufcms; worth a glance at recent repository activity before you build anything load-bearing on it.

We check each listing at SyncDev against the project's documentation before it goes live — if something here drifts out of date, it is a bug worth reporting.

Before you rely on it

  • It runs with your machine's permissions. That is convenient and also the reason to think about what you point it at before you approve a tool call.
  • With 14 tools registered it takes up a noticeable share of the context window; turn it off in projects that never touch MCP Gopls.
  • MCP clients confirm each tool call by default. Leave that on until you have watched what the mcp gopls mcp server does with a few real requests.

Available tools

ToolWhat it does
go_to_definition“Use go_to_definition on pkg/server/server.go:42.”
find_references“Ask the tool for references to ServeStdio.”
check_diagnostics“Request diagnostics for cmd/mcp-gopls/main.go.”
get_hover_info“Call get_hover_info on pkg/tools/workspace.go:88.”
get_completion“Trigger completions at pkg/server/server.go:55.”
format_document“Run the formatter over pkg/tools/refactor.go.”
rename_symbol“Rename clientFactory to newClientFactory via the tool.”
list_code_actions“List code actions for pkg/server/server.go:80-90.”
search_workspace_symbols“Search workspace symbols for NewWorkspaceConfig.”
analyze_coverage“Run analyze_coverage for ./pkg/... with per-function stats.”
run_go_test“Execute run_go_test on ./cmd/....”
run_go_mod_tidy“Invoke run_go_mod_tidy to sync go.mod.”
run_govulncheck“Run run_govulncheck and stream findings.”
module_graph“Call module_graph to inspect dependencies.”

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"
      }
    }
  }
}

Configuration as documented by the project. Restart the client after saving.

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_LEVELConfiguration value read at startup.Optional
MCP_GOPLS_GOPLS_PATHFilesystem location the server is allowed to use.Optional

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

It connects MCP Gopls to MCP-compatible AI assistants such as Claude and Cursor, exposing 14 tools (go_to_definition, find_references, check_diagnostics, and more) that the assistant can call on your behalf. Instead of copying data back and forth by hand, the assistant works with MCP Gopls directly.