Skip to content

Configure gopls-mcp

gopls-mcp uses a JSON configuration file for customization. Pass it via the -config flag:

Terminal window
gopls-mcp -config /path/to/config.json
{
"workdir": "/path/to/project",
"max_response_bytes": 64000,
"gopls": {
// Native gopls settings (passed directly to gopls)
}
}

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.

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

If no config file is provided:

{
"gopls": {},
"max_response_bytes": 32000,
"workdir": "<current directory>"
}
FlagDescription
-configPath to configuration file (JSON)
-workdirPath to Go project directory
-logfilePath to log file for debugging
-addrHTTP server address (e.g., localhost:8080)
-verboseEnable verbose logging (HTTP mode only)