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.
Metadata
Release files for telegram-to-agent-skill-cli 0.8.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| telegram_to_agent_skill_cli-0.8.0.tar.gz | 586.7 kB | With provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| telegram_to_agent_skill_cli-0.8.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 686.6 kB
Release files / telegram_to_agent_skill_cli-0.8.0.tar.gz
| Download URL | telegram_to_agent_skill_cli-0.8.0.tar.gz |
|---|---|
| Size | 586.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ab88310327fb54b162b44d6adc559b23a170b8dcc243f86cdfa439fff502db3b
|
|
BLAKE2b-256 checksum How to use checksums |
6fb7a23dfb2290ade72ffcc6049ae04aee8cd227b3fd99816692ed237d3c22cd
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 27, 2026.
Transparency logRelease files / telegram_to_agent_skill_cli-0.8.0-py3-none-any.whl
| Download URL | telegram_to_agent_skill_cli-0.8.0-py3-none-any.whl |
|---|---|
| Size | 100.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
457095290a4fe4b47a5b1be2a05cf1269141f86b0285643851138760ec59115d
|
|
BLAKE2b-256 checksum How to use checksums |
509463dd7cae801fd5bdfe342581b795e55fa515b98306247369a8def7370b2c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 27, 2026.
Transparency logSecurity for telegram-to-agent-skill-cli 0.8.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
All 2 files in this release have been uploaded with provenance metadata.
Attestation for telegram_to_agent_skill_cli-0.8.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 27, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.