Channel notifications dropped during hook execution
Problem
MCP channel notifications (e.g., Telegram messages) are dropped when Claude Code is executing hooks (Stop, PreToolUse, PostToolUse, etc.). The hook blocks the event loop, and incoming notifications/claude/channel messages are either not read from stdin or read but not processed.
Reproduction
- Configure a Stop hook with a long-running script (~30-120s)
- Connect the Telegram MCP channel plugin
- Send a Telegram message while the Stop hook is executing
- Message never appears in the conversation
Root Cause
The MCP plugin delivers inbound messages via mcp.notification() — fire-and-forget per MCP spec. The notification is written to stdio and may buffer in the OS pipe, but Claude Code's event loop doesn't process channel notifications while hooks are running. When the hook completes, buffered notifications appear to be discarded.
The plugin has zero visibility into Claude Code's processing state — no ack, no backpressure, no busy signal. There is no reliable plugin-side mitigation.
Proposed Fix
Buffer notifications/claude/channel messages received during hook execution and process them when hooks complete. This should be a small change in Claude Code's hook execution path — essentially queue channel notifications instead of dropping them when the main loop is blocked.
Workaround
Remove long-running hooks (e.g., moving CI validation from Stop hook to git's native pre-push hook via husky). This reduces the window where messages can be dropped but doesn't eliminate it.
Environment
- Claude Code CLI (latest)
- Telegram channel plugin v0.0.4
- MCP SDK
@modelcontextprotocol/sdk^1.0.0
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗