The best-benchmarked open-source AI memory system. And it's free.
Telegram CLI and MCP server for personal accounts
tgcli gives you a command-line way to read, search, send, and archive Telegram messages from your own account. It stores config, sessions, and a local message database in the OS app-data directory, and can also run an optional MCP server for agent access.
Builders who want Telegram chats and archives available from a CLI or agent tool.
You can sync and search Telegram history from the terminal instead of working inside the app.
What it does
Authentication and session setup
`tgcli auth` creates the Telegram session after you enter `api_id` and `api_hash` from my.telegram.org/apps.
Background sync and archive backfill
`tgcli sync` pulls older messages and can keep following new ones in real time with `--follow`.
Message search and listing
`tgcli messages list` and `tgcli messages search` let you browse chats and search archived messages from the CLI.
Send messages and files
`tgcli send` supports sending text and files to users or chats.
Optional MCP server
`tgcli server` can expose Telegram actions over MCP after `tgcli config set mcp.enabled true`.
Local store and service control
The app keeps `config.json`, sessions, and `messages.db` in the store directory and includes `tgcli service` for install, start, stop, status, and logs.
How to get it
- 1Run
npm install -g @kfastov/tgcli
- 2Run
brew install kfastov/tap/tgcli
- 3Run
tgcli auth tgcli sync --follow tgcli messages list --chat @username --limit 20 tgcli messages search "course" --chat @channel --source archive tgcli send text --to @username --message "hello" tgcli server
README
tgcli
Telegram CLI with background sync and an optional MCP server for your personal account (MTProto, not bot API).
Installation
npm install -g @kfastov/tgcli
brew install kfastov/tap/tgcli
Authentication
Get Telegram API credentials:
- Go to https://my.telegram.org/apps
- Log in with your phone number
- Create a new application
- Copy
api_idandapi_hash
Then authenticate:
tgcli auth
Quick start
tgcli auth
tgcli sync --follow
tgcli messages list --chat @username --limit 20
tgcli messages search "course" --chat @channel --source archive
tgcli send text --to @username --message "hello"
tgcli server
Commands
tgcli auth Authentication and session setup
tgcli config View and edit config
tgcli sync Archive backfill and realtime sync
tgcli server Run background sync service (MCP optional)
tgcli service Install/start/stop/status/logs for background service
tgcli channels List/search channels
tgcli messages List/search messages
tgcli send Send text or files
tgcli media Download media
tgcli topics Forum topics
tgcli tags Channel tags
tgcli metadata Channel metadata cache
tgcli contacts Contacts and people
tgcli groups Group management
tgcli doctor Diagnostics and sanity checks
Use tgcli [command] --help for details. Add --json for machine-readable output.
MCP (optional)
Enable it via config:
tgcli config set mcp.enabled true
By default the server binds to http://127.0.0.1:8080/mcp. To change it:
tgcli config set mcp.host 127.0.0.1
tgcli config set mcp.port 8080
Then run tgcli server and point your client at the configured address.
Configuration & Store
The tgcli store lives in the OS app-data directory and contains config.json, sessions, and messages.db.
Override the location with TGCLI_STORE.
Legacy version: see MIGRATION.md.
Files in the repo
- .github
- core
- docs
- scripts
- tests
- .gitignore
- .npmignore
- AGENTS.md
- cli.js
- client.js
- Dockerfile
- LIBRARY.md
- LICENSE
- mcp-server.js
- message-sync-service.js
- MIGRATION.md
- package-lock.json
- package.json
- README.md
- SKILL.md
- store-lock.js
- telegram-client.js
Discussion (0)
Ask about usage, or say what you built with itSign in to join the discussion.
No comments yet. Be the first to say what this is good for.
More tools
Never stop coding. Free MIT AI gateway: one endpoint, 352 providers (150+ free), 1200+ models Kimi, Claude, GPT, Gemini, GLM, DeepSeek, MiniMax. Works with Claude Code, Codex, Cursor, OpenCode, Cline & Copilot. Quota-aware auto-fallback, RTK+Caveman compression saves 15-95% tokens, MCP/A2A, Desktop/PWA. Built by 550+ contributors
Compress tool outputs, logs, files, and RAG chunks before they reach the LLM. 20% fewer tokens for coding agents, 60-95% fewer tokens for JSON, same answers. Library, proxy, MCP server.
Turn any technical book PDF into a Claude Code skill — ready to study, reference, and use while you work.
OfficeCLI is the first and best Office suite purpose-built for AI agents to read, edit, and automate Word, Excel, and PowerPoint files. Free, open-source, single binary, no Office installation required.
Use ChatGPT Web (including Pro) as a native model in Codex — with context, tools, streaming and images, without using Codex quota.