tgsearch-mcp
Server Configuration
Describes the environment variables required to run the server.
| Name | Required | Description | Default |
|---|---|---|---|
| TG_API_ID | No | Telegram app credentials (api_id). | |
| TG_API_HASH | No | Telegram app credentials (api_hash). | |
| TGSEARCH_HOME | No | Fixed directory for both config and index. | |
| XDG_DATA_HOME | No | Data base directory (…/tgsearch-mcp/index.sqlite3). | ~/.local/share |
| TGSEARCH_INDEX | No | Local index path. | $XDG_DATA_HOME/tgsearch-mcp/index.sqlite3 |
| XDG_CONFIG_HOME | No | Config base directory (…/tgsearch-mcp/config.json). | ~/.config |
| TGSEARCH_TIMEOUT | No | Per-request timeout, in seconds. | 60 |
| TG_SESSION_STRING | No | Session string (overrides config.json). | |
| TGSEARCH_DIALOG_TTL | No | Dialog cache TTL, in seconds. | 300 |
| TGSEARCH_DIALOG_LIMIT | No | Maximum dialogs fetched per listing. | 1000 |
| TGSEARCH_INCLUDE_ARCHIVED | No | Include archived dialogs. | true |
| TGSEARCH_INDEX_TEXT_LIMIT | No | Maximum characters stored per message in the local index. | 10000 |
Instructions
Guidance the server publishes about itself, which clients place ahead of the tool catalog so the model reads it before choosing anything.
Read-only Telegram search over your own user account. Workflow: tg_find_chats -> tg_search_messages -> tg_get_messages(around_id=...) for context. Use tg_search_global for cross-chat search, and tg_index_chat + tg_search_index for fast local search over big histories. The server never sends, edits, joins or deletes anything.
Capabilities
Features and capabilities supported by this server
Protocol revision2025-11-25
| Capability | Details |
|---|---|
| tools | {
"listChanged": false
} |
| prompts | {
"listChanged": false
} |
| resources | {
"subscribe": false,
"listChanged": false
} |
Tools
Functions exposed to the LLM to take actions
| Name | Description |
|---|---|
| tg_statusA | Check Telegram configuration, login state, account and local index. Call this first. Never raises: when configuration or the session is missing it returns {ok:true, logged_in:false, hint}. |
| tg_find_chatsA | Find chats and return the exact Searches your dialogs by title/username/id and, for a non-empty query, the public Telegram directory. Public results include chats you have not joined; nothing is joined automatically. |
| tg_get_chatA | Get one chat's details: about, member count, pinned message, forum flag, public link and access restrictions. |
| tg_list_topicsA | List forum topics of a supergroup; use the returned topic_id as
|
| tg_search_messagesA | Server-side full-text search inside one chat - the fast path for
"find X in this channel". Results are newest first, with snippet, link and
a |
| tg_search_globalA | Search across all chats your account has access to. Public channels you have not joined are NOT included: open such a channel with tg_search_messages instead. |
| tg_get_messagesA | Read history or fetch specific messages. Use ids for exact messages, around_id for context around a search hit,
before_id/after_id for pagination, and no cursor for the latest messages.
Results are oldest first and include |
| tg_index_chatA | Build or update the local SQLite FTS5 index for one chat. Incremental by default: only messages newer than the indexed maximum are
fetched. Use it for large histories you query repeatedly, then search it
instantly with tg_search_index. On FloodWait the response carries
|
| tg_search_indexA | Search the local FTS5 index built by tg_index_chat. Works without network when |
Prompts
Interactive templates invoked by user choice
| Name | Description |
|---|---|
No prompts | |
Resources
Contextual data attached and managed by the client
| Name | Description |
|---|---|
No resources | |
TDQS
Scored across 9 tools
The three search tools (tg_search_messages, tg_search_global, tg_search_index) could initially look interchangeable, but the descriptions clearly scope each: one chat server-side, account-wide server-side, and local FTS5 cache. tg_get_messages vs tg_search_messages and tg_find_chats vs tg_get_chat are also cleanly differentiated by intent (discover vs read).
Every tool shares the tg_ prefix followed by a predictable verb_noun pattern (get_chat, find_chats, list_topics, search_messages, get_messages, index_chat, search_index). tg_status is the single noun-only exception but is idiomatic for a health/config probe.
Nine tools is well-scoped for a search/read-focused Telegram server, with each tool covering a distinct capability (status, lookup, topic listing, three search modes, history read, indexing). No obvious filler tools.
The search-and-read lifecycle is well covered: discover chats, inspect them, list topics, search per-chat/global/local-index, and paginate history. Minor gaps exist for write/side-effect actions (join a discovered public channel, send/reply, download media, list all dialogs without a query), but the stated search purpose is largely served.