[BUG] SDK mcpServerStatus() hangs when called outside streaming loop

Resolved 💬 2 comments Opened Mar 28, 2026 by handpower Closed Apr 28, 2026

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

  1. Create a query with query() and iterate through the streaming loop
  2. After the loop completes (session idle), call queryInstance.mcpServerStatus()
  3. 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)

View original on GitHub ↗

This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗