Telegram MCP plugin disconnects mid-session on Windows — no auto-reconnect
Description
The Telegram MCP plugin (plugin:telegram:telegram) disconnects mid-session on Windows, breaking Telegram-based communication. Since there's no auto-reconnect mechanism, the only fix is manually running /mcp in the terminal — which is impossible when communicating solely via Telegram away from the computer.
Root Causes (from code review of server.ts v0.0.6)
1. Windows orphan detection is disabled (line 660)
const orphaned =
(process.platform !== 'win32' && process.ppid !== bootPpid) ||
process.stdin.destroyed ||
process.stdin.readableEnded
The ppid reparenting check is explicitly skipped on Windows, so orphaned server processes persist indefinitely.
2. No timeout on Telegram polling (line 996)
bot.start() uses Grammy's long-polling with no timeout. If a Telegram API getUpdates call hangs, the server becomes deaf to inbound messages while the MCP connection still appears alive. The process stays running (stdin keeps it alive), but the bot is unresponsive.
3. No MCP pipe health check
The server relies on stdin end/close events to detect disconnection, but on Windows these events don't reliably fire when the parent process chain is severed. There's no periodic probe to detect a broken pipe.
Impact
- Users communicating via Telegram lose the ability to send/receive messages mid-session
- The server process continues running as a zombie, holding the bot token
- No way to recover without terminal access (
/mcpcommand) - Particularly painful for mobile-only users who rely on Telegram as their primary interface
Suggested Fixes
- Remove Windows ppid exclusion — Enable orphan detection on all platforms
- Add polling timeout — Wrap
bot.start()with an AbortController timeout (e.g., 5 minutes); on timeout, stop and restart the poll loop instead of exiting - Add stdout pipe health check — Periodic probe (e.g., every 15s) that detects broken pipes and triggers shutdown
- Consider MCP-level auto-reconnect — A general mechanism for Claude Code to detect and reconnect dropped MCP servers would solve this for all plugins, not just Telegram
Environment
- Windows 10 Home 10.0.19045
- Claude Code CLI (latest)
- Telegram plugin v0.0.6
- Bun runtime
- Git Bash shell
Workaround
I've patched my local server.ts with all three fixes above. The patches work but are overwritten on plugin updates.
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗