Stuckgo

io.github.GillMacedo由 GitHub 帳號 GillMacedo 發布v0.1.0更新於 Nov 3, 2026

Find what a stuck Go program is waiting on from a goroutine dump, with no connection to it.

已驗證STDIO僅桌面開發者工具安全與監控

概覽

AI 產生的概覽

讀取 Go goroutine dump,告訴助理卡住或洩漏的 Go 程式在等什麼,且不連線到該程式。

可以做什麼
  • 檢視單份 goroutine dump(文字或檔案),合併相同堆疊、排除正常閒置的 goroutine 並列出排序後的發現
  • 辨識死鎖、nil channel 阻塞、互斥鎖堆積及可能的持有者、未完成的 WaitGroup、database/sql 連線池耗盡、長時間 HTTP 呼叫與 channel 洩漏
  • 比較同一程式的兩份 dump,顯示哪些堆疊在成長、哪些 goroutine ID 原地不動
  • 以文字或 JSON 輸出附嚴重程度與建議的發現
適用情境
適用於 Go 服務卡死、goroutine 洩漏、資料庫連線耗盡或疑似被互斥鎖阻塞,且手上有 dump 或崩潰堆疊可貼上時。也可用於間隔一段時間取兩份 dump 來驗證洩漏的懷疑。
執行需求
以 stdio 在本機執行,通常透過 npx(需 Node 18 或更新版本)或 Go 安裝。未宣告任何帳號、API 金鑰或環境變數。dump 文字需自行提供,例如來自 pprof goroutine 端點或崩潰堆疊。
安裝前請注意
dump 可能包含程式中的檔案路徑與數值,而 MCP 用戶端會把工具結果送給其模型,分享前請先檢查。發現只是線索而非證據:可能的鎖持有者是推斷的,單份 dump 無法證明洩漏。用 kill -QUIT 取得 dump 會終止行程。

安裝

在 SourceWeft 中

  1. 開啟 儀表板中的 Stuckgo,將其新增到工作區。
  2. 為需要使用其工具的對話啟用該服務。

Desktop only,透過 STDIO。 STDIO 服務會啟動本機處理程序,因此需要 SourceWeft 桌面主機。

其他 MCP 客戶端

參照 儲存庫 中的啟動說明。

README

stuckgo: why is this Go program stuck?

[npm] [CI] [MIT license]

An MCP server and CLI that reads a Go goroutine dump and tells you what the program is waiting on. It finds goroutine leaks, lock pile-ups, full database pools and HTTP calls with no timeout. It works from the dump text alone, so it never connects to your service.

A hung service can have thousands of goroutines, and most of them are normal: listeners, read loops, idle workers. stuckgo groups identical stacks, sets aside what's normally idle, and ranks what's left. When 40 goroutines wait on a mutex, it also names what might be holding it.

What you can ask your agent

  • "Our Go service is hanging. Here's the goroutine dump."
  • "Do we have a goroutine leak? Here are two dumps ten minutes apart."
  • "Why is this service out of database connections?"
  • "What's holding this mutex?"

Install

As a Claude Code plugin:

claude plugin marketplace add GillMacedo/stuckgoclaude plugin install stuckgo@stuckgo-marketplace

As an MCP server, for any client:

{"mcpServers": {"stuckgo": {"command": "npx", "args": ["-y", "[email protected]", "serve"]}}}

As a CLI, with Node 18 or newer:

npx stuckgo review dump.txt

Or with Go 1.27 or newer: go install github.com/GillMacedo/stuckgo@latest.

Usage

Get a dump from a service that imports net/http/pprof. This doesn't stop the program:

curl 'http://localhost:6060/debug/pprof/goroutine?debug=2' > dump.txt

kill -QUIT <pid> also prints a dump, but it ends the process. Crash output works too, and GOTRACEBACK=all shows every goroutine rather than just the failing one.

Here's a real dump from a made-up service in examples/, run from a clone of this repo:

$ go run . review examples/dumps/mutex-late.txt43 goroutines, 1 normally idle
Groups:      40  sync.Mutex.Lock, up to 2 min  main.(*store).Get (app/main.go:109)       1  chan receive, up to 2 min  main.mutex (app/main.go:130)       1  select, up to 2 min  main.(*store).Refresh (app/main.go:118)
HIGH   SG107 main.(*store).Get (app/main.go:109)  40 goroutines waiting for a mutex, waiting up to 2 minutes. Possible holder, not proven: main.(*store).Refresh (app/main.go:118), in select.  Try: Look at what the holder does while it holds the lock. Don't hold a lock across network calls, channel operations or slow work.

To check for a leak, compare two dumps taken some time apart. A stack that grows, with the same goroutine IDs staying in place, is much stronger evidence than one dump:

$ go run . compare examples/dumps/leak-early.txt examples/dumps/leak-late.txtGoroutines: 344 -> 637 (+293)
Growing:    +293  342 -> 635  chan send  main.lookupPrice.func1 (app/main.go:79)
Same goroutine IDs in the same place in both dumps:     342  chan send, up to 2 min  main.lookupPrice.func1 (app/main.go:79)

With Go 1.27 or newer, Go can also check for itself: /debug/pprof/goroutineleak?debug=2. stuckgo reads that output too.

Add --json for JSON, or --fail-on high to exit 1 in CI. Use - to read from stdin.

What it finds

RuleFinds
SG101Go's own "all goroutines are asleep" deadlock
SG102A panic or fatal error, and where it happened
SG103Goroutines that Go's leak profile reports as leaked
SG104A send or receive on a nil channel, which never returns
SG105Goroutines waiting for a free database/sql connection
SG106Outgoing HTTP calls that have been waiting a long time
SG107Goroutines piling up on a mutex, with possible holders
SG108A WaitGroup that hasn't finished, and what it started
SG109Goroutines stuck sending on a channel, the usual leak
SG110Many goroutines waiting on a channel receive or select
SG111Long waits on network I/O
SG112Long system calls
SG113Long waits in sync.Cond.Wait
SG114Many goroutines sleeping at one line
SG115One function that started most of the goroutines, across several stacks
SG116Many goroutines running or waiting for a CPU
SG117Many goroutines parked at one line in a debug=1 dump, which doesn't say why

Severity comes from how many goroutines are involved and how long they've waited. These thresholds are judgment calls.

MCP tools

ToolDoes
go_goroutine_reviewReviews one dump, from text or a file
go_goroutine_compareCompares two dumps of one program

Limits

  • Findings are leads. A dump is one moment. Check each finding against the code.
  • It can't prove who holds a lock. Go's dumps don't say. A "possible holder" is another goroutine in the same type's methods.
  • One dump can't prove a leak, unless it's Go's own leak profile. An idle worker pool looks the same as a leak, so compare two dumps.
  • debug=1 shows less. It has counts, with no wait times or goroutine IDs, and hides most of what a goroutine waits on. Use debug=2 when you can.
  • Wait times are rough. Go only prints a wait of a minute or more, and starts the clock at a garbage collection, so a missing time doesn't mean a short wait.
  • It can't see CPU use. For a program that's slow with nothing parked, take a CPU profile.
  • The list of normally idle stacks is short: the Go runtime, net/http, database/sql, gRPC and golang.org/x/net/http2. Other libraries' background loops show up as groups, but rarely as findings.
  • Dumps can hold file paths and values from your program. stuckgo stays on your machine, but your MCP client sends tool results to its model.

FAQ

How do I find a goroutine leak in Go? Take two dumps some time apart and run stuckgo compare. A growing stack whose goroutine IDs stay in place is the sign to look for.

How do I get a goroutine dump from a running Go program? Import net/http/pprof, then fetch /debug/pprof/goroutine?debug=2. Keep that endpoint private.

What does [chan send, 5 minutes] mean in a goroutine dump? That goroutine has been blocked for about 5 minutes, sending on a channel nothing is receiving from. SG109 covers it.

Why is my Go service out of database connections? Goroutines waiting in database/sql.(*DB).conn mean the pool is full. SG105 flags them. Look at what's holding the connections, such as slow queries or Rows that aren't closed.

How is this different from panicparse or goroutine-inspect? panicparse and goroutine-inspect help a person read and explore a dump. stuckgo gives an agent ranked findings, can compare two dumps, and sets aside what's normally idle.

Tested on

  • Real programs in examples/programs/: every rule from SG101 to SG109, plus SG111, SG114 and SG117, fired on dumps from programs that really got stuck, in examples/dumps/. Most also ran on Go 1.22.
  • Real services: idle Prometheus 3.7.3 and etcd 3.6.5, in examples/dumps/real/, raised nothing above low. Prometheus gets two low WaitGroup findings, which are normal there.
  • Written examples only: SG110, SG112, SG113, SG115 and SG116.
  • MCP tool calls went through the MCP Inspector.

It hasn't been used on an incident in production yet, or in a fresh Claude session.

Contributing

Contributions are welcome, from people and from people working with AI agents. See CONTRIBUTING.md. Good first issues are listed here.

AI disclosure

This project was largely generated with Claude Code and reviewed by its maintainer.

About me

I'm Giulliano Macedo, and I build developer tools at GoTech Solutions. Follow along or get in touch:

If stuckgo found what your program was stuck on, a star helps others find it.


Built by Giulliano Macedo, GoTech Solutions · LinkedIn · X

來源:README.md,提交 6627356

工具

2

go_goroutine_compare

Compare two Go goroutine dumps

Compares two goroutine dumps of one Go program taken some time apart, and shows which stacks are growing and which goroutine IDs never moved, which is stronger evidence of a leak than one dump. It never connects to the program.

輸入參數afterbeforeafter_pathbefore_path

go_goroutine_review

Review a Go goroutine dump

Finds what a stuck or leaking Go program is waiting on, from a goroutine dump: /debug/pprof/goroutine?debug=2 or debug=1, a panic traceback, or SIGQUIT output. Groups identical stacks, separates normal idle goroutines, and flags channel leaks, lock pile-ups with possible holders, WaitGroups that never finish, full database pools, HTTP calls with no timeout and nil channels. It only reads the text you give it and never connects to the program. Findings are leads.

輸入參數dumppath

版本歷史

1
  1. v0.1.0最新Nov 1, 2026

評分

已滿足適用檢查項的 90%

該評分衡量此收錄條目的完整程度,依據註冊中心條目、端點與公開來源計算得出。它不是對伺服器本身的評價,也不表示伺服器安全或目前可用:可連通性是帶日期的檢查結果,評分也不包含安裝量或使用者評價。

  • 近 30 天內可連通25 分
  • 已宣告認證方式10 分

    請在註冊中心條目中宣告憑證請求標頭,或保持端點能夠回應探測,以便判定其認證方式。

  • 已列出工具必需15 分
  • 描述必需15 分
  • 圖示10 分
  • 文件15 分
  • 授權條款10 分