Skip to content

x/tools/gopls: mcp stdio/sse report crashing message on non-go workspace #74593

Description

@h9jiang

gopls version

0.0.0

go env

N/A

What did you do?

Run gopls mcp -listen ADDRESS or gopls mcp

What did you see happen?

N/A

What did you expect to see?

Some MCP client surface the error from STDERR to the user, this may seems confusing. Instead, in non-go workspace, the gopls mcp server should be quiet.

The error is reported from Go see source

In addition, when launching gopls mcp server in non-go workspace, it takes a few seconds for the server to start serving mcp request either for stdio or sse.

Editor and settings

No response

Logs

2025/07/11 14:31:48 Error:2025/07/11 14:31:48 go/packages.Load #1: err: exit status 2: stderr: panic: LoadImport called with empty package path [recovered, repanicked]

goroutine 1 [running]:
cmd/go/internal/load.(*preload).flush(0x140002582b0)
        /GOPATH/go/src/cmd/go/internal/load/pkg.go:1122 +0x80
panic({0x100727640?, 0x10080dd90?})
        /GOPATH/go/src/runtime/panic.go:783 +0x120
cmd/go/internal/load.loadImport({0x100817070, 0x100c408e0}, {0x0, 0x1, 0x0, 0x1, 0x1, 0x0}, 0x0, {0x107ba69a9, ...}, ...)
        /GOPATH/go/src/cmd/go/internal/load/pkg.go:711 +0x100c
cmd/go/internal/load.(*Package).load(0x140006b0608, {0x100817070, 0x100c408e0}, {0x0, 0x1, 0x0, 0x1, 0x1, 0x0}, {0x140000c1460, ...}, ...)
        /GOPATH/go/src/cmd/go/internal/load/pkg.go:2029 +0x1d50
cmd/go/internal/load.loadImport({0x100817070, 0x100c408e0}, {0x0, 0x1, 0x0, 0x1, 0x1, 0x0}, 0x140002582b0, {0x140000c1460, ...}, ...)
        /GOPATH/go/src/cmd/go/internal/load/pkg.go:774 +0x3d8
cmd/go/internal/load.PackagesAndErrors({0x100817070?, 0x100c408e0?}, {0x0, 0x1, 0x0, 0x1, 0x1, 0x0}, {0x140001343f0, 0x2, ...})
        /GOPATH/go/src/cmd/go/internal/load/pkg.go:2955 +0x714
cmd/go/internal/list.runList({0x100817070, 0x100c408e0}, 0x14000132858?, {0x140001343f0, 0x2, 0x2})
        /GOPATH/go/src/cmd/go/internal/list/list.go:616 +0xbdc
main.invoke(0x100c09b80, {0x14000134350, 0xc, 0xc})
        /GOPATH/go/src/cmd/go/main.go:341 +0x63c
main.main()
        /GOPATH/go/src/cmd/go/main.go:220 +0xd58

        view_id="1"
        snapshot=0
        directory=/GOPATH/python-workspace
        query=[/Users/hxjiang/... builtin]
        packages=0
        duration=36.535622333s
2025/07/11 14:31:48 Error:2025/07/11 14:31:48 initial workspace load failed: packages.Load error: err: exit status 2: stderr: panic: LoadImport called with empty package path [recovered, repanicked]

goroutine 1 [running]:
cmd/go/internal/load.(*preload).flush(0x140002582b0)
        /GOPATH/go/src/cmd/go/internal/load/pkg.go:1122 +0x80
panic({0x100727640?, 0x10080dd90?})
        /GOPATH/go/src/runtime/panic.go:783 +0x120
cmd/go/internal/load.loadImport({0x100817070, 0x100c408e0}, {0x0, 0x1, 0x0, 0x1, 0x1, 0x0}, 0x0, {0x107ba69a9, ...}, ...)
        /GOPATH/go/src/cmd/go/internal/load/pkg.go:711 +0x100c
cmd/go/internal/load.(*Package).load(0x140006b0608, {0x100817070, 0x100c408e0}, {0x0, 0x1, 0x0, 0x1, 0x1, 0x0}, {0x140000c1460, ...}, ...)
        /GOPATH/go/src/cmd/go/internal/load/pkg.go:2029 +0x1d50
cmd/go/internal/load.loadImport({0x100817070, 0x100c408e0}, {0x0, 0x1, 0x0, 0x1, 0x1, 0x0}, 0x140002582b0, {0x140000c1460, ...}, ...)
        /GOPATH/go/src/cmd/go/internal/load/pkg.go:774 +0x3d8
cmd/go/internal/load.PackagesAndErrors({0x100817070?, 0x100c408e0?}, {0x0, 0x1, 0x0, 0x1, 0x1, 0x0}, {0x140001343f0, 0x2, ...})
        /GOPATH/go/src/cmd/go/internal/load/pkg.go:2955 +0x714
cmd/go/internal/list.runList({0x100817070, 0x100c408e0}, 0x14000132858?, {0x140001343f0, 0x2, 0x2})
        /GOPATH/go/src/cmd/go/internal/list/list.go:616 +0xbdc
main.invoke(0x100c09b80, {0x14000134350, 0xc, 0xc})
        /GOPATH/go/src/cmd/go/main.go:341 +0x63c
main.main()
        /GOPATH/go/src/cmd/go/main.go:220 +0xd58

2025/07/11 14:31:48 Listening for MCP messages on stdin...

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

ToolsThis label describes issues relating to any tools in the x/tools repository.goplsIssues related to the Go language server, gopls.

Type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions