SETUP — tgcloud-mcp step by step#
From zero to an assistant that manages Telegram serverless bots. Other languages: Russian. The shorter install pages are 中文, العربية, Deutsch, Français.
0. You need#
- Node.js 20+ (
node -v) - A Telegram account and a bot created in @BotFather
- A CLI access token (step 2)
- Network access to
cloud.telegram.organdapi.telegram.org
1. Install the server#
Option A — npm (preferred):
Option B — one command (git clone into ~/.tgcloud-mcp, then the wizard):
Option C — Docker:
2. CLI access token#
- Open @BotFather → your bot → Serverless → CLI Access → Access token.
- The token looks like
app<id>:<secret>. It is not the API token (123456:AA…). Turn Serverless on for the bot first.
Two ways to use it:
- Link it to the project:
npx tgcloud loginin the project directory (non-interactive:printf 'app...\n' | TGCLOUD_ASSUME_TTY=1 npx tgcloud login). Thelogin_bottool does this for the agent. - Pass it in the environment (CI):
TGCLOUD_TOKEN='app...'. Thenloginis unnecessary.
The token never appears in tool output. The server masks it.
3. Connect a client#
Automatic: tgcloud-mcp setup (global install) or node ~/.tgcloud-mcp/scripts/setup.mjs.
Ready-made snippets: node scripts/generate-install-links.mjs.
The wizard also offers the Agent Plugin. It copies agent-plugin/ to
~/.tgcloud-mcp/agent-plugin. For Cursor it also copies to
~/.cursor/plugins/local/tgcloud. For VS Code it sets chat.pluginLocations
when settings.json is strict JSON. Codex, Copilot, and Kiro load that directory
from their plugin UI. Claude Code and opencode keep the MCP config and the skill:
Manual fragment (npm):
opencode (~/.config/opencode/opencode.json):
Claude Code / Cursor (mcpServers):
VS Code (mcp.json):
Restart the client. You should see 16 tgcloud tools and the tgcloud://docs/* resources.
4. Server environment#
| Variable | Default | Purpose |
|---|---|---|
TGCLOUD_CLI | npx | CLI launcher (a proxy wrapper or a PATH override is fine) |
TGCLOUD_CLI_ARGS | tgcloud | Arguments before the subcommand |
TGCLOUD_TIMEOUT_MS | 120000 | Timeout of one command. deploy allows at least 300000 ms for the build |
TGCLOUD_TOKEN | — | CLI access token instead of tgcloud login |
5. A first dialogue#
“Create a bot in ~/bots/echo” → the agent calls
create_project, asks for the CLI access token,login_bot, editshandlers/message.js,push,webhook_sync.
Cookbook: docs/cookbook-srl-bot.md (Russian narrative, platform commands).
Troubleshooting#
"tgcloud login" requires an interactive terminal— uselogin_bot(it setsTGCLOUD_ASSUME_TTY=1) orTGCLOUD_TOKEN.Token format looks wrong. Expected "app<id>:<secret>"— that was the API token. You need the CLI access token (step 2).Could not reach the tgcloud server— no route tocloud.telegram.org. PointTGCLOUD_CLIat a wrapper withHTTPS_PROXYandNODE_USE_ENV_PROXY=1.This bot already has N deployed modules (revision R)—fetch, look atdiff, thenpush(or a deliberatepush --forcewith confirm).non-interactive session — specify --safe, --yes, or --dry-run— usemigrate: dry-run by default, ordry_run: falsewithconfirm: true(apply: "safe"orapply: "yes").- Old layout (
schema.jsat the project root) —upgradedry-run, then apply withconfirm: true.