claude-code - 💡(How to fix) Fix Telegram MCP plugin disconnects mid-session on Windows — no auto-reconnect [1 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
anthropics/claude-code#49690Fetched 2026-04-17 08:34:08
View on GitHub
Comments
1
Participants
2
Timeline
5
Reactions
0
Timeline (top)
labeled ×4commented ×1

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 Cause

Root Causes (from code review of server.ts v0.0.6)

Fix Action

Workaround

I've patched my local server.ts with all three fixes above. The patches work but are overwritten on plugin updates.

Code Example

const orphaned =
  (process.platform !== 'win32' && process.ppid !== bootPpid) ||
  process.stdin.destroyed ||
  process.stdin.readableEnded
RAW_BUFFERClick to expand / collapse

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 (/mcp command)
  • Particularly painful for mobile-only users who rely on Telegram as their primary interface

Suggested Fixes

  1. Remove Windows ppid exclusion — Enable orphan detection on all platforms
  2. 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
  3. Add stdout pipe health check — Periodic probe (e.g., every 15s) that detects broken pipes and triggers shutdown
  4. 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.

extent analysis

TL;DR

Apply the suggested fixes to the Telegram MCP plugin, specifically removing the Windows ppid exclusion, adding a polling timeout, and implementing a stdout pipe health check to prevent disconnections.

Guidance

  • Remove the Windows ppid exclusion by modifying the orphaned check in server.ts to include Windows platforms.
  • Add a polling timeout to bot.start() using an AbortController to prevent the server from becoming unresponsive due to hanging Telegram API calls.
  • Implement a periodic stdout pipe health check to detect broken pipes and trigger shutdown, ensuring the server process does not persist indefinitely.

Example

const orphaned =
  (process.ppid !== bootPpid) ||
  process.stdin.destroyed ||
  process.stdin.readableEnded

This example shows the modified orphaned check without the Windows exclusion.

Notes

The suggested fixes are specific to the Telegram MCP plugin and may not apply to other plugins. Additionally, the patches may be overwritten on plugin updates, so a more permanent solution, such as implementing MCP-level auto-reconnect, may be necessary.

Recommendation

Apply the workaround by patching the server.ts file with the suggested fixes, as it has been proven to work locally, but be aware that this is a temporary solution until a more permanent fix is implemented.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING