claude-code - 💡(How to fix) Fix Telegram plugin MCP server disconnects after ~3 messages in --channels mode [1 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#53270Fetched 2026-04-26 05:20:00
View on GitHub
Comments
0
Participants
1
Timeline
7
Reactions
0
Participants
Timeline (top)
labeled ×5closed ×1cross-referenced ×1

The Telegram plugin (telegram@claude-plugins-official) consistently disconnects after handling roughly 3 message exchanges when running in --channels mode. Claude Code is closing the stdio pipe to the MCP server every 1-5 minutes, triggering the plugin's graceful shutdown.

The plugin itself is not crashing — it's being shut down by Claude Code recycling the MCP connection.

Root Cause

The Telegram plugin (telegram@claude-plugins-official) consistently disconnects after handling roughly 3 message exchanges when running in --channels mode. Claude Code is closing the stdio pipe to the MCP server every 1-5 minutes, triggering the plugin's graceful shutdown.

The plugin itself is not crashing — it's being shut down by Claude Code recycling the MCP connection.

Code Example

[2026-04-25T13:33:16.332Z] -- server.ts boot pid=3647090 ppid=3647051 --
[2026-04-25T13:33:16.424Z] telegram channel: polling as @claudsky_bot
[2026-04-25T13:36:09.105Z] telegram channel: shutting down (cause=stdin-end)3 min

[2026-04-25T13:36:12.187Z] -- server.ts boot pid=3648669 ppid=3648664 --
[2026-04-25T13:36:12.348Z] telegram channel: polling as @claudsky_bot
[2026-04-25T13:37:05.188Z] telegram channel: shutting down (cause=stdin-end)53 sec

[2026-04-25T13:37:35.591Z] -- server.ts boot pid=3649277 ppid=3649271 --
[2026-04-25T13:37:35.705Z] telegram channel: polling as @claudsky_bot
[2026-04-25T13:38:44.195Z] telegram channel: shutting down (cause=stdin-end)1 min

---

[13:26:54.601Z] boot pid=3635290 ppid=3635263
[13:26:54.609Z] replacing stale poller pid=3628607
[13:26:54.709Z] shutting down (cause=SIGTERM)        ← killed 108ms after boot
[13:26:54.693Z] boot pid=3635289 ppid=3635270        ← second instance kills first
[13:26:54.700Z] replacing stale poller pid=3635290

---

// server.ts:668-672
process.stdin.on('end', () => shutdown('stdin-end'))
process.stdin.on('close', () => shutdown('stdin-close'))
process.on('SIGTERM', () => shutdown('SIGTERM'))
RAW_BUFFERClick to expand / collapse

Description

The Telegram plugin (telegram@claude-plugins-official) consistently disconnects after handling roughly 3 message exchanges when running in --channels mode. Claude Code is closing the stdio pipe to the MCP server every 1-5 minutes, triggering the plugin's graceful shutdown.

The plugin itself is not crashing — it's being shut down by Claude Code recycling the MCP connection.

Environment

  • Claude Code version: 2.1.119
  • Plugin version: claude-channel-telegram 0.0.6
  • Platform: Linux 6.8.0-106-generic
  • Launch command: claude --dangerously-skip-permissions --channels plugin:telegram@claude-plugins-official

Evidence from debug.log

The plugin logs its full lifecycle to ~/.claude/channels/telegram/debug.log. Here's the repeating pattern — every instance lives 1-5 minutes before being killed:

[2026-04-25T13:33:16.332Z] -- server.ts boot pid=3647090 ppid=3647051 --
[2026-04-25T13:33:16.424Z] telegram channel: polling as @claudsky_bot
[2026-04-25T13:36:09.105Z] telegram channel: shutting down (cause=stdin-end)    ← 3 min

[2026-04-25T13:36:12.187Z] -- server.ts boot pid=3648669 ppid=3648664 --
[2026-04-25T13:36:12.348Z] telegram channel: polling as @claudsky_bot
[2026-04-25T13:37:05.188Z] telegram channel: shutting down (cause=stdin-end)    ← 53 sec

[2026-04-25T13:37:35.591Z] -- server.ts boot pid=3649277 ppid=3649271 --
[2026-04-25T13:37:35.705Z] telegram channel: polling as @claudsky_bot
[2026-04-25T13:38:44.195Z] telegram channel: shutting down (cause=stdin-end)    ← 1 min

Session duration summary (April 25)

DurationCause
2 minstdin-end
4 minSIGTERM (replaced by new instance)
3 minstdin-end
53 secstdin-end
1 minstdin-end
1 minSIGTERM
44 secstdin-end
2 minstdin-end

Average: ~2 minutes per session. At ~30-60s per Telegram round-trip, that's exactly ~3 commands before disconnect.

Shutdown causes

  • ~70% stdin-end: Claude Code closes its end of the stdio pipe, the plugin's process.stdin emits 'end', triggering graceful shutdown. This is the MCP host recycling the connection.
  • ~30% SIGTERM: A new plugin instance boots, finds the old PID still running via bot.pid, and sends SIGTERM (stale-poller replacement — working as designed, but shouldn't fire this often).

Race condition (secondary issue)

Occasionally two instances boot within the same millisecond and kill each other:

[13:26:54.601Z] boot pid=3635290 ppid=3635263
[13:26:54.609Z] replacing stale poller pid=3628607
[13:26:54.709Z] shutting down (cause=SIGTERM)        ← killed 108ms after boot
[13:26:54.693Z] boot pid=3635289 ppid=3635270        ← second instance kills first
[13:26:54.700Z] replacing stale poller pid=3635290

Expected behavior

In --channels mode, the MCP connection to the Telegram plugin should remain alive for the duration of the Claude session, not be recycled every 1-5 minutes. The Telegram plugin needs a persistent connection to maintain its polling loop and deliver inbound messages.

Plugin shutdown logic (for reference)

The plugin's shutdown is correct — it terminates when stdin closes to prevent zombie polling processes holding the Telegram bot token:

// server.ts:668-672
process.stdin.on('end', () => shutdown('stdin-end'))
process.stdin.on('close', () => shutdown('stdin-close'))
process.on('SIGTERM', () => shutdown('SIGTERM'))

The issue is on the Claude Code side — the MCP host shouldn't be closing the pipe this frequently in channel mode.

extent analysis

TL;DR

The Telegram plugin disconnects due to Claude Code recycling the MCP connection, causing the plugin to shut down after 1-5 minutes, and a potential fix involves modifying Claude Code to maintain a persistent connection in --channels mode.

Guidance

  • Investigate Claude Code's connection recycling mechanism to determine why it's closing the stdio pipe every 1-5 minutes in --channels mode.
  • Consider modifying Claude Code to exempt the Telegram plugin from connection recycling or to increase the recycling interval.
  • Review the plugin's shutdown logic to ensure it's correctly handling the stdin-end event and SIGTERM signals.
  • To mitigate the race condition, explore ways to synchronize the boot process of multiple plugin instances.

Example

No code example is provided as the issue is related to the interaction between Claude Code and the Telegram plugin, and any modifications would require a deeper understanding of the Claude Code's internal mechanics.

Notes

The issue is specific to the interaction between Claude Code and the Telegram plugin, and resolving it may require changes to Claude Code's connection management or the plugin's shutdown logic. The provided information suggests that the plugin's shutdown logic is correct, and the issue lies with Claude Code's connection recycling.

Recommendation

Apply a workaround to modify Claude Code's connection recycling mechanism to maintain a persistent connection in --channels mode, as upgrading to a fixed version is not mentioned in the issue. This would require a deeper understanding of Claude Code's internal mechanics and may involve modifying its source code.

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…

FAQ

Expected behavior

In --channels mode, the MCP connection to the Telegram plugin should remain alive for the duration of the Claude session, not be recycled every 1-5 minutes. The Telegram plugin needs a persistent connection to maintain its polling loop and deliver inbound messages.

Still need to ship something?

×6

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

Back to top recommendations

TRENDING

claude-code - 💡(How to fix) Fix Telegram plugin MCP server disconnects after ~3 messages in --channels mode [1 participants]