[BUG] SDK mcpServerStatus() hangs when called outside streaming loop
Bug Description
Query.mcpServerStatus() hangs indefinitely (promise never resolves) when called after the for await streaming loop has completed, even though the Query instance is still alive and not closed.
Steps to Reproduce
- Create a query with
query()and iterate through the streaming loop - After the loop completes (session idle), call
queryInstance.mcpServerStatus() - The returned promise never resolves
const generator = await query({ prompt, options })
for await (const message of generator) {
// process messages...
}
// Session is idle, but queryInstance is still alive (not closed)
const statuses = await generator.mcpServerStatus() // ← hangs forever
Expected Behavior
mcpServerStatus() should resolve with the current MCP server statuses, regardless of whether the streaming loop is active.
Actual Behavior
The promise never resolves or rejects. No timeout, no error.
Workaround
Call mcpServerStatus() inside the streaming loop (e.g., right after system:init) and cache the result for later use.
Context
Building an MCP status indicator for Better Agent Terminal. Other Query methods like accountInfo() and supportedCommands() appear to have the same limitation — they only work reliably during active streaming.
Environment
@anthropic-ai/claude-agent-sdk: 0.2.81- Node.js: v20.19.3
- macOS (Darwin 24.6.0)
This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗