Telegram plugin MCP server crashes: missing error handler on bot.start()
Description
The official Telegram channel plugin (claude-plugins-official/telegram/0.0.1) MCP server crashes repeatedly during sessions. The server dies within seconds of a successful reply tool call.
Root Cause
In server.ts, grammy's bot.start() (line 596) is called with void (fire-and-forget) and no .catch(). There is also no bot.catch() handler registered.
void bot.start({
onStart: info => {
botUsername = info.username
process.stderr.write(`telegram channel: polling as @${info.username}\n`)
},
})
If grammy's long-polling loop encounters any error (network hiccup, Telegram API rate limit, malformed response), the returned promise rejects. Since it was called with void, this becomes an unhandled promise rejection, which in Bun kills the process by default.
The MCP stdio transport and grammy's polling run concurrently. When the bot process dies, Claude Code reports "MCP server disconnected."
Steps to Reproduce
- Install the Telegram plugin and configure a bot token
- Start a Claude Code session with
--channels plugin:telegram@claude-plugins-official - Pair a Telegram account
- Send a message from Telegram, have Claude reply
- Server crashes within seconds. Telegram messages stop arriving.
/mcpreconnect works but server crashes again quickly.
Suggested Fix
Add error handlers to prevent unhandled rejections from killing the process:
bot.catch(err => {
process.stderr.write(`telegram channel: bot error: ${err.message ?? err}\n`)
})
bot.start({
onStart: info => {
botUsername = info.username
process.stderr.write(`telegram channel: polling as @${info.username}\n`)
},
}).catch(err => {
process.stderr.write(`telegram channel: bot.start() failed: ${err.message ?? err}\n`)
})
process.on('unhandledRejection', err => {
process.stderr.write(`telegram channel: unhandled rejection: ${err}\n`)
})
Environment
- Claude Code: latest (2026-03-20)
- Windows 11
- Bun (bundled with plugin)
- Telegram plugin: 0.0.1
Related Issues
- #36427 - Telegram plugin MCP server disconnects despite active polling
- #36615 - Telegram MCP server disconnects silently after idle period
- #15904 - Feature request for auto-reconnect (closed)
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗