Project Files
README
A lightweight LM Studio plugin that fetches, caches, and performs lexical RAG (Retrieval-Augmented Generation) search over public Telegram channel messages.
It uses Telegram's public web preview (t.me/s/<channel>), so no API keys or authentication are required. Messages are cached locally as pure JSON files, and search is powered by a BM25 lexical ranker with smoothed IDF.
~/.lmstudio/plugin-data/telegram-rag-cache/. No external databases required.ai, js, v2...), single-digit preservation (qwen 3), CJK bigram tokenization, and bounded exact-substring bonuses with deterministic tie-breaking.telegram_search_all ranks results across a channel list, your watchlist, or every cached channel with one query.latestId), avoiding redundant HTTP requests. Opt out with forceFullPages.[Poll] ...) — so their IDs and timestamps are never dropped.earliestId/latestId fields are backfilled.schemaVersion field for safe future migrations. Invalid watchlist entries are dropped instead of silently mangled.fullText parameter disables the 1200-character truncation on search and recent-message results.fs, path, os, https); schema validation uses zod via the LM Studio SDK.In LM Studio, open the plugin settings to configure:
| Setting | Description | Default |
|---|---|---|
| History Window | How far back to cache and search | 1 Month |
| Max Cached Messages | Upper bound on messages stored on disk per channel | 5,000 |
| Default Fetch Pages | Pages to fetch per sync (~20 messages/page) | 5 |
| Search Result Limit | Maximum number of search results returned | 10 |
| Tool Name | Description |
|---|---|
telegram_fetch_channel | Fetches recent messages for a channel and merges them into the local cache. Supports maxPages and forceFullPages. |
telegram_search | Searches one channel's cache using BM25 + smoothed IDF scoring. Supports limit and fullText. |
telegram_search_all | Searches multiple channels (explicit list, watchlist, or all cached channels) with one query. Supports limit and fullText. |
telegram_watchlist_add | Adds a channel to watchlist.json for regular syncing. |
telegram_watchlist_remove | Removes a channel from the watchlist. |
telegram_watchlist_sync | Fetches and updates the cache for every channel in the watchlist. Supports forceFullPages. |
telegram_cache_stats | Returns statistics (total cached, in-window count, date range) for a channel. |
telegram_get_recent | Returns the most recent N cached messages for a channel. Supports fullText. |
telegram_list_channels | Lists all channels that have cached data on disk. |
telegram_clear_cache | Deletes the local cache file for a specific channel. |
telegram_ping | Health check. Returns plugin status and the data directory. |
cache_info | Read-only research contract version 1.0: cache availability, counts, and last recorded channel sync attempt. |
search_cache | Read-only BM25 search across cached channels; optional limit, ISO 8601 since, and channel-handle source. |
get_cached_item | Read-only bounded excerpt for an itemId in channel/messageId form. |
The research provider identifies itself as mh825/telegram-rag-cache. Search hits and item lookups include a stable item ID, title, excerpt, cache timestamp, channel, original Telegram link, and publication timestamp when valid. cachedAt is the channel's recorded sync-attempt time, not proof of a successful refresh. The research tools do not fetch or write data. They return errors instead of hiding malformed caches or silently returning partial results; limits include 50 results, 32 MiB of cache files, 20,000 messages, and a two-second operation deadline. The deadline is checked during processing; synchronous JSON parsing and ranking steps cannot be interrupted until they return. Specify source to narrow large searches. Existing Telegram tools retain their prior behavior.
Research integrations should call cache_info first, then search_cache with a query and optional source and ISO timestamp (for example, 2026-11-01T00:00:00Z). Pass a returned itemId, such as durov/123, to get_cached_item. Cite the returned sourceUrl and check the source for context. An empty cache is available but has no items; a malformed or inaccessible cache produces an error. A client must have LM Studio's plugins.use permission for this plugin to start a tool session.
All channel-accepting tools normalize input automatically: @name, t.me/name, t.me/s/name, telegram.me/name, and full https://t.me/s/name?before=... URLs (including URL fragments and extra path segments) are all accepted.
Just talk to your LLM in LM Studio. Make sure the plugin is enabled in the Tools menu.
Setting up a watchlist
"Please add the channels
durovandtelegramto my Telegram watchlist."
Syncing data
"Sync my Telegram watchlist now."
The LLM fetches every channel in watchlist.json and caches their messages.
Searching (RAG)
"Search the
durovchannel for messages about AI or technology."
The LLM searches the local cache and returns the most relevant messages with direct t.me links.
Searching across everything
"Search all my cached Telegram channels for news about LLMs."
Runs one BM25 query across your watchlist (or every cached channel if the watchlist is empty) and returns the top hits ranked together.
Checking stats
"Show me the cache stats for the
telegramchannel."
~/.lmstudio/plugin-data/telegram-rag-cache/cache_<channel>.json~/.lmstudio/plugin-data/telegram-rag-cache/watchlist.jsonLM Studio's plugin output includes structured [telegram-rag-cache] events for completed or interrupted syncs and research-tool operations. They record elapsed time, outcome, and an error category where applicable; sync events also include page and message counts. They do not include search queries, message text, channel names, item IDs, or raw error messages. Access-denied errors raised before LM Studio starts a tool session appear in LM Studio's authenticator logs rather than plugin output.
This plugin adheres to the LM Studio SDK architecture rules:
src/index.ts entry point exporting async function main(context)."type": "module" in package.json (bundles to CommonJS).manifest.json contains only type, runner, owner, name, description, revision.createConfigSchematics with only select or numeric fields.tool() helper with plain Zod object parameters.__dirname / os.homedir() instead of import.meta.url.Install dependencies and type-check:
npm install npm run typecheck npm test
lms login # once, authenticates your LM Studio account lms push # uploads the artifact in this folder to LM Studio Hub
Bump revision in manifest.json (and version in package.json) for every published update — Hub updates require a higher revision than the previously published build.