tgcloud — Telegram serverless bots

v0.3.3
io.github.sdamarketing/tgcloud-mcp Checked 4 hours ago Published 1 month ago

MCP server for Telegram serverless bots: lifecycle, deploys, migrations, webhooks via tgcloud CLI

These tools were reported by the server itself during our smoke test (tools/list), not copied from the README.

create_project Create a bot project

Scaffolds a serverless bot with `npm create @tgcloud/bot <name>` inside parent_dir. Needs Node.js 18+ and the npm registry. Does not overwrite existing files.

ParameterTypeDescription
name *stringNew project directory name, for example my-bot
parent_dir *stringAbsolute path of the directory that will contain the new project

init_project Initialize a project in place

Scaffolds tgcloud into an existing directory (tgcloud init, offline): tgcloud/schema.js, handlers/, endpoints/, lib/, tgcloud.jsonc, AGENTS.md, docs/tgcloud-sdk.md. In a front-end project it detects the bundler, sets static.source, and adds an npm run deploy script (build, then push) without overwriting files you already have.

ParameterTypeDescription
project_dir *stringAbsolute path to a tgcloud project directory (contains .tgcloud/)

login_bot Link a bot to the project

Runs `tgcloud login` with a CLI access token (app<id>:<secret> from @BotFather → your bot → Serverless → CLI Access → Access token). This is NOT the Bot API token (123456:AA…). The CLI wants a TTY, so the token is written to stdin with TGCLOUD_ASSUME_TTY=1 and masked in every tool result. NEVER show the token to the user after this call. In CI, set TGCLOUD_TOKEN and skip login.

ParameterTypeDescription
project_dir *stringAbsolute path to a tgcloud project directory (contains .tgcloud/)
token *stringCLI access token from @BotFather (Serverless → CLI Access), form app<id>:<secret>

add_module Add a module

Scaffolds a module with `tgcloud add <target>` (tgcloud/ layout). handlers/<type> is one flat update handler (message, edited_message, callback_query, inline_query, chosen_inline_result, shipping_query, pre_checkout_query, poll, poll_answer, my_chat_member, chat_member, chat_join_request, message_reaction, channel_post, …). endpoints/<name> is a Mini App function (POST /api/<name>; identifier, not starting with a digit). lib/<path> is shared code and may be nested. Existing files are never overwritten.

ParameterTypeDescription
project_dir *stringAbsolute path to a tgcloud project directory (contains .tgcloud/)
target *stringModule path, for example handlers/callback_query, endpoints/getProfile, or lib/cart

upgrade Upgrade a pre-0.2.0 project layout

One-time move of schema.js, handlers/, and lib/ from the project root into tgcloud/ (tgcloud upgrade). Required before other commands on projects created before CLI 0.2.0. Keeps the bot link; nothing needs to be redeployed. dry_run defaults to true and only prints the planned moves. Applying (dry_run: false) requires confirm: true.

ParameterTypeDescription
project_dir *stringAbsolute path to a tgcloud project directory (contains .tgcloud/)
confirmbooleanRequired confirm: true when dry_run is false
dry_runbooleantrue (default) — print planned moves only (--dry-run)

status Project status

Shows local changes against the deployed snapshot (tgcloud status). Offline. Also reports stray .js files inside tgcloud/ that will not deploy, Mini App static diffs, and a webhook that is out of sync with the deployed handlers.

ParameterTypeDescription
project_dir *stringAbsolute path to a tgcloud project directory (contains .tgcloud/)

diff Line diff

Line-by-line diff of the local project against the deployed snapshot (tgcloud diff). Offline.

ParameterTypeDescription
project_dir *stringAbsolute path to a tgcloud project directory (contains .tgcloud/)

push Deploy to the cloud

Uploads changed modules in one atomic batch (tgcloud push). Without files, mirrors the whole local module set (deletions included) and, when tgcloud.jsonc names static.source, uploads that build folder exactly as it is on disk. push never runs the bundler — after front-end edits call deploy, or the previous build goes live. A targeted push never deletes other modules and leaves static files untouched unless the target is the build folder. push does not migrate the database; it only prints pending schema changes. Adding or removing a handler can leave the webhook out of sync — follow with w…

ParameterTypeDescription
project_dir *stringAbsolute path to a tgcloud project directory (contains .tgcloud/)
confirmbooleanRequired confirm: true for destructive operations (the --force flag, reset, and similar)
filesarraySpecific files or directories to deploy; omit to deploy every change
forcebooleanPass --force (dangerous, requires confirm: true)

pull Pull from the cloud

Makes the local project match the cloud: updates the snapshot and working files (tgcloud pull). Does not write the Mini App build folder.

ParameterTypeDescription
project_dir *stringAbsolute path to a tgcloud project directory (contains .tgcloud/)

fetch Refresh the cloud snapshot

Updates the local snapshot of what is deployed without touching working files (tgcloud fetch). Use it before resolving a revision conflict.

ParameterTypeDescription
project_dir *stringAbsolute path to a tgcloud project directory (contains .tgcloud/)

reset Discard local changes

DESTRUCTIVE: discards local module edits and restores the working tree from the last known cloud snapshot (tgcloud reset). Does not touch the Mini App build folder. Requires confirm: true.

ParameterTypeDescription
project_dir *stringAbsolute path to a tgcloud project directory (contains .tgcloud/)
confirmbooleanRequired confirm: true for destructive operations (the --force flag, reset, and similar)

deploy Build the Mini App and push

Runs `npm run build` when package.json has a build script, then `tgcloud push`. Use this after front-end edits: a plain push uploads static.source as it sits on disk and never runs the bundler, so it would publish a stale dist. Does not migrate the database and never passes --force. skip_build=true pushes without building. If there is no build script, only push runs.

ParameterTypeDescription
project_dir *stringAbsolute path to a tgcloud project directory (contains .tgcloud/)
skip_buildbooleantrue — skip npm run build and only push

run_handler Run a module without deploying

Runs a handler or an endpoint on the platform using local files, without publishing them (tgcloud run). args is the payload (a Message for handlers/message, or the endpoint input) as a JSON5 object. ctx is the second argument (--ctx): the raw update for a handler, or initData for an endpoint, for example { initData: { user: { id: 1, first_name: "Ann" } } }. Returns the value, captured console logs, and elapsed time.

ParameterTypeDescription
module *stringModule path, for example handlers/message or endpoints/getProfile
project_dir *stringAbsolute path to a tgcloud project directory (contains .tgcloud/)
argsstringHandler payload or endpoint input as JSON5, for example '{ chat: { id: 1 }, text: "hi" }'
ctxstringSecond-argument context as JSON5 (passed as --ctx)

migrate Database migrations

Applies schema.js changes to the database (tgcloud migrate). push never does this. dry_run defaults to true (--dry-run): preview only. Applying (dry_run: false) requires confirm: true. apply "safe" passes --safe (auto-apply safe changes, skip warnings and manual steps). apply "yes" or omitting apply passes --yes (safe changes plus every warning, including .deprecated drops that delete data; manual type changes are still skipped). local: true diffs against the local schema.js instead of the deployed one (--local) and can be combined with either mode. Show the user the preview before applying. W…

ParameterTypeDescription
project_dir *stringAbsolute path to a tgcloud project directory (contains .tgcloud/)
applystringWhen dry_run is false: "safe" → --safe, "yes" (default) → --yes
confirmbooleanRequired confirm: true to apply migrations, including drops of .deprecated columns and tables
dry_runbooleantrue (default) — preview only (--dry-run)
localbooleanDiff against local schema.js instead of the deployed schema (--local)

webhook_status Webhook status

Shows the platform-managed webhook (tgcloud webhook): URL, allowed_updates, pending update count, the last delivery error, and whether it is in sync with the deployed handlers. First step when a bot is silent. Deploying or removing a handler can leave it out of sync.

ParameterTypeDescription
project_dir *stringAbsolute path to a tgcloud project directory (contains .tgcloud/)

webhook_sync Re-sync the webhook

Points the webhook at the platform and rebuilds allowed_updates from deployed handlers (tgcloud webhook sync). Call it after adding or removing a handler. drop_pending=true discards updates Telegram already queued — destructive, requires confirm: true.

ParameterTypeDescription
project_dir *stringAbsolute path to a tgcloud project directory (contains .tgcloud/)
confirmbooleanRequired confirm: true when drop_pending is true
drop_pendingbooleanDiscard queued updates (--drop-pending, requires confirm: true)