English · Русский
Ask your coding agent "what did the team discuss this week?" and it actually knows.
Half of every project's real context lives in Telegram: decisions made in group chats, specs shared as files, links that never made it to the wiki. This tool gives that context to Claude Code, Codex, or any agent that can run a CLI.
The tg CLI signs in as you (MTProto via Telethon), syncs your chats into a local SQLite index with full-text search, and installs an agent skill that activates itself whenever you mention your chats. Agents read locally: instant, offline, no rate limits. The CLI touches Telegram only to sync, download files, or (after your explicit "yes") send a reply.
Install
Pick any of the three. Each one ends in the interactive setup wizard: sign-in, agent skill, desktop apps, initial sync. No API keys needed: press Enter and the built-in Telegram Desktop keys are used (your own from my.telegram.org stay recommended for heavy syncing).
# with uv (recommended)
uv tool install telegram-to-agent-skill-cli && tg setup
# one-shot, no prior install
uvx --from telegram-to-agent-skill-cli tg setup
# via npm, if Node is your home turf
npx telegram-to-agent-skill-cli
Developers clone the repo and run ./install.sh (editable install, same wizard). Details: docs/INSTALL.md.
Claude Code users can also add the repo as a plugin marketplace, which installs the skill without touching the shell:
/plugin marketplace add voftik/telegram-to-agent-skill-cli
/plugin install telegram-context@telegram-to-agent-skill-cli
The CLI itself still comes from PyPI (the skill will tell you the install command if tg is missing).
Update
tg update # checks PyPI, upgrades, refreshes the agent skill
tg update --check # just report; agents read update.update_available from `tg status --yaml`
The CLI never phones home on its own in data commands: the passive version hint reads a local cache and prints to stderr only in interactive sessions. Set TG_UPDATE_CHECK=0 to silence it.
Desktop chat apps
Claude Desktop, Perplexity and ChatGPT (chat mode) cannot run a CLI, but they can run local MCP servers. One command wires them to the same local index through tg mcp, a read-only bridge that never touches the Telegram session:
tg connect
It detects the apps, writes their configs, self-tests the bridge and offers tg autosync (a scheduled refresh that keeps the index fresh). Details per app: docs/DESKTOP-APPS.md (in Russian).
Why skill-first (and where the MCP bridge fits)
- Zero context tax. MCP tool schemas eat tokens in every session. A skill loads on demand; the CLI costs nothing until used. Coding agents (Claude Code, Codex) get the full skill + CLI.
- One integration, every agent. The same
tgcommands work in Claude Code, Codex, and anything else with a shell. - No session juggling. Sync is owned by one CLI process on the host; any number of agent sessions read the SQLite index. The bundled
tg mcpbridge follows the same rule: it is a read-only adapter for hosts without a shell, six small tools, no Telegram session, no sends.
How it works
flowchart LR
TG[("Telegram<br/>(your account, MTProto)")]
subgraph LOCAL["Your machine"]
SYNC["tg sync / refresh<br/><i>on demand</i>"]
DB[("SQLite + FTS5<br/>messages · attachments · links · threads")]
FILES["files/ + extracted text<br/>pdf · docx · xlsx · pptx"]
QUERY["tg brief · search · thread<br/>links · files · style"]
end
subgraph AGENTS["Agents"]
CC["Claude Code<br/><i>skill auto-activates</i>"]
CX["Codex<br/><i>via AGENTS.md</i>"]
end
TG -->|history| SYNC --> DB
TG -->|lazy download| FILES
DB --> QUERY
QUERY --> CC & CX
FILES --> CC & CX
CC & CX -.->|"send only with --confirm<br/>after explicit user yes"| TG
What agents can do with it
| Ask in plain language | What happens under the hood |
|---|---|
| "What did we discuss in the project chat?" | sync, then brief picks the depth, then recent and a summary with dates and authors |
| "Find where they shared the pricing doc" | tg links --kind gdoc returns the export URL (plain text, not a JS shell) |
| "Read the spec they sent as a file" | tg files --download extracts text next to the file |
| "Reconstruct that argument about the deadline" | tg thread rebuilds the reply chain, even when the root is a poll |
| "Draft a reply in my voice" | tg style gives the agent your own messages; drafts stay dry-run until you say yes |
| "Digest my work chats since yesterday" | the agent loops chats, collects highlights, flags what needs your reaction |
Safety model
- The Telethon session file equals full account access. It lives in a private data dir (0700/0600), never in git, never in cloud-synced folders; every machine signs in separately.
- Every write to Telegram (
send,edit,delete) is a dry-run without--confirm. Confirmed mutations land in a durable journal before the network call. - Untrusted attachments face budgets: size checks before download, zip-bomb guards, streaming hashes, private file modes.
- Use your own
api_idandapi_hash. The tool syncs politely (delays, jitter, FloodWait handling) and reads locally.
How it compares
Honest comparison with the other ways to give an agent your Telegram (state of the ecosystem, August 2026):
| tg (this project) | Telegram MCP servers¹ | Upstream tg-cli | Telegram Desktop export | |
|---|---|---|---|---|
| Works in any CLI agent | yes, one install | per-agent MCP config | yes | manual copy-paste |
| Session context cost | zero until used | tool schemas eat tokens in every session | zero | zero |
| Search over all history | FTS5, milliseconds, offline | live API calls, rate-limited | LIKE scan |
none (static files) |
| Attachments as readable text | pdf/docx/xlsx/pptx extracted | download at best | not stored | raw files |
| Google Docs links | ready-to-fetch export URLs | no | no | no |
| Thread reconstruction | yes, incl. t.me links | partial | no | no |
| Parallel agent sessions | any number of readers | session-file conflicts² | single user | n/a |
| Send safety | dry-run default, --confirm, journal |
varies; several send immediately | sends immediately | n/a |
| Sync integrity | gap-safe cursors, tg backfill |
n/a (live reads) | best effort | one-off snapshot |
| Data freshness | incremental sync in seconds | always live | incremental | frozen at export |
| Install and update | npx/uv one-liner, tg update |
manual server config | pip | built into the app |
¹ chigwell/telegram-mcp, chaindead/telegram-mcp, overpod/mcp-telegram and similar. They still fit when your agent lives in claude.ai web, which cannot spawn local processes at all; chaindead's drafts-only design is a genuinely safe touch. Desktop hosts (Claude Desktop, Perplexity, ChatGPT desktop) are covered by the bundled read-only tg mcp bridge instead.
² Telethon/GramJS allow one process per session file; MCP servers spawn per agent session and collide (the shared-daemon setups that avoid this need extra configuration).
What the fork adds over upstream tg-cli
| Area | upstream | this fork |
|---|---|---|
| Attachments | not stored | indexed at sync, lazy download, text extraction (pdf/docx/xlsx/pptx/csv) |
| Links | not extracted | tg links with agent-fetchable fetch_url, structural URL parsing |
| Threads | none | tg thread, resilient to unsynced roots, t.me link support |
| Search | LIKE scan |
FTS5 with Unicode-correct fallback and gap-safe regex paging |
| Sync integrity | best effort | gap-safe cursors, tg backfill, honest per-chat reports |
| Identity | bare IDs collide | marked peer IDs end-to-end with lazy migration |
| First sync | manual | tg bootstrap: survives reboots, removes itself when done |
| Send safety | sends immediately | dry-run by default, --confirm, mutation journal |
| Agent integration | a doc file | packaged skill, setup wizard, self-update, auto-activation, MCP bridge for desktop chat apps |
Credits
A fork of jackwener/tg-cli (Apache-2.0): the clean local-first core is theirs. Built on Telethon. License: Apache-2.0.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file telegram_to_agent_skill_cli-0.8.0.tar.gz.
File metadata
- Download URL: telegram_to_agent_skill_cli-0.8.0.tar.gz
- Upload date:
- Size: 586.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ab88310327fb54b162b44d6adc559b23a170b8dcc243f86cdfa439fff502db3b
|
|
| MD5 |
5e2e84e683eef572e56d0995d43da457
|
|
| BLAKE2b-256 |
6fb7a23dfb2290ade72ffcc6049ae04aee8cd227b3fd99816692ed237d3c22cd
|
Provenance
The following attestation bundles were made for telegram_to_agent_skill_cli-0.8.0.tar.gz:
Publisher:
release.yml on voftik/telegram-to-agent-skill-cli
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
telegram_to_agent_skill_cli-0.8.0.tar.gz -
Subject digest:
ab88310327fb54b162b44d6adc559b23a170b8dcc243f86cdfa439fff502db3b - Sigstore transparency entry: 2618830309
- Sigstore integration time:
-
Permalink:
voftik/telegram-to-agent-skill-cli@c39281cedbcfc9c851d9272627bf4d3c4e0446e5 -
Branch / Tag:
refs/tags/v0.8.0 - Owner: https://github.com/voftik
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@c39281cedbcfc9c851d9272627bf4d3c4e0446e5 -
Trigger Event:
push
-
Statement type:
File details
Details for the file telegram_to_agent_skill_cli-0.8.0-py3-none-any.whl.
File metadata
- Download URL: telegram_to_agent_skill_cli-0.8.0-py3-none-any.whl
- Upload date:
- Size: 100.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
457095290a4fe4b47a5b1be2a05cf1269141f86b0285643851138760ec59115d
|
|
| MD5 |
06aa1255772b83ffef241684938f77b4
|
|
| BLAKE2b-256 |
509463dd7cae801fd5bdfe342581b795e55fa515b98306247369a8def7370b2c
|
Provenance
The following attestation bundles were made for telegram_to_agent_skill_cli-0.8.0-py3-none-any.whl:
Publisher:
release.yml on voftik/telegram-to-agent-skill-cli
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
telegram_to_agent_skill_cli-0.8.0-py3-none-any.whl -
Subject digest:
457095290a4fe4b47a5b1be2a05cf1269141f86b0285643851138760ec59115d - Sigstore transparency entry: 2618830313
- Sigstore integration time:
-
Permalink:
voftik/telegram-to-agent-skill-cli@c39281cedbcfc9c851d9272627bf4d3c4e0446e5 -
Branch / Tag:
refs/tags/v0.8.0 - Owner: https://github.com/voftik
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@c39281cedbcfc9c851d9272627bf4d3c4e0446e5 -
Trigger Event:
push
-
Statement type: