Using mtcute
Multi-account Telegram CLI for syncing chats, searching messages locally, listening in real time, auto-downloading attachments, and managing messages from your terminal.
npx -y skills add will-17173/telegram-cli --skill using-mtcuteAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
2 things to look at
- 29 days oldThe repository was created 29 days ago. New is not bad, but a brand new repository carrying a familiar-sounding name is the shape a typosquat arrives in, and there has been no time for anyone else to find a problem with it.
- 5 stars5 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.
What its author says it does
Copied from the file, not written here
Use when working with mtcute, @mtcute/* packages, Telegram MTProto in TypeScript, TL types, Telegram API methods, or building Telegram bots/clients/userbots with mtcute. Trigger for tasks involving TelegramClient, Dispatcher, filters, raw TL API calls, mtcute storage, sessions, media/files, keyboards, parse modes, or mtcute API lookup. Do not use for Bot API wrapper libraries such as grammy, telegraf, or node-telegram-bot-api unless the task is migrating from them to mtcute.
SKILL.md
4.6 KB, ~1.0k tokens by cl100k_base, as published. Nobody here has run it
using mtcute
Core Rule
Treat mtcute as a TypeScript MTProto library, not a Bot API wrapper. Prefer high-level TelegramClient methods first, then raw TL .call() only when there is no high-level method.
Use the platform package for the target runtime:
import { TelegramClient } from '@mtcute/node'
Do not import TelegramClient from @mtcute/core in normal apps; platform packages preconfigure runtime crypto, storage, transport, and file helpers.
Workflow
- Identify the runtime and install/import the right package:
- Node.js:
@mtcute/node - Bun:
@mtcute/bun - Deno:
jsr:@mtcute/deno - Browser:
@mtcute/web - Update routing: add
@mtcute/dispatcher - PostgreSQL storage: add
@mtcute/postgresandpgor PGlite
- Node.js:
- Search the current project before writing code. Reuse existing client construction, storage names, dispatcher setup, env handling, and logging patterns.
- Use the bundled lookup scripts in this skill directory to inspect the installed/generated API when method names, options, or TL types are uncertain.
- Read only the relevant reference file:
references/app-patterns.mdfor clients, auth, storage, updates, dispatcher, errors, and common implementation patterns.references/api-lookup.mdfor high-level method lookup, raw TL calls, and TypeDoc/reference navigation.
- Verify with the project’s TypeScript/test commands when code changes are made.
Minimal Bot
import { Dispatcher, filters } from '@mtcute/dispatcher'
import { TelegramClient } from '@mtcute/node'
const tg = new TelegramClient({
apiId: Number(process.env.API_ID),
apiHash: process.env.API_HASH!,
storage: 'bot.session',
})
const dp = Dispatcher.for(tg)
dp.onNewMessage(filters.command('start'), async (msg) => {
await msg.replyText('Hello from mtcute')
})
await tg.start({ botToken: process.env.BOT_TOKEN })
Method And Type Lookup
Resolve bundled scripts relative to this SKILL.md file, not relative to the user's project. In examples below, replace <skill-dir> with the absolute path to the directory containing this SKILL.md.
node <skill-dir>/scripts/get-method.js sendText
node <skill-dir>/scripts/get-method.js --search forum
node <skill-dir>/scripts/get-class.js Message
node <skill-dir>/scripts/get-constructor.js --with-references messages.sendMessage
Run these commands from the project or app root so the scripts can resolve local node_modules or the mtcute monorepo workspace. Use these scripts before guessing signatures. They read the installed @mtcute/* packages or this monorepo workspace and support fuzzy matching.
Key Practices
- Keep secrets in environment variables:
API_ID,API_HASH,BOT_TOKEN, session strings. - Use persisted storage for real apps. String storage names map to runtime defaults: SQLite in Node/Bun/Deno, IndexedDB in web.
- Pass
InputPeerLikevalues directly to high-level methods:'me', usernames, marked IDs,User,Chat,Message, or input peers. - Prefer
Chat,User,Message, or.inputPeerover username/phone when a peer object is already available. - Use
@mtcute/dispatcherfor bots with update routing, filters, middleware, scenes, state, or callback handling. - Use
html,thtml, ormdtagged templates for formatted text instead of manually building entities unless the task requires raw entities. - Use
InputMediaandBotKeyboardbuilders for media and keyboards. - For raw TL calls, read
node_modules/@mtcute/core/tl/index.d.tsor useget-constructor.js; handle returnedUpdateswithtg.handleClientUpdate(...)when needed. - Handle
tl.RpcError.is(e, 'FLOOD_WAIT_%d')and other RPC errors explicitly when user-facing behavior matters.
Source Material
Local docs are in docs/guide. Hosted docs and API reference:
- Guide:
https://mtcute.dev/guide/ - API reference:
https://ref.mtcute.dev/ - LLM index:
https://mtcute.dev/llms.txt
Prefer local docs in this repository when available because they match the source checkout. Use the hosted TypeDoc reference for exact public API pages or when working outside this repo.
What ships with it: 6 files
67.1 KB alongside SKILL.md, 3 of them executable
agents/
- openai.yaml204 B
references/
- api-lookup.md3.5 KB
- app-patterns.md4.0 KB
scripts/
- get-class.jsruns18.5 KB
- get-constructor.jsruns23.9 KB
- get-method.jsruns17.0 KB