Skip to content

x/tools/gopls: mcp: opens too many files #76291

@thenom

Description

@thenom

Go version

go version go1.25.1 darwin/arm64

Output of go env in your module/workspace:

CC='cc'
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_ENABLED='1'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
CXX='c++'
GCCGO='gccgo'
GO111MODULE='auto'
GOARCH='arm64'
GOARM64='v8.0'
GOAUTH='netrc'
GOBIN=''
GOCACHE='/Users/simon.thorley/Library/Caches/go-build'
GOCACHEPROG=''
GODEBUG=''
GOENV='/Users/simon.thorley/Library/Application Support/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFIPS140='off'
GOFLAGS=''
GOGCCFLAGS='-fPIC -arch arm64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -ffile-prefix-map=/var/folders/qd/k6bddt8s6156q_fft23bdly40000gr/T/go-build3764416828=/tmp/go-build -gno-record-gcc-switches -fno-common'
GOHOSTARCH='arm64'
GOHOSTOS='darwin'
GOINSECURE=''
GOMOD=''
GOMODCACHE='/Users/simon.thorley/workspace/go/pkg/mod'
GONOPROXY='gitlab.com/private-subgroup/*'
GONOSUMDB='gitlab.com/private-subgroup/*'
GOOS='darwin'
GOPATH='/Users/simon.thorley/workspace/go'
GOPRIVATE='gitlab.com/private-subgroup/*'
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/opt/homebrew/Cellar/go/1.25.1/libexec'
GOSUMDB='sum.golang.org'
GOTELEMETRY='local'
GOTELEMETRYDIR='/Users/simon.thorley/Library/Application Support/go/telemetry'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/opt/homebrew/Cellar/go/1.25.1/libexec/pkg/tool/darwin_arm64'
GOVCS=''
GOVERSION='go1.25.1'
GOWORK=''
PKG_CONFIG='pkg-config'

What did you do?

Using the following MCP config within AmazonQ CLI:

		"gopls": {
			"command": "gopls",
			"args": [
				"mcp"
			]
		},

Or starting up directly by just running gopls mcp

What did you see happen?

When using Q CLI I always start getting too many open files errors and applications start to close/crash (e.g. chrome). I found that if i run the mcp server manually i can limit these open files by running it within an empty folder.

If i run it from my home folder i always hit the open file limit so it seems that potentially it is reading in all files and subfolders files on startup.

My open files went from ~12k before running it within my home folder to +71k at which point my laptop became unresponsive until i could finally cancel the server out:

 $ gopls mcp
2025/11/13 13:28:19 Listening for MCP messages on stdin...

2025/11/13 13:28:43 Error:2025/11/13 13:28:43 failed to get import resolver: err: fork/exec /opt/homebrew/bin/go: too many open files in system: stderr:
^C^C
^C
^C
^C

What did you expect to see?

Stable OS and low additional open files count

Metadata

Metadata

Assignees

Labels

BugReportIssues describing a possible bug in the Go implementation.ToolsThis label describes issues relating to any tools in the x/tools repository.goplsIssues related to the Go language server, gopls.

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions