Back to MCP Directory
Gopls
Model Context Protocol moderate risk

Gopls

MCP server exposing Go's LSP (gopls) for AI assistants, enabling code navigation, diagnostics, testing, and refactoring capabilities.

Connections & Capabilities

Connects To

GitHubDocker

Capabilities

readwriteexec

Quickstart

Install

npx -y @mark3labs/mcp-inspector \

Config

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

Exposed MCP Tools (14)

safe
go_to_definition

Navigates to the definition of a specified symbol.

Read-only operation, no side effects.

safe
find_references

Lists all references to a specified symbol.

Read-only operation, no side effects.

safe
check_diagnostics

Fetches cached diagnostics for a specified file.

Read-only operation, no side effects.

safe
get_hover_info

Returns hover information for a symbol at a given position.

Read-only operation, no side effects.

safe
get_completion

Returns code completion suggestions at a given position.

Read-only operation, no side effects.

moderate
format_document

Formats the specified Go document.

Modifies the document, but generally non-destructive.

high
rename_symbol

Renames a symbol throughout the workspace.

Modifies code structure, potential for errors.

moderate
list_code_actions

Lists available code actions for a given range.

Code actions can modify code, review before applying.

safe
search_workspace_symbols

Searches for symbols within the workspace.

Read-only operation, no side effects.

safe
analyze_coverage

Analyzes code coverage for specified packages.

Read-only analysis, no code modification.

moderate
run_go_test

Executes Go tests for specified packages.

Can modify files (e.g., generate test coverage files).

moderate
run_go_mod_tidy

Runs `go mod tidy` to synchronize the go.mod file.

Modifies go.mod and go.sum, potentially altering dependencies.

safe
run_govulncheck

Runs `govulncheck` to identify known vulnerabilities.

Read-only analysis, no code modification.

safe
module_graph

Generates a module graph of dependencies.

Read-only operation, no side effects.

Safety Assessment

This server provides powerful code analysis and manipulation capabilities. It's safe for read-only operations like code navigation and diagnostics. However, running tests or applying code actions carries a moderate risk of unintended changes and should be carefully reviewed.

  • Uses LSP for code analysis, which is generally safe.
  • Provides structured logging for auditing.
  • Allows configurable runtime parameters.
  • Supports progress streaming for long-running commands.
  • Can execute `go test`, `go mod tidy`, and `govulncheck`, which can modify the workspace.
  • Exposes code actions that could potentially introduce unintended changes.
  • Relies on the security of the underlying `gopls` LSP server.
  • Requires access to the Go workspace, potentially exposing sensitive code.