| name | telegram-multi-session |
| description | Install, repair, and manage the multi-session Telegram channel server that allows switching between Claude Code sessions from Telegram |
| user_invocable | true |
| tools_required | ["Bash","Read","Edit","Write"] |
/telegram-multi-session — Multi-Session Telegram Channel Manager
Manages the custom multi-session Telegram server that replaces the default plugin
server. This skill is self-contained: server.ts lives inside the skill
directory and is deployed by the install command.
Throughout this skill, <tg-state> refers to the Telegram state directory.
Resolve it at runtime:
TG_STATE="${GOVERNED_WORKFLOW_TELEGRAM_STATE:-$(python3 -c 'from core.paths import REPO_ROOT; print(REPO_ROOT)')/.local/channels/telegram}"
If GOVERNED_WORKFLOW_TELEGRAM_STATE is not set, the default is <repo>/.local/channels/telegram/.
The source server.ts lives inside this skill directory and is deployed to <tg-state>/server.ts.
Arguments passed: (check the args variable from the skill invocation)
Dispatch on arguments
Parse the arguments (space-separated). If empty or unrecognized, run status.
No args — status
- Check if custom server exists at
<tg-state>/server.ts
- Check if
.mcp.json in the telegram plugin directory is patched (points to custom server vs default)
- Check if
<tg-state>/.env exists and contains BOT_TOKEN
- Read all files from
<tg-state>/sessions/, check PID liveness, list active sessions
- Report overall status: installed/not installed, patched/not patched, token present/missing, active sessions
install
- Create
<tg-state>/ if it doesn't exist
- Copy
server.ts from the skill directory to <tg-state>/server.ts:
cp <skill-dir>/server.ts "$TG_STATE/server.ts"
- Install dependencies alongside the server:
cp ~/.claude/plugins/cache/claude-plugins-official/telegram/$(ls ~/.claude/plugins/cache/claude-plugins-official/telegram/)/package.json "$TG_STATE/"
cd "$TG_STATE" && bun install --no-summary
Note: Bun resolves node_modules relative to the file location, not --cwd. Installing dependencies here ensures the server can find grammy and @modelcontextprotocol/sdk.
- Find the telegram plugin directory:
ls ~/.claude/plugins/cache/claude-plugins-official/telegram/
Use the latest version directory.
- Read the current
.mcp.json in that directory and patch it to point to the custom server:
{
"mcpServers": {
"telegram": {
"command": "bun",
"args": ["run", "/absolute/path/to/tg-state/server.ts"]
}
}
}
Use the actual expanded path to <tg-state>/server.ts (no ~ or env vars — bun requires an absolute literal path).
- Check if
<tg-state>/.env exists with a BOT_TOKEN line. If not, tell the user:
Bot token not found. Create <tg-state>/.env with:
BOT_TOKEN=your_token_here
- Confirm installation and tell the user to restart Claude Code sessions for the change to take effect.
repair
Re-patches .mcp.json after a plugin update overwrites it. Does NOT re-copy
server.ts unless --force is passed.
Steps:
- If
--force flag is present, copy server.ts from skill directory to <tg-state>/server.ts
- If
<tg-state>/node_modules is missing, re-run bun install:
cd "$TG_STATE" && bun install --no-summary
- Run install steps 4-5 (find plugin dir, patch
.mcp.json)
- Confirm and tell user to restart Claude Code sessions.
update
Deploys the latest server.ts from the skill directory, overwriting the currently
deployed one. Use this after editing the source file in the skill directory.
Steps:
- Copy
<skill-dir>/server.ts to <tg-state>/server.ts
- Confirm the update. Remind user to restart Claude Code sessions.
uninstall
Restore .mcp.json to the default plugin config. Does NOT delete the custom server.
Steps:
- Find the telegram plugin directory
- Restore
.mcp.json to the default:
{
"mcpServers": {
"telegram": {
"command": "bun",
"args": ["run", "--cwd", "${CLAUDE_PLUGIN_ROOT}", "--shell=bun", "--silent", "start"]
}
}
}
- Confirm uninstall. Note that
server.ts and .env are preserved.
sessions
- Read all files from
<tg-state>/sessions/
- For each, parse JSON and check if PID is still alive (
kill -0 <pid>)
- Display: session name, PID, uptime, alive/dead status
- Clean up dead session files (delete them)
name <new-name>
Set the session name for the CURRENT session by calling the set_session_name MCP tool.
Note: this only works if the multi-session server is running in this session.
The tool is available as mcp__plugin_telegram_telegram__set_session_name.
How it works
- Session names default to the basename of the working directory (PWD) where
Claude Code was launched. The
WORKSPACE environment variable overrides this
(WORKSPACE=work claude --channels ...). If neither is set, a random s-<4hex>
name is used. Names can also be changed at runtime via set_session_name or
/telegram-multi-session name <name>.
- Outbound replies are automatically prefixed with
[session-name] so the
user can tell which Claude Code session is responding.
- From Telegram: send
/sessions to list active sessions, /switch <name> to
route incoming messages to a specific session.
- MCP tools available in each session:
claim_channel, channel_status,
set_session_name.
- Dependencies: Each deployed server has its own
node_modules alongside it.
This is required because bun resolves modules relative to the file location, not
the working directory.
- Plugin updates overwrite
.mcp.json but not the deployed server.ts. Run
/telegram-multi-session repair after any plugin update.
Troubleshooting
Portability
This skill is self-contained. server.ts is bundled inside the skill directory
so no external source is needed on a new device.
To set up on a new device:
- The skill ships with the repo at
<repo>/claude/skills/telegram-multi-session/
- Make sure the telegram plugin is installed (
plugin:telegram@claude-plugins-official)
- Run
/telegram-multi-session install — this also installs dependencies automatically
- Create
<tg-state>/.env with BOT_TOKEN=your_token_here if not transferred
Note: node_modules/, bun.lock, and package.json in <tg-state>/ are NOT
transferred between devices — they are regenerated by the install command.