Configure gopls-mcp
Quick Setup
Section titled “Quick Setup”gopls-mcp uses a JSON configuration file for customization. Pass it via the -config flag:
gopls-mcp -config /path/to/config.jsonConfiguration Structure
Section titled “Configuration Structure”{ "workdir": "/path/to/project", "max_response_bytes": 64000, "gopls": { // Native gopls settings (passed directly to gopls) }}Key Settings
Section titled “Key Settings”max_response_bytes
Section titled “max_response_bytes”Type: integer | Default: 32000 (32KB)
Global response size limit in bytes. All tools respect this limit automatically. When exceeded, responses are truncated with metadata.
{ "max_response_bytes": 64000 // 64KB limit}Increase this if you frequently encounter truncated results from large files or complex queries.
workdir
Section titled “workdir”Type: string | Default: Current directory
The Go project directory to analyze. Overrides the -workdir flag.
{ "workdir": "/path/to/my/project"}Type: object | Default: {}
Native gopls configuration options. These are passed directly to gopls’s internal settings system.
For complete gopls settings documentation, see go.dev/gopls/settings
Common options:
{ "gopls": { "staticcheck": true, "analyses": { "unusedparams": true }, "buildFlags": ["-tags=integration"], "env": { "GOFLAGS": "-mod=mod" } }}Default Configuration
Section titled “Default Configuration”If no config file is provided:
{ "gopls": {}, "max_response_bytes": 32000, "workdir": "<current directory>"}Command-Line Flags
Section titled “Command-Line Flags”| Flag | Description |
|---|---|
-config | Path to configuration file (JSON) |
-workdir | Path to Go project directory |
-logfile | Path to log file for debugging |
-addr | HTTP server address (e.g., localhost:8080) |
-verbose | Enable verbose logging (HTTP mode only) |
Learn More
Section titled “Learn More”- gopls settings reference - All native gopls options
- gopls user guide - Comprehensive documentation