SuperAPI AI Directory

mcp-gopls

Go code analysis via gopls, the Go language server.

Open website

About this tool

mcp-gopls is a Model Context Protocol (MCP) server designed to let AI assistants leverage Go's official language server, gopls, for code analysis, navigation, diagnostics, testing, coverage checking, and tool invocation. It communicates with gopls over LSP, providing AI clients with full LSP capabilities.

Main Capabilities

  • Analyze Go workspaces using LSP
  • Navigate to definitions, references, and workspace symbols
  • Format, rename, and inspect code actions without leaving MCP
  • Run Go tests, coverage analysis, go mod tidy, govulncheck, and module graph commands, and return structured results
  • Read workspace resources (overview and go.mod) and use curated prompts

Usage

After installing the server, ensure it is in $PATH, then configure your AI client (such as Cursor, Claude Desktop, GitHub Copilot). All clients point to the same command:mcp-gopls --workspace /absolute/path/to/your/go/project. The configuration format varies by client, but the binary and arguments are the same.

Client Configuration Examples

  • Cursor: Open Settings → MCP Servers → Edit JSON, add an mcp-gopls entry, then run Developer: Reload Window to reconnect.
  • Claude Desktop: Edit claude_desktop_config.json (macOS: ~/Library/Application Support/Claude/claude_desktop_config.json; Linux: ~/.config/Claude/claude_desktop_config.json; Windows: %APPDATA%\Claude\claude_desktop_config.json), add the server entry, and restart Claude Desktop.
  • GitHub Copilot (Agent Mode): Requires VS Code 1.99+, configure in .vscode/mcp.json, and reload Agent Mode.

Docker / MCP Gateway

You can run it in a container using the official image; copy docs/docker-mcp.yaml and update the bind mount paths.

Tool Catalog Metadata

If the MCP catalog tools require a toolsUrl, you can use docs/tools.json as a static tool list.

Configuration Options

Supports command-line flags and environment variables (MCP_GOPLS_* prefix), with command-line flags taking precedence. You can configure --workspace, --gopls-path, --log-level, --rpc-timeout, --shutdown-timeout, and more.

Progress Notifications

Long-running tools emit structured notifications/progress events, supporting streaming progress (such as run_go_test, analyze_coverage, run_govulncheck, run_go_mod_tidy) and start/completion events.

Prompts

Provides the summarize_diagnostics and refactor_plan prompts to help assistants generate consistent output.

Use Cases

Suitable for Go developers using MCP-capable AI clients such as Claude, Cursor, and GitHub Copilot, who want full LSP editing and tool support from MCP.

Limitations

  • Requires Go 1.25+ (tested with go1.25.4) and gopls installed (go install golang.org/x/tools/gopls@latest).
  • Optional govulncheck (go install golang.org/x/vuln/cmd/govulncheck@latest).
  • The server enforces GOTOOLCHAIN=local for nested gopls processes.
  • Compared with the built-in gopls MCP, mcp-gopls provides richer functionality; if you only need read-only/introspection tools, the built-in gopls MCP may be sufficient.
  • The built-in gopls MCP server is still marked experimental, and the toolset may change.

Project Status

Under active development, used in real projects, tested with Go 1.25.x and gopls@latest. The MCP is implemented using the mark3labs/mcp-go library.

License

Apache License 2.0.