Plugins: support singleton mode for plugins that can't run multiple instances (e.g. Telegram polling)
Summary
Plugins that use exclusive external resources (e.g. Telegram bot long-polling) break when multiple Claude Code sessions are active. Each session spawns its own plugin MCP server instance, and they compete for the same resource — in Telegram's case, only one getUpdates consumer is allowed per bot token (409 Conflict).
Environment
- Multiple Claude Code sessions in the same project (tmux panes)
- Spawned Claude subprocesses (
system/spawn-claude, worker subtasks) also inherit plugin config and spawn additional instances - Plugin:
telegram@claude-plugins-official(research)
What happens
- User enables the Telegram plugin in
~/.claude/settings.json(enabledPlugins) - Opens multiple Claude Code sessions in the same project
- Each session + each spawned subprocess starts its own
bun server.tsfor the Telegram plugin - Multiple instances fight over the Telegram polling slot (409 Conflict with backoff/retry)
- Messages arrive at a random instance — the MCP notification goes to whichever session won the poll, not necessarily the one the user is interacting with
- No way to enable the plugin for just one session —
enabledPluginsis user-global
Observed instance counts
With 10+ Claude sessions and spawned workers, we saw 3-6 simultaneous bot instances at any given time. Manually killing competing instances was a game of whack-a-mole since new sessions and workers kept spawning them.
Feature request
Support a singleton mode for plugins, so that only one instance runs across all sessions. Possible approaches:
- Plugin manifest
singleton: true— plugin declares it needs exclusive access. The first session starts it; others connect to the existing instance or skip it. - Lock file — plugin acquires a lock on startup; subsequent instances detect the lock and exit gracefully.
- Per-session plugin toggle — allow enabling/disabling plugins per-session (not just user-global), so the user can choose which session runs the Telegram bridge.
- Exclude spawned subprocesses — spawned Claude instances (
--session-id,-pwith inline prompts) should not inherit plugin config, or should have a flag to opt out.
Option 4 is particularly important — even with a singleton lock, spawned worker subprocesses shouldn't be starting channel plugins at all.
Workaround
Disabled the plugin entirely. No viable workaround for multi-session use.
Labels
Research feedback — the Telegram plugin is marked as research/0.0.1.
This issue has 4 comments on GitHub. Read the full discussion on GitHub ↗